Skip to content

Commit b931c4b

Browse files
authored
Add tests for Bugzilla update see_also field (#245)
1 parent 22a7c9f commit b931c4b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tests/unit/actions/test_default.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def test_default_returns_callable_with_data(
4747
def test_created_public(
4848
webhook_create_example: BugzillaWebhookRequest, mocked_jira, mocked_bugzilla
4949
):
50+
mocked_jira.create_issue.return_value = {"key": "new-id"}
5051
mocked_bugzilla.get_bug.return_value = webhook_create_example.bug
5152
mocked_bugzilla.get_comments.return_value = [
5253
comment_factory(text="Initial comment")
@@ -65,6 +66,10 @@ def test_created_public(
6566
},
6667
)
6768

69+
mocked_bugzilla.update_bug.assert_called_once_with(
70+
654321, see_also={"add": ["https://mozit-test.atlassian.net/browse/new-id"]}
71+
)
72+
6873

6974
def test_modified_public(webhook_modify_example: BugzillaWebhookRequest, mocked_jira):
7075
assert webhook_modify_example.bug

tests/unit/services/test_bugzilla.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ def test_bugzilla_update_bug_uses_a_put(mocked_responses):
8484
url = f"{get_settings().bugzilla_base_url}/rest/bug/42"
8585
mocked_responses.add(responses.PUT, url, json={"bugs": [{"id": 42}]})
8686

87-
get_client().update_bug(42, see_also="http://url.com")
87+
get_client().update_bug(42, see_also={"add": ["http://url.com"]})
8888

89-
assert mocked_responses.calls[0].request.body == b'{"see_also": "http://url.com"}'
89+
assert (
90+
mocked_responses.calls[0].request.body
91+
== b'{"see_also": {"add": ["http://url.com"]}}'
92+
)
9093

9194

9295
@pytest.mark.no_mocked_bugzilla

0 commit comments

Comments
 (0)