Skip to content

Commit 2c08424

Browse files
committed
Add assertion about respective issues calls
1 parent 87d1d58 commit 2c08424

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def mocked_statsd():
5555
yield _mocked_statsd
5656

5757

58+
register(factories.ActionStepsFactory)
5859
register(factories.ActionContextFactory)
5960
register(factories.ActionFactory)
6061
register(factories.ActionsFactory, "_actions")

tests/fixtures/factories.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@ def _build(cls, model_class, *args, **kwargs):
2323
return model_class.model_construct(**kwargs)
2424

2525

26+
class ActionStepsFactory(PydanticFactory):
27+
class Meta:
28+
model = models.ActionSteps
29+
30+
2631
class ActionParamsFactory(PydanticFactory):
2732
class Meta:
2833
model = models.ActionParams
2934

35+
steps = factory.SubFactory(ActionStepsFactory)
3036
jira_project_key = "JBI"
3137
jira_components = {}
3238
labels_brackets = "no"

tests/unit/test_runner.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ def test_request_triggers_multiple_update_actions(
720720
webhook_request_factory,
721721
mocked_bugzilla,
722722
mocked_jira,
723+
webhook_event_change_factory,
723724
):
724725
actions = factories.ActionsFactory(
725726
root=[
@@ -728,12 +729,20 @@ def test_request_triggers_multiple_update_actions(
728729
bugzilla_user_id="tbd",
729730
description="test config",
730731
parameters__jira_project_key="JBI",
732+
parameters__steps__existing=["maybe_update_issue_resolution"],
733+
parameters__resolution_map={
734+
"FIXED": "Closed",
735+
},
731736
),
732737
factories.ActionFactory(
733738
whiteboard_tag="other",
734739
bugzilla_user_id="tbd",
735740
description="test config",
736741
parameters__jira_project_key="DE",
742+
parameters__steps__existing=["maybe_update_issue_resolution"],
743+
parameters__resolution_map={
744+
"FIXED": "Done",
745+
},
737746
),
738747
]
739748
)
@@ -744,6 +753,12 @@ def test_request_triggers_multiple_update_actions(
744753
"https://mozilla.atlassian.net/browse/JBI-234",
745754
"https://mozilla.atlassian.net/browse/DE-567",
746755
],
756+
bug__resolution="FIXED",
757+
event__changes=[
758+
webhook_event_change_factory(
759+
field="resolution", removed="OPEN", added="FIXED"
760+
)
761+
],
747762
)
748763
mocked_bugzilla.get_bug.return_value = webhook.bug
749764

@@ -759,9 +774,21 @@ def side_effect_for_get_issue(issue_key):
759774

760775
details = execute_action(request=webhook, actions=actions)
761776

777+
mocked_jira.update_issue_field.assert_any_call(
778+
key="JBI-234",
779+
fields={
780+
"resolution": {"name": "Closed"},
781+
},
782+
)
783+
mocked_jira.update_issue_field.assert_any_call(
784+
key="DE-567",
785+
fields={
786+
"resolution": {"name": "Done"},
787+
},
788+
)
789+
762790
# Details has the following shape:
763791
# {'devtest': {'responses': [..]}, 'other': {'responses': [...]}}
764792
assert len(actions) == len(details)
765793
assert "devtest" in details
766794
assert "other" in details
767-
print(details)

0 commit comments

Comments
 (0)