8
8
9
9
from django_github_app .mentions import Comment
10
10
from django_github_app .mentions import MentionScope
11
- from django_github_app .mentions import get_event_scope
12
11
from django_github_app .mentions import parse_mentions_for_username
13
12
14
13
@@ -188,83 +187,83 @@ def test_special_character_command(self, create_comment_event):
188
187
189
188
190
189
class TestGetEventScope :
191
- def test_get_event_scope_for_various_events (self ):
190
+ def test_from_event_for_various_events (self ):
192
191
# Issue comment on actual issue
193
192
event1 = sansio .Event ({"issue" : {}}, event = "issue_comment" , delivery_id = "1" )
194
- assert get_event_scope (event1 ) == MentionScope .ISSUE
193
+ assert MentionScope . from_event (event1 ) == MentionScope .ISSUE
195
194
196
195
# PR review comment
197
196
event2 = sansio .Event ({}, event = "pull_request_review_comment" , delivery_id = "2" )
198
- assert get_event_scope (event2 ) == MentionScope .PR
197
+ assert MentionScope . from_event (event2 ) == MentionScope .PR
199
198
200
199
# Commit comment
201
200
event3 = sansio .Event ({}, event = "commit_comment" , delivery_id = "3" )
202
- assert get_event_scope (event3 ) == MentionScope .COMMIT
201
+ assert MentionScope . from_event (event3 ) == MentionScope .COMMIT
203
202
204
203
def test_issue_scope_on_issue_comment (self ):
205
204
# Issue comment on an actual issue (no pull_request field)
206
205
issue_event = sansio .Event (
207
206
{"issue" : {"title" : "Bug report" }}, event = "issue_comment" , delivery_id = "1"
208
207
)
209
- assert get_event_scope (issue_event ) == MentionScope .ISSUE
208
+ assert MentionScope . from_event (issue_event ) == MentionScope .ISSUE
210
209
211
210
# Issue comment on a pull request (has pull_request field)
212
211
pr_event = sansio .Event (
213
212
{"issue" : {"title" : "PR title" , "pull_request" : {"url" : "..." }}},
214
213
event = "issue_comment" ,
215
214
delivery_id = "2" ,
216
215
)
217
- assert get_event_scope (pr_event ) == MentionScope .PR
216
+ assert MentionScope . from_event (pr_event ) == MentionScope .PR
218
217
219
218
def test_pr_scope_on_issue_comment (self ):
220
219
# Issue comment on an actual issue (no pull_request field)
221
220
issue_event = sansio .Event (
222
221
{"issue" : {"title" : "Bug report" }}, event = "issue_comment" , delivery_id = "1"
223
222
)
224
- assert get_event_scope (issue_event ) == MentionScope .ISSUE
223
+ assert MentionScope . from_event (issue_event ) == MentionScope .ISSUE
225
224
226
225
# Issue comment on a pull request (has pull_request field)
227
226
pr_event = sansio .Event (
228
227
{"issue" : {"title" : "PR title" , "pull_request" : {"url" : "..." }}},
229
228
event = "issue_comment" ,
230
229
delivery_id = "2" ,
231
230
)
232
- assert get_event_scope (pr_event ) == MentionScope .PR
231
+ assert MentionScope . from_event (pr_event ) == MentionScope .PR
233
232
234
233
def test_pr_scope_allows_pr_specific_events (self ):
235
234
# PR scope should allow pull_request_review_comment
236
235
event1 = sansio .Event ({}, event = "pull_request_review_comment" , delivery_id = "1" )
237
- assert get_event_scope (event1 ) == MentionScope .PR
236
+ assert MentionScope . from_event (event1 ) == MentionScope .PR
238
237
239
238
# PR scope should allow pull_request_review
240
239
event2 = sansio .Event ({}, event = "pull_request_review" , delivery_id = "2" )
241
- assert get_event_scope (event2 ) == MentionScope .PR
240
+ assert MentionScope . from_event (event2 ) == MentionScope .PR
242
241
243
242
# PR scope should not allow commit_comment
244
243
event3 = sansio .Event ({}, event = "commit_comment" , delivery_id = "3" )
245
- assert get_event_scope (event3 ) == MentionScope .COMMIT
244
+ assert MentionScope . from_event (event3 ) == MentionScope .COMMIT
246
245
247
246
def test_commit_scope_allows_commit_comment_only (self ):
248
247
# Commit scope should allow commit_comment
249
248
event1 = sansio .Event ({}, event = "commit_comment" , delivery_id = "1" )
250
- assert get_event_scope (event1 ) == MentionScope .COMMIT
249
+ assert MentionScope . from_event (event1 ) == MentionScope .COMMIT
251
250
252
251
# Commit scope should not allow issue_comment
253
252
event2 = sansio .Event ({"issue" : {}}, event = "issue_comment" , delivery_id = "2" )
254
- assert get_event_scope (event2 ) == MentionScope .ISSUE
253
+ assert MentionScope . from_event (event2 ) == MentionScope .ISSUE
255
254
256
255
# Commit scope should not allow PR events
257
256
event3 = sansio .Event ({}, event = "pull_request_review_comment" , delivery_id = "3" )
258
- assert get_event_scope (event3 ) == MentionScope .PR
257
+ assert MentionScope . from_event (event3 ) == MentionScope .PR
259
258
260
259
def test_different_event_types_have_correct_scope (self ):
261
260
# pull_request_review_comment should be PR scope
262
261
event1 = sansio .Event ({}, event = "pull_request_review_comment" , delivery_id = "1" )
263
- assert get_event_scope (event1 ) == MentionScope .PR
262
+ assert MentionScope . from_event (event1 ) == MentionScope .PR
264
263
265
264
# commit_comment should be COMMIT scope
266
265
event2 = sansio .Event ({}, event = "commit_comment" , delivery_id = "2" )
267
- assert get_event_scope (event2 ) == MentionScope .COMMIT
266
+ assert MentionScope . from_event (event2 ) == MentionScope .COMMIT
268
267
269
268
def test_pull_request_field_none_treated_as_issue (self ):
270
269
# If pull_request field exists but is None, treat as issue
@@ -273,17 +272,17 @@ def test_pull_request_field_none_treated_as_issue(self):
273
272
event = "issue_comment" ,
274
273
delivery_id = "1" ,
275
274
)
276
- assert get_event_scope (event ) == MentionScope .ISSUE
275
+ assert MentionScope . from_event (event ) == MentionScope .ISSUE
277
276
278
277
def test_missing_issue_data (self ):
279
278
# If issue data is missing entirely, defaults to ISSUE scope for issue_comment
280
279
event = sansio .Event ({}, event = "issue_comment" , delivery_id = "1" )
281
- assert get_event_scope (event ) == MentionScope .ISSUE
280
+ assert MentionScope . from_event (event ) == MentionScope .ISSUE
282
281
283
282
def test_unknown_event_returns_none (self ):
284
283
# Unknown event types should return None
285
284
event = sansio .Event ({}, event = "unknown_event" , delivery_id = "1" )
286
- assert get_event_scope (event ) is None
285
+ assert MentionScope . from_event (event ) is None
287
286
288
287
289
288
class TestComment :
0 commit comments