Exemple #1
0
 def test_inhibition_eq_missing_parameters(self):
     with self.assertRaises(AnnotationError):
         from_json(
             json.loads('{"tag": "inhibition"'
                        ',"condition":'
                        '["eq", "openportmapper"]'
                        '}'))
Exemple #2
0
 def test_tag_always_true(self):
     annotation = from_json(
         json.loads('{"tag": "test-always-true"'
                    ',"condition": true'
                    '}'))
     self.assertEqual(annotation.tag, "test-always-true")
     self.assertTrue(annotation.matches({}))
Exemple #3
0
 def test_inhibition_inequality(self):
     annotation1 = from_json(
         json.loads('{"tag": "inhibition"'
                    ',"condition":'
                    '["eq"'
                    ', ["event_field"'
                    '  , "classification.identifier"'
                    '  ]'
                    ', "openportmapper"]'
                    '}'))
     annotation2 = from_json(
         json.loads('{"tag": "inhibition"'
                    ',"condition":'
                    '["eq"'
                    ', ["event_field"'
                    '  , "classification.identifier"'
                    '  ]'
                    ', "openmongodb"]'
                    '}'))
     self.assertFalse(annotation1 == annotation2)
     self.assertTrue(annotation1 != annotation2)
Exemple #4
0
 def test_tag_condition(self):
     annotation = from_json(
         json.loads('{"tag": "test-condition"'
                    ',"condition":'
                    '["eq"'
                    ', ["event_field"'
                    '  , "classification.identifier"'
                    '  ]'
                    ', "opensnmp"]'
                    '}'))
     self.assertEqual(annotation.tag, "test-condition")
     self.assertTrue(
         annotation.matches({"classification.identifier": "opensnmp"}))
Exemple #5
0
 def test_inhibition(self):
     annotation = from_json(
         json.loads('{"tag": "inhibition"'
                    ',"condition":'
                    '["eq"'
                    ', ["event_field"'
                    '  , "classification.identifier"'
                    '  ]'
                    ', "openportmapper"]'
                    '}'))
     self.assertTrue(
         annotation.matches({"classification.identifier":
                             "openportmapper"}))
     self.assertFalse(
         annotation.matches({"classification.identifier": "openmongodb"}))
Exemple #6
0
 def test_tag_non_string_value(self):
     with self.assertRaises(AnnotationError):
         from_json(json.loads('{"tag": 123}'))
Exemple #7
0
 def test_annotation_no_tag(self):
     with self.assertRaises(AnnotationError):
         from_json(json.loads('{"abc": "123"}'))
Exemple #8
0
 def test_tag_default_condition(self):
     annotation = from_json(json.loads('{"tag": "test-default-condition"}'))
     self.assertEqual(annotation.tag, "test-default-condition")
     self.assertTrue(annotation.matches({}))
Exemple #9
0
 def test_tag_inequality(self):
     annotation1 = from_json(json.loads('{"tag": "hourly"}'))
     annotation2 = from_json(json.loads('{"tag": "daily"}'))
     self.assertTrue(annotation1 != annotation2)
     self.assertFalse(annotation1 == annotation2)
Exemple #10
0
 def test_tag(self):
     annotation = from_json(json.loads('{"tag": "daily"}'))
     self.assertEqual(annotation.tag, "daily")
Exemple #11
0
 def test_inhibition_unknown_function(self):
     with self.assertRaises(AnnotationError):
         from_json(
             json.loads('{"tag": "inhibition"'
                        ',"condition": ["some_function", 1, "value"]'
                        '}'))
Exemple #12
0
 def test_inhibition_true(self):
     annotation = from_json(
         json.loads('{"tag": "inhibition"'
                    ',"condition": true}'))
     self.assertTrue(annotation.matches({}))