@@ -33,14 +33,15 @@ def webhook_comment_example(
33
33
34
34
35
35
def test_bugzilla_object_is_always_fetched (
36
- mocked_bugzilla , webhook_create_example , actions_factory , bug_factory
36
+ mocked_jira , mocked_bugzilla , webhook_create_example , actions_factory , bug_factory
37
37
):
38
38
# See https://github.com/mozilla/jira-bugzilla-integration/issues/292
39
39
fetched_bug = bug_factory (
40
40
id = webhook_create_example .bug .id ,
41
41
see_also = [f"{ get_settings ().jira_base_url } browse/JBI-234" ],
42
42
)
43
43
mocked_bugzilla .get_bug .return_value = fetched_bug
44
+ mocked_jira .get_issue .return_value = {"fields" : {"project" : {"key" : "JBI" }}}
44
45
45
46
execute_action (
46
47
request = webhook_create_example ,
@@ -50,6 +51,30 @@ def test_bugzilla_object_is_always_fetched(
50
51
mocked_bugzilla .get_bug .assert_called_once_with (webhook_create_example .bug .id )
51
52
52
53
54
+ def test_request_is_ignored_because_project_mismatch (
55
+ webhook_create_example : BugzillaWebhookRequest ,
56
+ actions_factory ,
57
+ mocked_jira ,
58
+ mocked_bugzilla ,
59
+ bug_factory ,
60
+ ):
61
+ bug = bug_factory (
62
+ id = webhook_create_example .bug .id ,
63
+ see_also = [f"{ get_settings ().jira_base_url } browse/JBI-234" ],
64
+ )
65
+ webhook_create_example .bug = bug
66
+ mocked_bugzilla .get_bug .return_value = bug
67
+ mocked_jira .get_issue .return_value = {"fields" : {"project" : {"key" : "FXDROID" }}}
68
+
69
+ with pytest .raises (IgnoreInvalidRequestError ) as exc_info :
70
+ execute_action (
71
+ request = webhook_create_example ,
72
+ actions = actions_factory (),
73
+ )
74
+
75
+ assert str (exc_info .value ) == "ignore linked project 'FXDROID' (!='JBI')"
76
+
77
+
53
78
def test_request_is_ignored_because_private (
54
79
webhook_create_example : BugzillaWebhookRequest ,
55
80
actions_factory ,
0 commit comments