Example #1
0
 def test_can_merge_merge_keys_absent(self):
     """Alert Class - Can Merge - True if Merge Keys Do Not Exist in Either Record"""
     alert1 = Alert('', {},
                    set(),
                    merge_by_keys=['key'],
                    merge_window=timedelta(minutes=10))
     alert2 = Alert('', {},
                    set(),
                    merge_by_keys=['key'],
                    merge_window=timedelta(minutes=10))
     assert_true(alert1.can_merge(alert2))
     assert_true(alert2.can_merge(alert1))
Example #2
0
 def test_can_merge_different_values(self):
     """Alert Class - Can Merge - False if Merge Key has Different Values"""
     alert1 = Alert('', {'key': True},
                    set(),
                    merge_by_keys=['key'],
                    merge_window=timedelta(minutes=10))
     alert2 = Alert('', {'key': False},
                    set(),
                    merge_by_keys=['key'],
                    merge_window=timedelta(minutes=10))
     assert_false(alert1.can_merge(alert2))
     assert_false(alert2.can_merge(alert1))
Example #3
0
 def test_can_merge_key_not_common(self):
     """Alert Class - Can Merge - False if Merge Key Not Present in Both Records"""
     alert1 = Alert('', {'key': True},
                    set(),
                    merge_by_keys=['key'],
                    merge_window=timedelta(minutes=10))
     alert2 = Alert('', {'other': True},
                    set(),
                    merge_by_keys=['key'],
                    merge_window=timedelta(minutes=10))
     assert_false(alert1.can_merge(alert2))
     assert_false(alert2.can_merge(alert1))
Example #4
0
 def test_can_merge_different_merge_keys(self):
     """Alert Class - Can Merge - False if Different Merge Keys Defined"""
     alert1 = Alert('', {'key': True},
                    set(),
                    merge_by_keys=['key'],
                    merge_window=timedelta(minutes=10))
     alert2 = Alert('', {'key': True},
                    set(),
                    merge_by_keys=['other'],
                    merge_window=timedelta(minutes=10))
     assert_false(alert1.can_merge(alert2))
     assert_false(alert2.can_merge(alert1))
Example #5
0
 def test_can_merge_too_far_apart(self):
     """Alert Class - Can Merge - False if Outside Merge Window"""
     alert1 = Alert('', {'key': True},
                    set(),
                    created=datetime(year=2000, month=1, day=1, minute=0),
                    merge_by_keys=['key'],
                    merge_window=timedelta(minutes=10))
     alert2 = Alert('', {'key': True},
                    set(),
                    created=datetime(year=2000, month=1, day=1, minute=11),
                    merge_by_keys=['key'],
                    merge_window=timedelta(minutes=10))
     assert_false(alert1.can_merge(alert2))
     assert_false(alert2.can_merge(alert1))
Example #6
0
 def test_can_merge_true(self):
     """Alert Class - Can Merge - True Result"""
     alert1 = Alert(
         '', {'key': True}, set(),
         created=datetime(year=2000, month=1, day=1, minute=0),
         merge_by_keys=['key'],
         merge_window=timedelta(minutes=10)
     )
     alert2 = Alert(
         '', {'key': True, 'other': True}, set(),
         created=datetime(year=2000, month=1, day=1, minute=10),
         merge_by_keys=['key'],
         merge_window=timedelta(minutes=10)
     )
     assert_true(alert1.can_merge(alert2))
     assert_true(alert2.can_merge(alert1))