1
+ from enum import IntEnum
2
+ from typing import Any , cast
1
3
from unittest import mock
2
4
3
5
import pytest
4
6
5
7
from sentry .testutils .cases import TestCase
6
8
from sentry .workflow_engine .models .data_condition import Condition , DataConditionEvaluationException
7
- from sentry .workflow_engine .types import DataConditionHandler , DetectorPriorityLevel , WorkflowEventData
8
- from tests .sentry .workflow_engine .endpoints .validators .test_base_data_condition import (
9
- MockDataConditionEnum ,
10
- MockDataConditionHandlerDictComparison ,
11
- )
12
9
from sentry .workflow_engine .registry import condition_handler_registry
10
+ from sentry .workflow_engine .types import (
11
+ DataConditionHandler ,
12
+ DetectorPriorityLevel ,
13
+ WorkflowEventData ,
14
+ )
13
15
from tests .sentry .workflow_engine .test_base import BaseWorkflowTest
14
16
15
17
@@ -69,18 +71,11 @@ def test_boolean(self):
69
71
70
72
71
73
class EvaluateValueTest (BaseWorkflowTest ):
72
- def setUp (self ):
74
+ def setUp (self ) -> None :
73
75
super ().setUp ()
74
- self .workflow_triggers = self .create_data_condition_group ()
75
- self .dict_comparison_dc = self .create_data_condition (
76
- type = "test" ,
77
- comparison = {
78
- "baz" : MockDataConditionEnum .FOO ,
79
- }
76
+ condition_handler_registry .registrations [Condition .REAPPEARED_EVENT ] = cast (
77
+ DataConditionHandler [Any ], MockDataConditionHandlerDictComparison
80
78
)
81
- condition_handler_registry .registrations [Condition .REAPPEARED_EVENT ] = (
82
- MockDataConditionHandlerDictComparison
83
- ) # type:ignore[assignment]
84
79
self .workflow_triggers = self .create_data_condition_group ()
85
80
self .dict_comparison_dc = self .create_data_condition (
86
81
type = Condition .REAPPEARED_EVENT ,
@@ -98,20 +93,7 @@ def test(self):
98
93
assert dc .evaluate_value (2 ) == DetectorPriorityLevel .HIGH
99
94
assert dc .evaluate_value (1 ) is None
100
95
101
- @mock .patch (
102
- "sentry.workflow_engine.registry.condition_handler_registry.get" ,
103
- return_value = MockDataConditionHandlerDictComparison ,
104
- )
105
- def test_dict_comparison_result_high (self , mock_dc_handler ):
106
- assert self .dict_comparison_dc .evaluate_value (2 ) == DetectorPriorityLevel .HIGH
107
-
108
- @mock .patch (
109
- "sentry.workflow_engine.registry.condition_handler_registry.get" ,
110
- return_value = MockDataConditionHandlerDictComparison ,
111
- )
112
-
113
96
def test_dict_comparison_result_high (self ):
114
- self .dict_comparison_dc .update (comparison = {"baz" : MockDataConditionEnum .BAR })
115
97
assert self .dict_comparison_dc .evaluate_value (2 ) == DetectorPriorityLevel .HIGH
116
98
117
99
def test_dict_comparison_result_ok (self ):
0 commit comments