def test_missing_label_keys_zero(self): old_dict = { 'foo': ('test docstring', ('bar', 'baz'), { ('a', 'b'): 1, ('c', 'd'): 1 }), 'other': ('other docstring', (), { (): 1 }), } new_dict = { 'foo': ('test docstring', ('bar', 'baz'), { ('a', 'b'): 2 }), 'other': ('other docstring', (), { (): 2 }), } expected = { 'foo{bar="a",baz="b"}': 2, 'foo{bar="c",baz="d"}': 0, 'other': 2, } result = convert_metric_dict( merge_metric_dicts(old_dict, new_dict, zero_missing=True)) self.assertEqual(expected, result)
def test_new_metric(self): old_dict = { 'other': ('other docstring', (), { (): 1 }), } new_dict = { 'foo': ('test docstring', ('bar', 'baz'), { ('a', 'b'): 1 }), 'other': ('other docstring', (), { (): 2 }), } expected = { 'foo{bar="a",baz="b"}': 1, 'other': 2, } result = convert_metric_dict(merge_metric_dicts(old_dict, new_dict)) self.assertEqual(expected, result)