|
1 | 1 | from datetime import timedelta |
2 | 2 | from unittest.mock import MagicMock, Mock, patch |
3 | 3 |
|
4 | | -import pytest |
5 | 4 | from django.utils import timezone |
6 | 5 |
|
7 | 6 | from sentry.eventstream.base import GroupState |
|
10 | 9 | from sentry.models.activity import Activity |
11 | 10 | from sentry.models.environment import Environment |
12 | 11 | from sentry.services.eventstore.models import GroupEvent |
13 | | -from sentry.testutils.factories import Factories |
14 | 12 | from sentry.testutils.helpers.datetime import before_now, freeze_time |
15 | 13 | from sentry.testutils.helpers.features import with_feature |
16 | | -from sentry.testutils.pytest.fixtures import django_db_all |
17 | 14 | from sentry.types.activity import ActivityType |
18 | 15 | from sentry.utils import json |
19 | 16 | from sentry.utils.cache import cache |
20 | 17 | from sentry.workflow_engine.buffer.batch_client import DelayedWorkflowClient, DelayedWorkflowItem |
21 | | -from sentry.workflow_engine.models import ( |
22 | | - Action, |
23 | | - DataConditionGroup, |
24 | | - DataConditionGroupAction, |
25 | | - Workflow, |
26 | | -) |
| 18 | +from sentry.workflow_engine.models import DataConditionGroup |
27 | 19 | from sentry.workflow_engine.models.data_condition import Condition |
28 | 20 | from sentry.workflow_engine.models.workflow_fire_history import WorkflowFireHistory |
29 | 21 | from sentry.workflow_engine.processors.contexts.workflow_event_context import ( |
|
32 | 24 | ) |
33 | 25 | from sentry.workflow_engine.processors.data_condition_group import get_data_conditions_for_group |
34 | 26 | from sentry.workflow_engine.processors.workflow import ( |
35 | | - delete_workflow, |
36 | 27 | enqueue_workflows, |
37 | 28 | evaluate_workflow_triggers, |
38 | 29 | evaluate_workflows_action_filters, |
@@ -1148,83 +1139,3 @@ def test_enqueue_workflow__adds_to_workflow_engine_set(self) -> None: |
1148 | 1139 | ) |
1149 | 1140 | }, |
1150 | 1141 | ) |
1151 | | - |
1152 | | - |
1153 | | -@django_db_all |
1154 | | -class TestDeleteWorkflow: |
1155 | | - @pytest.fixture(autouse=True) |
1156 | | - def setUp(self) -> None: |
1157 | | - self.organization = Factories.create_organization() |
1158 | | - self.project = Factories.create_project(organization=self.organization) |
1159 | | - |
1160 | | - self.workflow = Factories.create_workflow() |
1161 | | - self.workflow_trigger = Factories.create_data_condition_group( |
1162 | | - organization=self.organization |
1163 | | - ) |
1164 | | - self.workflow.when_condition_group = self.workflow_trigger |
1165 | | - self.workflow.save() |
1166 | | - |
1167 | | - self.action_filter = Factories.create_data_condition_group(organization=self.organization) |
1168 | | - self.action = Factories.create_action() |
1169 | | - self.action_and_filter = Factories.create_data_condition_group_action( |
1170 | | - condition_group=self.action_filter, |
1171 | | - action=self.action, |
1172 | | - ) |
1173 | | - |
1174 | | - self.workflow_actions = Factories.create_workflow_data_condition_group( |
1175 | | - workflow=self.workflow, |
1176 | | - condition_group=self.action_filter, |
1177 | | - ) |
1178 | | - |
1179 | | - self.trigger_condition = Factories.create_data_condition( |
1180 | | - condition_group=self.workflow_trigger, |
1181 | | - comparison=1, |
1182 | | - condition_result=True, |
1183 | | - ) |
1184 | | - |
1185 | | - self.action_condition = Factories.create_data_condition( |
1186 | | - condition_group=self.action_filter, |
1187 | | - comparison=1, |
1188 | | - condition_result=True, |
1189 | | - ) |
1190 | | - |
1191 | | - @pytest.mark.parametrize( |
1192 | | - "instance_attr", |
1193 | | - [ |
1194 | | - "workflow", |
1195 | | - "workflow_trigger", |
1196 | | - "action_filter", |
1197 | | - "action_and_filter", |
1198 | | - "workflow_actions", |
1199 | | - "trigger_condition", |
1200 | | - "action_condition", |
1201 | | - ], |
1202 | | - ) |
1203 | | - def test_delete_workflow(self, instance_attr: str) -> None: |
1204 | | - instance = getattr(self, instance_attr) |
1205 | | - instance_id = instance.id |
1206 | | - cls = instance.__class__ |
1207 | | - |
1208 | | - delete_workflow(self.workflow) |
1209 | | - assert not cls.objects.filter(id=instance_id).exists() |
1210 | | - |
1211 | | - def test_delete_workflow__no_actions(self) -> None: |
1212 | | - Action.objects.get(id=self.action.id).delete() |
1213 | | - assert not DataConditionGroupAction.objects.filter(id=self.action_and_filter.id).exists() |
1214 | | - |
1215 | | - workflow_id = self.workflow.id |
1216 | | - delete_workflow(self.workflow) |
1217 | | - |
1218 | | - assert not Workflow.objects.filter(id=workflow_id).exists() |
1219 | | - |
1220 | | - def test_delete_workflow__no_workflow_triggers(self) -> None: |
1221 | | - # TODO - when this condition group is deleted, it's removing the workflow |
1222 | | - # it's basically inverted from what's expected on the cascade delete |
1223 | | - self.workflow.when_condition_group = None |
1224 | | - self.workflow.save() |
1225 | | - |
1226 | | - DataConditionGroup.objects.get(id=self.workflow_trigger.id).delete() |
1227 | | - |
1228 | | - workflow_id = self.workflow.id |
1229 | | - delete_workflow(self.workflow) |
1230 | | - assert not Workflow.objects.filter(id=workflow_id).exists() |
0 commit comments