Skip to content

Commit 1b66eaa

Browse files
ref: make condition_data / action_data param names match for create_project_rule (#80781)
<!-- Describe your PR here. -->
1 parent 350ad66 commit 1b66eaa

File tree

10 files changed

+63
-77
lines changed

10 files changed

+63
-77
lines changed

src/sentry/testutils/fixtures.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -190,24 +190,10 @@ def create_project_key(self, project=None, *args, **kwargs):
190190
project = self.project
191191
return Factories.create_project_key(project=project, *args, **kwargs)
192192

193-
def create_project_rule(
194-
self,
195-
project=None,
196-
action_match=None,
197-
condition_match=None,
198-
comparison_interval=None,
199-
*args,
200-
**kwargs,
201-
) -> Rule:
193+
def create_project_rule(self, project=None, *args, **kwargs) -> Rule:
202194
if project is None:
203195
project = self.project
204-
return Factories.create_project_rule(
205-
project=project,
206-
action_data=action_match,
207-
condition_data=condition_match,
208-
*args,
209-
**kwargs,
210-
)
196+
return Factories.create_project_rule(project, *args, **kwargs)
211197

212198
def create_slack_project_rule(
213199
self, project=None, integration_id=None, channel_id=None, channel_name=None, *args, **kwargs

tests/sentry/api/endpoints/test_project_rule_details.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,8 @@ def test_remove_conditions(self):
700700
"""Test that you can edit an alert rule to have no conditions (aka fire on every event)"""
701701
rule = self.create_project_rule(
702702
project=self.project,
703-
action_match=self.notify_issue_owners_action,
704-
condition_match=self.first_seen_condition,
703+
action_data=self.notify_issue_owners_action,
704+
condition_data=self.first_seen_condition,
705705
name="no conditions",
706706
)
707707
payload = {
@@ -729,8 +729,8 @@ def test_update_duplicate_rule(self):
729729
]
730730
rule = self.create_project_rule(
731731
project=self.project,
732-
action_match=self.notify_issue_owners_action,
733-
condition_match=conditions,
732+
action_data=self.notify_issue_owners_action,
733+
condition_data=conditions,
734734
)
735735
conditions.append(
736736
{
@@ -742,8 +742,8 @@ def test_update_duplicate_rule(self):
742742
)
743743
rule2 = self.create_project_rule(
744744
project=self.project,
745-
action_match=self.notify_issue_owners_action,
746-
condition_match=conditions,
745+
action_data=self.notify_issue_owners_action,
746+
condition_data=conditions,
747747
)
748748
conditions.pop(1)
749749
payload = {
@@ -769,13 +769,13 @@ def test_duplicate_rule_environment(self):
769769
that does have one set, we consider this when determining if it's a duplicate"""
770770
self.create_project_rule(
771771
project=self.project,
772-
action_match=self.notify_issue_owners_action,
773-
condition_match=self.first_seen_condition,
772+
action_data=self.notify_issue_owners_action,
773+
condition_data=self.first_seen_condition,
774774
)
775775
env_rule = self.create_project_rule(
776776
project=self.project,
777-
action_match=self.notify_issue_owners_action,
778-
condition_match=self.first_seen_condition,
777+
action_data=self.notify_issue_owners_action,
778+
condition_data=self.first_seen_condition,
779779
)
780780
payload = {
781781
"name": "hello world",
@@ -812,15 +812,15 @@ def test_duplicate_rule_both_have_environments(self):
812812
"""
813813
rule = self.create_project_rule(
814814
project=self.project,
815-
action_match=self.notify_issue_owners_action,
816-
condition_match=self.first_seen_condition,
815+
action_data=self.notify_issue_owners_action,
816+
condition_data=self.first_seen_condition,
817817
name="rule_with_env",
818818
environment_id=self.environment.id,
819819
)
820820
rule2 = self.create_project_rule(
821821
project=self.project,
822-
action_match=self.notify_issue_owners_action,
823-
condition_match=self.first_seen_condition,
822+
action_data=self.notify_issue_owners_action,
823+
condition_data=self.first_seen_condition,
824824
name="rule_wo_env",
825825
)
826826
payload = {
@@ -890,8 +890,8 @@ def test_edit_rule(self):
890890
]
891891
self.create_project_rule(
892892
project=self.project,
893-
action_match=self.notify_issue_owners_action,
894-
condition_match=conditions,
893+
action_data=self.notify_issue_owners_action,
894+
condition_data=conditions,
895895
)
896896
conditions.append(
897897
{

tests/sentry/api/endpoints/test_project_rule_enable.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ def test_duplicate_rule(self):
7272
}
7373
]
7474
rule = self.create_project_rule(
75-
project=self.project, action_match=actions, condition_match=conditions
75+
project=self.project, action_data=actions, condition_data=conditions
7676
)
7777

7878
rule2 = self.create_project_rule(
79-
project=self.project, action_match=actions, condition_match=conditions
79+
project=self.project, action_data=actions, condition_data=conditions
8080
)
8181
rule2.status = ObjectStatus.DISABLED
8282
rule2.save()
@@ -114,15 +114,15 @@ def test_duplicate_rule_diff_env(self):
114114
)
115115
self.create_project_rule(
116116
project=self.project,
117-
action_match=actions,
118-
condition_match=conditions,
117+
action_data=actions,
118+
condition_data=conditions,
119119
environment_id=dev_env.id,
120120
)
121121

122122
rule2 = self.create_project_rule(
123123
project=self.project,
124-
action_match=actions,
125-
condition_match=conditions,
124+
action_data=actions,
125+
condition_data=conditions,
126126
environment_id=prod_env.id,
127127
)
128128
rule2.status = ObjectStatus.DISABLED
@@ -154,15 +154,15 @@ def test_duplicate_rule_one_env_one_not(self):
154154
dev_env = self.create_environment(self.project, name="dev", organization=self.organization)
155155
self.create_project_rule(
156156
project=self.project,
157-
action_match=actions,
158-
condition_match=conditions,
157+
action_data=actions,
158+
condition_data=conditions,
159159
environment_id=dev_env.id,
160160
)
161161

162162
rule2 = self.create_project_rule(
163163
project=self.project,
164-
action_match=actions,
165-
condition_match=conditions,
164+
action_data=actions,
165+
condition_data=conditions,
166166
)
167167
rule2.status = ObjectStatus.DISABLED
168168
rule2.save()

tests/sentry/integrations/repository/issue_alert/test_issue_alert_notification_message_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def setUp(self) -> None:
2323
}
2424
]
2525
self.rule = self.create_project_rule(
26-
project=self.project, action_match=self.notify_issue_owners_action
26+
project=self.project, action_data=self.notify_issue_owners_action
2727
)
2828
self.event_id = 456
2929
self.notification_uuid = str(uuid4())

tests/sentry/integrations/slack/actions/notification/test_slack_notify_service_action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def setUp(self) -> None:
3939
"channel": "test-notifications",
4040
"uuid": self.uuid,
4141
}
42-
self.rule = self.create_project_rule(project=self.project, action_match=[self.action_data])
42+
self.rule = self.create_project_rule(project=self.project, action_data=[self.action_data])
4343
self.notification_uuid = str(uuid4())
4444
self.event = self.store_event(
4545
data={

tests/sentry/integrations/slack/notifications/test_issue_alert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def test_issue_alert_issue_owners_environment_block(self):
315315
)
316316
rule = self.create_project_rule(
317317
project=self.project,
318-
action_match=[action_data],
318+
action_data=[action_data],
319319
name="ja rule",
320320
environment_id=environment.id,
321321
)

tests/sentry/integrations/slack/service/test_slack_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def setUp(self) -> None:
6868
}
6969
]
7070
self.rule = self.create_project_rule(
71-
project=self.project, action_match=self.notify_issue_owners_action
71+
project=self.project, action_data=self.notify_issue_owners_action
7272
)
7373
self.rule_fire_history = RuleFireHistory.objects.create(
7474
project=self.project,
@@ -205,7 +205,7 @@ def setUp(self) -> None:
205205
"uuid": self.rule_action_uuid,
206206
}
207207
self.rule = self.create_project_rule(
208-
project=self.project, action_match=self.notify_issue_owners_action
208+
project=self.project, action_data=self.notify_issue_owners_action
209209
)
210210
self.rule_fire_history = RuleFireHistory.objects.create(
211211
project=self.project,
@@ -216,7 +216,7 @@ def setUp(self) -> None:
216216
)
217217

218218
self.slack_rule = self.create_project_rule(
219-
project=self.project, action_match=[self.slack_action]
219+
project=self.project, action_data=[self.slack_action]
220220
)
221221
self.slack_rule_fire_history = RuleFireHistory.objects.create(
222222
project=self.project,
@@ -314,7 +314,7 @@ def test_raises_exception_when_rule_action_does_not_exist(self) -> None:
314314
}
315315
]
316316
rule = self.create_project_rule(
317-
project=self.project, action_match=notify_issue_owners_action
317+
project=self.project, action_data=notify_issue_owners_action
318318
)
319319
rule_fire_history = RuleFireHistory.objects.create(
320320
project=self.project,

tests/sentry/migrations/test_0645_backfill_add_uuid_to_all_rule_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class BackfillAddUuidToAllRuleActions(TestMigrations):
1313
def setup_before_migration(self, apps):
1414
# Create your db state here
1515
self.notify_event_action = [{"id": "sentry.rules.actions.notify_event.NotifyEventAction"}]
16-
self.rule = self.create_project_rule(action_match=self.notify_event_action)
16+
self.rule = self.create_project_rule(action_data=self.notify_event_action)
1717

1818
@pytest.mark.skip(
1919
reason="This reaches into code to create projects, rather than migration code. Don't need this test anymore"

tests/sentry/models/test_rule.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def setUp(self) -> None:
2424
},
2525
]
2626
self.rule = self.create_project_rule(
27-
project=self.project, action_match=self.notify_issue_owners_action
27+
project=self.project, action_data=self.notify_issue_owners_action
2828
)
2929

3030
def test_simple(self) -> None:
@@ -38,15 +38,15 @@ def test_returns_none(self) -> None:
3838
def test_when_no_actions_are_in_rule(self) -> None:
3939
rule = self.create_project_rule(
4040
project=self.project,
41-
action_match=[],
41+
action_data=[],
4242
)
4343
result = rule.get_rule_action_details_by_uuid(str(uuid4()))
4444
assert result is None
4545

4646
def test_when_actions_have_missing_uuid_key(self) -> None:
4747
rule = self.create_project_rule(
4848
project=self.project,
49-
action_match=[
49+
action_data=[
5050
{
5151
"targetType": "IssueOwners",
5252
"fallthroughType": "ActiveMembers",
@@ -61,7 +61,7 @@ def test_when_actions_have_missing_uuid_key(self) -> None:
6161
def test_when_action_has_missing_uuid_value(self) -> None:
6262
rule = self.create_project_rule(
6363
project=self.project,
64-
action_match=[
64+
action_data=[
6565
{
6666
"targetType": "IssueOwners",
6767
"fallthroughType": "ActiveMembers",

0 commit comments

Comments
 (0)