fix get_numeric_data

The change[1] introduced a failure for the grouped-runs page, there
is a case where if no data is provided to get_numeric_data it will error
with[2]

This change aims to fix that error by returning get_numeric_data early
if no data is provided.

[1] https://review.openstack.org/#/c/547866/
[2] http://paste.openstack.org/show/725854/

Change-Id: I02e9f40f4dcd44aefb47f5c8c96d9a318e034189
This commit is contained in:
mccasland, trevor (tm2086) 2018-07-13 14:55:50 -05:00
parent 741a457f72
commit 1febf0c179
2 changed files with 7 additions and 0 deletions

View File

@ -30,6 +30,8 @@ def format_output_numeric_dicts(df):
def get_numeric_data(run_times_time_series, sample_rate):
if not run_times_time_series:
return {}
temp_dict = {}
sample_rate = base.resample_matrix[sample_rate]
for run_at, run in run_times_time_series.items():

View File

@ -58,6 +58,11 @@ class TestRunAggregatorGetNumericData(base.TestCase):
}
}
def test_get_numeric_data_no_runs(self):
expected = {}
actual = run_aggregator.get_numeric_data({}, 'day')
self.assertEqual(expected, actual)
def test_get_numeric_data(self):
self.maxDiff = None
expected = {