1111from sentry .deletions .tasks .scheduled import run_scheduled_deletions
1212from sentry .grouping .grouptype import ErrorGroupType
1313from sentry .incidents .grouptype import MetricIssue
14- from sentry .notifications .types import FallthroughChoiceType
1514from sentry .testutils .asserts import assert_org_audit_log_exists
1615from sentry .testutils .cases import APITestCase
1716from sentry .testutils .outbox import outbox_runner
1817from sentry .testutils .silo import region_silo_test
19- from sentry .workflow_engine .models import (
20- Action ,
21- DataConditionGroupAction ,
22- DetectorWorkflow ,
23- Workflow ,
24- WorkflowDataConditionGroup ,
25- WorkflowFireHistory ,
26- )
18+ from sentry .workflow_engine .models import Action , DetectorWorkflow , Workflow , WorkflowFireHistory
2719from sentry .workflow_engine .models .data_condition import Condition
2820from sentry .workflow_engine .typings .notification_action import (
2921 ActionTarget ,
@@ -447,7 +439,7 @@ def test_create_workflow__with_config(self) -> None:
447439
448440 assert response .status_code == 201
449441 new_workflow = Workflow .objects .get (id = response .data ["id" ])
450- assert new_workflow . config == self . valid_workflow [ "config" ]
442+ assert response . data == serialize ( new_workflow )
451443
452444 def test_create_workflow__with_triggers (self ) -> None :
453445 self .valid_workflow ["triggers" ] = {
@@ -462,10 +454,7 @@ def test_create_workflow__with_triggers(self) -> None:
462454
463455 assert response .status_code == 201
464456 new_workflow = Workflow .objects .get (id = response .data ["id" ])
465- assert new_workflow .when_condition_group is not None
466- assert str (new_workflow .when_condition_group .id ) == response .data .get ("triggers" , {}).get (
467- "id"
468- )
457+ assert response .data == serialize (new_workflow )
469458
470459 @mock .patch (
471460 "sentry.notifications.notification_action.registry.action_validator_registry.get" ,
@@ -498,11 +487,7 @@ def test_create_workflow__with_actions(self, mock_action_validator: mock.MagicMo
498487
499488 assert response .status_code == 201
500489 new_workflow = Workflow .objects .get (id = response .data ["id" ])
501- new_action_filters = WorkflowDataConditionGroup .objects .filter (workflow = new_workflow )
502- assert len (new_action_filters ) == len (response .data .get ("actionFilters" , []))
503- assert str (new_action_filters [0 ].condition_group .id ) == response .data .get (
504- "actionFilters" , []
505- )[0 ].get ("id" )
490+ assert response .data == serialize (new_workflow )
506491
507492 @mock .patch (
508493 "sentry.notifications.notification_action.registry.action_validator_registry.get" ,
@@ -534,24 +519,7 @@ def test_create_workflow__with_fallthrough_type_action(
534519
535520 assert response .status_code == 201
536521 new_workflow = Workflow .objects .get (id = response .data ["id" ])
537- new_action_filters = WorkflowDataConditionGroup .objects .filter (workflow = new_workflow )
538- assert len (new_action_filters ) == len (response .data .get ("actionFilters" , []))
539- dcga = DataConditionGroupAction .objects .filter (
540- condition_group = new_action_filters [0 ].condition_group
541- ).first ()
542- assert dcga
543- assert str (new_action_filters [0 ].condition_group .id ) == response .data .get (
544- "actionFilters" , []
545- )[0 ].get ("id" )
546- assert (
547- response .data .get ("actionFilters" )[0 ]
548- .get ("actions" )[0 ]
549- .get ("data" )
550- .get ("fallthrough_type" )
551- == FallthroughChoiceType .ACTIVE_MEMBERS .value
552- )
553- assert dcga .action .type == Action .Type .EMAIL
554- assert dcga .action .data == {"fallthrough_type" : "ActiveMembers" }
522+ assert response .data == serialize (new_workflow )
555523
556524 @responses .activate
557525 def test_create_workflow_with_sentry_app_action (self ) -> None :
@@ -587,19 +555,7 @@ def test_create_workflow_with_sentry_app_action(self) -> None:
587555 raw_data = self .valid_workflow ,
588556 )
589557 updated_workflow = Workflow .objects .get (id = response .data ["id" ])
590- new_action_filters = WorkflowDataConditionGroup .objects .filter (workflow = updated_workflow )
591- dcga = DataConditionGroupAction .objects .filter (
592- condition_group = new_action_filters [0 ].condition_group
593- )
594- action = dcga [0 ].action
595-
596- assert action .type == Action .Type .SENTRY_APP
597- assert action .config == {
598- "sentry_app_identifier" : SentryAppIdentifier .SENTRY_APP_ID ,
599- "target_identifier" : str (self .sentry_app .id ),
600- "target_type" : ActionTarget .SENTRY_APP .value ,
601- }
602- assert action .data ["settings" ] == self .sentry_app_settings
558+ assert response .data == serialize (updated_workflow )
603559
604560 @responses .activate
605561 def test_create_sentry_app_action_missing_settings (self ) -> None :
@@ -679,19 +635,7 @@ def test_create_sentry_app_action_no_settings(self) -> None:
679635 raw_data = self .valid_workflow ,
680636 )
681637 updated_workflow = Workflow .objects .get (id = response .data ["id" ])
682- new_action_filters = WorkflowDataConditionGroup .objects .filter (workflow = updated_workflow )
683- dcga = DataConditionGroupAction .objects .filter (
684- condition_group = new_action_filters [0 ].condition_group
685- )
686- action = dcga [0 ].action
687-
688- assert action .type == Action .Type .SENTRY_APP
689- assert action .config == {
690- "sentry_app_identifier" : SentryAppIdentifier .SENTRY_APP_ID ,
691- "target_identifier" : str (sentry_app .id ),
692- "target_type" : ActionTarget .SENTRY_APP .value ,
693- }
694- assert action .data == {}
638+ assert response .data == serialize (updated_workflow )
695639
696640 def test_create_invalid_workflow (self ) -> None :
697641 self .valid_workflow ["name" ] = ""
0 commit comments