Exemplo n.º 1
0
 def test_compute_common_top_level(self):
     """Alert Class - Compute Common - No Nested Dictionaries"""
     record1 = {'a': 1, 'b': 2, 'c': 3}
     record2 = {'b': 2, 'c': 3, 'd': 4}
     record3 = {'c': 3, 'd': 4, 'e': 5}
     assert_equal({'c': 3},
                  Alert._compute_common([record1, record2, record3]))
Exemplo n.º 2
0
 def test_compute_common_partial_nested(self):
     """Alert Class - Compute Common - Some Common Features in Nested Dictionary"""
     # This is the example given in the docstring
     record1 = {'abc': 123, 'nested': {'A': 1, 'B': 2}}
     record2 = {'abc': 123, 'def': 456, 'nested': {'A': 1}}
     assert_equal({
         'abc': 123,
         'nested': {
             'A': 1
         }
     }, Alert._compute_common([record1, record2]))
Exemplo n.º 3
0
 def test_compute_common_many_nested(self):
     """Alert Class - Compute Common - Multiple Levels of Nesting"""
     record1 = {'a': {'b': {'c': 3, 'd': 4}, 'e': {'h': {'i': 9}}, 'j': {}}}
     record2 = {
         'a': {
             'b': {
                 'c': 3,
             },
             'e': {
                 'f': {
                     'g': 8
                 },
                 'h': {}
             },
             'j': {}
         }
     }
     expected = {'a': {'b': {'c': 3}, 'j': {}}}
     assert_equal(expected, Alert._compute_common([record1, record2]))
Exemplo n.º 4
0
 def test_compute_common_all_identical(self):
     """Alert Class - Compute Common - Identical Records"""
     record = {'a': 1, 'b': 2, 'c': {'d': {'e': 3}}}
     assert_equal(record, Alert._compute_common([record] * 4))
Exemplo n.º 5
0
 def test_compute_common_different_types(self):
     """Alert Class - Compute Common - Same Keys, Different Types"""
     record1 = {'a': 1, 'b': None, 'c': {'d': {'e': 5}, 'f': {'g': 6}}}
     record2 = {'a': '1', 'b': 0, 'c': []}
     assert_equal({}, Alert._compute_common([record1, record2]))
Exemplo n.º 6
0
 def test_compute_common_no_similarities(self):
     """Alert Class - Compute Common - Empty Common Set"""
     record1 = {'a': -1, 'b': -2, 'c': -3, 'd': {'e': 0}}
     record2 = {'a': 1, 'b': 2, 'c': 3}
     assert_equal({}, Alert._compute_common([record1, record2]))
Exemplo n.º 7
0
 def test_compute_common_single_record(self):
     """Alert Class - Compute Common - Single Record"""
     # The greatest common subset of a single record is itself
     record = {'a': 1, 'b': 2, 'c': {'d': {'e': 3}}}
     assert_equal(record, Alert._compute_common([record]))
Exemplo n.º 8
0
 def test_compute_common_empty_record(self):
     """Alert Class - Compute Common - Empty Record List"""
     assert_equal({}, Alert._compute_common([]))