Exemplo n.º 1
0
 def test_matched_multiple_group_setter_not_collide(self):
     rule = Rule(Match(pattern_service_name='(\w+)_production'),
                 pattern_user_id='\d+',
                 event='ComeFrom.{0}')
     line = LineA(None, '2016-01-01 14:32', 'noxy_production', 43)
     self.assertTrue(rule.apply(line))
     self.assertEqual(line.event, 'ComeFrom.noxy')
Exemplo n.º 2
0
 def test_not_success_multiple_condition_2(self):
     m = Match(pattern_service_name='production.*', match_user_id=22)
     success, _ = m.check(LineA(None, '2016-01-01 14:32', 'noxy_production', 43))
     self.assertFalse(success)
Exemplo n.º 3
0
 def test_success_multiple_condition(self):
     m = Match(pattern_service_name='.*production', match_user_id=22)
     success, _ = m.check(LineA(None, '2016-01-01 14:32', 'noxy_production', 22))
     self.assertTrue(success)
Exemplo n.º 4
0
 def test_not_success_pattern_condition(self):
     m = Match(pattern_service_name='production.*')
     success, groups = m.check(LineA(None, '2016-01-01 14:32', 'noxy_production', 22))
     self.assertFalse(success)
Exemplo n.º 5
0
 def test_not_success_match_condition(self):
     m = Match(match_user_id=22)
     success, _ = m.check(LineA(None, '2016-01-01 14:32', 'noxy_production', 52))
     self.assertFalse(success)
Exemplo n.º 6
0
 def test_not_matched_ignore(self):
     rule = Rule(Match(match_user_id=22), ignore=True)
     line = LineA(None, '2016-01-01 14:32', 'noxy_production', 43)
     self.assertFalse(rule.apply(line))
Exemplo n.º 7
0
 def test_matched_ignore(self):
     rule = Rule(Match(match_user_id=22), ignore=True)
     line = LineA(None, '2016-01-01 14:32', 'noxy_production', 22)
     with self.assertRaises(IgnoreLine):
         rule.apply(line)
Exemplo n.º 8
0
 def test_not_success_multiple_condition_2(self):
     m = Match(pattern_service_name='production.*', match_user_id=22)
     success, _ = m.check(
         LineA(None, '2016-01-01 14:32', 'noxy_production', 43))
     self.assertFalse(success)
Exemplo n.º 9
0
 def test_success_multiple_condition(self):
     m = Match(pattern_service_name='.*production', match_user_id=22)
     success, _ = m.check(
         LineA(None, '2016-01-01 14:32', 'noxy_production', 22))
     self.assertTrue(success)
Exemplo n.º 10
0
 def test_not_success_pattern_condition(self):
     m = Match(pattern_service_name='production.*')
     success, groups = m.check(
         LineA(None, '2016-01-01 14:32', 'noxy_production', 22))
     self.assertFalse(success)
Exemplo n.º 11
0
 def test_not_success_match_condition(self):
     m = Match(match_user_id=22)
     success, _ = m.check(
         LineA(None, '2016-01-01 14:32', 'noxy_production', 52))
     self.assertFalse(success)
Exemplo n.º 12
0
 def test_not_matched_setter(self):
     rule = Rule(Match(match_user_id=22), not_existing=1, service_name=2)
     line = LineA(None, '2016-01-01 14:32', 'noxy_production', 43)
     self.assertFalse(rule.apply(line))
     self.assertFalse(hasattr(line, 'not_existing'))
     self.assertEqual(line.service_name, 'noxy_production')