def test_increment_metrics_already_there(): metrics = collections.defaultdict(int, {'foo': 2, 'bar': 3}) increment_metric_values(metrics, [Metric('foo', 1), Metric('bar', 2)]) assert metrics == {'foo': 3, 'bar': 5}
def test_increment_metrics_first_time(): metrics = collections.defaultdict(int) increment_metric_values(metrics, [Metric('foo', 1), Metric('bar', 2)]) assert metrics == {'foo': 1, 'bar': 2}
def test_increment_metrics_already_there(): metric_values = collections.Counter({0: 2, 1: 3}) metrics = [Metric('foo', 1), Metric('bar', 2)] increment_metric_values(metric_values, {'foo': 0, 'bar': 1}, metrics) assert metric_values == {0: 3, 1: 5}
def test_increment_metrics_first_time(): metric_values = collections.Counter() metrics = [Metric('foo', 1), Metric('bar', 2)] increment_metric_values(metric_values, {'foo': 0, 'bar': 1}, metrics) assert metric_values == {0: 1, 1: 2}