2
2
3
3
from gidgethub import sansio
4
4
5
- from django_github_app .commands import CommandScope
6
- from django_github_app .commands import check_event_for_mention
7
- from django_github_app .commands import check_event_scope
8
- from django_github_app .commands import parse_mentions
5
+ from django_github_app .mentions import MentionScope
6
+ from django_github_app .mentions import check_event_for_mention
7
+ from django_github_app .mentions import check_event_scope
8
+ from django_github_app .mentions import parse_mentions
9
9
10
10
11
11
class TestParseMentions :
@@ -231,65 +231,65 @@ def test_issue_scope_on_issue_comment(self):
231
231
issue_event = sansio .Event (
232
232
{"issue" : {"title" : "Bug report" }}, event = "issue_comment" , delivery_id = "1"
233
233
)
234
- assert check_event_scope (issue_event , CommandScope .ISSUE ) is True
234
+ assert check_event_scope (issue_event , MentionScope .ISSUE ) is True
235
235
236
236
# Issue comment on a pull request (has pull_request field)
237
237
pr_event = sansio .Event (
238
238
{"issue" : {"title" : "PR title" , "pull_request" : {"url" : "..." }}},
239
239
event = "issue_comment" ,
240
240
delivery_id = "2" ,
241
241
)
242
- assert check_event_scope (pr_event , CommandScope .ISSUE ) is False
242
+ assert check_event_scope (pr_event , MentionScope .ISSUE ) is False
243
243
244
244
def test_pr_scope_on_issue_comment (self ):
245
245
# Issue comment on an actual issue (no pull_request field)
246
246
issue_event = sansio .Event (
247
247
{"issue" : {"title" : "Bug report" }}, event = "issue_comment" , delivery_id = "1"
248
248
)
249
- assert check_event_scope (issue_event , CommandScope .PR ) is False
249
+ assert check_event_scope (issue_event , MentionScope .PR ) is False
250
250
251
251
# Issue comment on a pull request (has pull_request field)
252
252
pr_event = sansio .Event (
253
253
{"issue" : {"title" : "PR title" , "pull_request" : {"url" : "..." }}},
254
254
event = "issue_comment" ,
255
255
delivery_id = "2" ,
256
256
)
257
- assert check_event_scope (pr_event , CommandScope .PR ) is True
257
+ assert check_event_scope (pr_event , MentionScope .PR ) is True
258
258
259
259
def test_pr_scope_allows_pr_specific_events (self ):
260
260
# PR scope should allow pull_request_review_comment
261
261
event1 = sansio .Event ({}, event = "pull_request_review_comment" , delivery_id = "1" )
262
- assert check_event_scope (event1 , CommandScope .PR ) is True
262
+ assert check_event_scope (event1 , MentionScope .PR ) is True
263
263
264
264
# PR scope should allow pull_request_review
265
265
event2 = sansio .Event ({}, event = "pull_request_review" , delivery_id = "2" )
266
- assert check_event_scope (event2 , CommandScope .PR ) is True
266
+ assert check_event_scope (event2 , MentionScope .PR ) is True
267
267
268
268
# PR scope should not allow commit_comment
269
269
event3 = sansio .Event ({}, event = "commit_comment" , delivery_id = "3" )
270
- assert check_event_scope (event3 , CommandScope .PR ) is False
270
+ assert check_event_scope (event3 , MentionScope .PR ) is False
271
271
272
272
def test_commit_scope_allows_commit_comment_only (self ):
273
273
# Commit scope should allow commit_comment
274
274
event1 = sansio .Event ({}, event = "commit_comment" , delivery_id = "1" )
275
- assert check_event_scope (event1 , CommandScope .COMMIT ) is True
275
+ assert check_event_scope (event1 , MentionScope .COMMIT ) is True
276
276
277
277
# Commit scope should not allow issue_comment
278
278
event2 = sansio .Event ({"issue" : {}}, event = "issue_comment" , delivery_id = "2" )
279
- assert check_event_scope (event2 , CommandScope .COMMIT ) is False
279
+ assert check_event_scope (event2 , MentionScope .COMMIT ) is False
280
280
281
281
# Commit scope should not allow PR events
282
282
event3 = sansio .Event ({}, event = "pull_request_review_comment" , delivery_id = "3" )
283
- assert check_event_scope (event3 , CommandScope .COMMIT ) is False
283
+ assert check_event_scope (event3 , MentionScope .COMMIT ) is False
284
284
285
285
def test_issue_scope_disallows_non_issue_events (self ):
286
286
# Issue scope should not allow pull_request_review_comment
287
287
event1 = sansio .Event ({}, event = "pull_request_review_comment" , delivery_id = "1" )
288
- assert check_event_scope (event1 , CommandScope .ISSUE ) is False
288
+ assert check_event_scope (event1 , MentionScope .ISSUE ) is False
289
289
290
290
# Issue scope should not allow commit_comment
291
291
event2 = sansio .Event ({}, event = "commit_comment" , delivery_id = "2" )
292
- assert check_event_scope (event2 , CommandScope .ISSUE ) is False
292
+ assert check_event_scope (event2 , MentionScope .ISSUE ) is False
293
293
294
294
def test_pull_request_field_none_treated_as_issue (self ):
295
295
# If pull_request field exists but is None, treat as issue
@@ -298,11 +298,11 @@ def test_pull_request_field_none_treated_as_issue(self):
298
298
event = "issue_comment" ,
299
299
delivery_id = "1" ,
300
300
)
301
- assert check_event_scope (event , CommandScope .ISSUE ) is True
302
- assert check_event_scope (event , CommandScope .PR ) is False
301
+ assert check_event_scope (event , MentionScope .ISSUE ) is True
302
+ assert check_event_scope (event , MentionScope .PR ) is False
303
303
304
304
def test_missing_issue_data (self ):
305
305
# If issue data is missing entirely, default behavior
306
306
event = sansio .Event ({}, event = "issue_comment" , delivery_id = "1" )
307
- assert check_event_scope (event , CommandScope .ISSUE ) is True
308
- assert check_event_scope (event , CommandScope .PR ) is False
307
+ assert check_event_scope (event , MentionScope .ISSUE ) is True
308
+ assert check_event_scope (event , MentionScope .PR ) is False
0 commit comments