def test_aggregate_detail(self): with patch("redis_metrics.templatetags.redis_metric_tags.get_r") as mock_r: slugs = ['a1', 'a2'] inst = mock_r.return_value inst._granularities.return_value = ['daily', 'weekly', 'monthly', 'yearly'] inst.get_metrics.return_value = [ ('a1', {'day': 1, 'week': 2, 'month': 3, 'year': 4}), ('a2', {'day': 3, 'week': 6, 'month': 9, 'year': 12}), ] result = taglib.aggregate_detail(slugs) expected_result = { 'chart_id': 'metric-aggregate-a1-a2', 'granularities': ['Day', 'Week', 'Month', 'Year'], 'slugs': slugs, 'metrics': [ ('a1', [1, 2, 3, 4]), ('a2', [3, 6, 9, 12]), ], 'with_data_table': False, } self.assertDictEqual(result, expected_result) mock_r.assert_called_once_with() inst.get_metrics.assert_called_once_with(slugs)
def test_aggregate_detail(self): with patch("redis_metrics.templatetags.redis_metric_tags.R") as mock_r: slugs = ['a1', 'a2'] inst = mock_r.return_value inst.get_metrics.return_value = 'RESULTS' result = taglib.aggregate_detail(slugs) expected_result = { 'slugs': slugs, 'metrics': 'RESULTS', } self.assertEqual(result, expected_result) mock_r.assert_called_once_with() inst.get_metrics.assert_called_once_with(slugs)