def test_compute_diff_many_nested(self): """Alert Class - Compute Diff - Multiple Levels of Nesting""" # These values are the same as those from test_compute_common_many_nested record1 = {'a': {'b': {'c': 3, 'd': 4}, 'e': {'h': {'i': 9}}, 'j': {}}} record2 = { 'a': { 'b': { 'c': 3, }, 'e': { 'f': { 'g': 8 }, 'h': {} }, 'j': {} } } common = {'a': {'b': {'c': 3}, 'j': {}}} expected_diff1 = {'a': {'b': {'d': 4}, 'e': {'h': {'i': 9}}}} assert_equal(expected_diff1, Alert._compute_diff(common, record1)) expected_diff2 = {'a': {'e': {'f': {'g': 8}, 'h': {}}}} assert_equal(expected_diff2, Alert._compute_diff(common, record2))
def test_compute_diff_nested(self): """Alert Class - Compute Diff - Difference in Nested Dictionary""" # This is the example given in the docstring common = {'abc': 123, 'nested': {'A': 1}} record = {'abc': 123, 'nested': {'A': 1, 'B': 2}} assert_equal({'nested': {'B': 2}}, Alert._compute_diff(common, record))
def test_compute_diff_different_types(self): """Alert Class - Compute Diff - Type Mismatch Short-Circuits Recursion""" common = {'b': 2} record = {'a': 1, 'b': {'nested': 'stuff'}} assert_equal(record, Alert._compute_diff(common, record))
def test_compute_diff_top_level(self): """Alert Class - Compute Diff - Top Level Keys""" common = {'c': 3} record = {'a': 1, 'b': 2, 'c': 3} assert_equal({'a': 1, 'b': 2}, Alert._compute_diff(common, record))
def test_compute_diff_no_diff(self): """Alert Class - Compute Diff - Record Identical to Common""" record = {'a': 1, 'b': 2, 'c': {'d': {'e': 3}}} common = record assert_equal({}, Alert._compute_diff(common, record))
def test_compute_diff_no_common(self): """Alert Class - Compute Diff - No Common Set""" record = {'a': 1, 'b': 2, 'c': {'d': {'e': 3}}} assert_equal(record, Alert._compute_diff({}, record))