17
17
from sentry .rules import init_registry
18
18
from sentry .rules .conditions import EventCondition
19
19
from sentry .rules .filters .base import EventFilter
20
- from sentry .rules .processor import RuleProcessor
20
+ from sentry .rules .processing . processor import RuleProcessor
21
21
from sentry .testutils .cases import TestCase
22
22
from sentry .testutils .helpers import install_slack
23
23
from sentry .testutils .helpers .features import with_feature
37
37
38
38
39
39
class MockConditionTrue (EventCondition ):
40
- id = "tests.sentry.rules.test_processor.MockConditionTrue"
40
+ id = "tests.sentry.rules.processing. test_processor.MockConditionTrue"
41
41
label = "Mock condition which always passes."
42
42
43
43
def passes (self , event , state ):
@@ -317,7 +317,9 @@ def test_multiple_rules(self):
317
317
318
318
# Test that we don't get errors if we try to create statuses that already exist due to a
319
319
# race condition
320
- with mock .patch ("sentry.rules.processor.GroupRuleStatus" ) as mocked_GroupRuleStatus :
320
+ with mock .patch (
321
+ "sentry.rules.processing.processor.GroupRuleStatus"
322
+ ) as mocked_GroupRuleStatus :
321
323
call_count = 0
322
324
323
325
def mock_filter (* args , ** kwargs ):
@@ -339,7 +341,7 @@ def mock_filter(*args, **kwargs):
339
341
[
340
342
"sentry.mail.actions.NotifyEmailAction" ,
341
343
"sentry.rules.conditions.event_frequency.EventFrequencyCondition" ,
342
- "tests.sentry.rules.test_processor.MockConditionTrue" ,
344
+ "tests.sentry.rules.processing. test_processor.MockConditionTrue" ,
343
345
],
344
346
)
345
347
def test_slow_conditions_evaluate_last (self ):
@@ -349,14 +351,14 @@ def test_slow_conditions_evaluate_last(self):
349
351
data = {
350
352
"conditions" : [
351
353
{"id" : "sentry.rules.conditions.event_frequency.EventFrequencyCondition" },
352
- {"id" : "tests.sentry.rules.test_processor.MockConditionTrue" },
354
+ {"id" : "tests.sentry.rules.processing. test_processor.MockConditionTrue" },
353
355
],
354
356
"action_match" : "any" ,
355
357
"actions" : [EMAIL_ACTION_DATA ],
356
358
},
357
359
)
358
360
with (
359
- patch ("sentry.rules.processor.rules" , init_registry ()),
361
+ patch ("sentry.rules.processing. processor.rules" , init_registry ()),
360
362
patch (
361
363
"sentry.rules.conditions.event_frequency.BaseEventFrequencyCondition.passes"
362
364
) as passes ,
@@ -376,15 +378,15 @@ def test_slow_conditions_evaluate_last(self):
376
378
377
379
378
380
class MockFilterTrue (EventFilter ):
379
- id = "tests.sentry.rules.test_processor.MockFilterTrue"
381
+ id = "tests.sentry.rules.processing. test_processor.MockFilterTrue"
380
382
label = "Mock filter which always passes."
381
383
382
384
def passes (self , event , state ):
383
385
return True
384
386
385
387
386
388
class MockFilterFalse (EventFilter ):
387
- id = "tests.sentry.rules.test_processor.MockFilterFalse"
389
+ id = "tests.sentry.rules.processing. test_processor.MockFilterFalse"
388
390
label = "Mock filter which never passes."
389
391
390
392
def passes (self , event , state ):
@@ -395,8 +397,8 @@ class RuleProcessorTestFilters(TestCase):
395
397
MOCK_SENTRY_RULES_WITH_FILTERS = (
396
398
"sentry.mail.actions.NotifyEmailAction" ,
397
399
"sentry.rules.conditions.every_event.EveryEventCondition" ,
398
- "tests.sentry.rules.test_processor.MockFilterTrue" ,
399
- "tests.sentry.rules.test_processor.MockFilterFalse" ,
400
+ "tests.sentry.rules.processing. test_processor.MockFilterTrue" ,
401
+ "tests.sentry.rules.processing. test_processor.MockFilterFalse" ,
400
402
)
401
403
402
404
def setUp (self ):
@@ -406,7 +408,7 @@ def setUp(self):
406
408
@patch ("sentry.constants._SENTRY_RULES" , MOCK_SENTRY_RULES_WITH_FILTERS )
407
409
def test_filter_passes (self ):
408
410
# setup a simple alert rule with 1 condition and 1 filter that always pass
409
- filter_data = {"id" : "tests.sentry.rules.test_processor.MockFilterTrue" }
411
+ filter_data = {"id" : "tests.sentry.rules.processing. test_processor.MockFilterTrue" }
410
412
411
413
Rule .objects .filter (project = self .group_event .project ).delete ()
412
414
ProjectOwnership .objects .create (project_id = self .project .id , fallthrough = True )
@@ -418,7 +420,7 @@ def test_filter_passes(self):
418
420
},
419
421
)
420
422
# patch the rule registry to contain the mocked rules
421
- with patch ("sentry.rules.processor.rules" , init_registry ()):
423
+ with patch ("sentry.rules.processing. processor.rules" , init_registry ()):
422
424
rp = RuleProcessor (
423
425
self .group_event ,
424
426
is_new = True ,
@@ -436,7 +438,7 @@ def test_filter_passes(self):
436
438
@patch ("sentry.constants._SENTRY_RULES" , MOCK_SENTRY_RULES_WITH_FILTERS )
437
439
def test_filter_fails (self ):
438
440
# setup a simple alert rule with 1 condition and 1 filter that doesn't pass
439
- filter_data = {"id" : "tests.sentry.rules.test_processor.MockFilterFalse" }
441
+ filter_data = {"id" : "tests.sentry.rules.processing. test_processor.MockFilterFalse" }
440
442
441
443
Rule .objects .filter (project = self .group_event .project ).delete ()
442
444
self .rule = Rule .objects .create (
@@ -447,7 +449,7 @@ def test_filter_fails(self):
447
449
},
448
450
)
449
451
# patch the rule registry to contain the mocked rules
450
- with patch ("sentry.rules.processor.rules" , init_registry ()):
452
+ with patch ("sentry.rules.processing. processor.rules" , init_registry ()):
451
453
rp = RuleProcessor (
452
454
self .group_event ,
453
455
is_new = True ,
@@ -553,15 +555,15 @@ def test_last_active_too_recent(self):
553
555
)
554
556
555
557
with mock .patch (
556
- "sentry.rules.processor.RuleProcessor.bulk_get_rule_status" ,
558
+ "sentry.rules.processing. processor.RuleProcessor.bulk_get_rule_status" ,
557
559
return_value = {self .rule .id : grs },
558
560
):
559
561
results = list (rp .apply ())
560
562
assert len (results ) == 0
561
563
562
- @mock .patch ("sentry.rules.processor.RuleProcessor.logger" )
564
+ @mock .patch ("sentry.rules.processing. processor.RuleProcessor.logger" )
563
565
def test_invalid_predicate (self , mock_logger ):
564
- filter_data = {"id" : "tests.sentry.rules.test_processor.MockFilterTrue" }
566
+ filter_data = {"id" : "tests.sentry.rules.processing. test_processor.MockFilterTrue" }
565
567
566
568
Rule .objects .filter (project = self .group_event .project ).delete ()
567
569
ProjectOwnership .objects .create (project_id = self .project .id , fallthrough = True )
@@ -573,7 +575,7 @@ def test_invalid_predicate(self, mock_logger):
573
575
},
574
576
)
575
577
576
- with patch ("sentry.rules.processor.get_match_function" , return_value = None ):
578
+ with patch ("sentry.rules.processing. processor.get_match_function" , return_value = None ):
577
579
rp = RuleProcessor (
578
580
self .group_event ,
579
581
is_new = True ,
0 commit comments