From bf0c01eb484b576a8a5a0bac25b280f9ffb32e65 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 4 Mar 2013 12:31:48 -0500 Subject: [PATCH] Fix an invalid test in the storage test suite The test_by_user_period test is looking for the first result set to come back with the wrong timestampe, and not noticing that most of the test isn't even being run. Be more explicit about the expected results. Change-Id: I47e7699c877819d98f66d47dc85662f26767abd6 Signed-off-by: Doug Hellmann --- tests/storage/base.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/storage/base.py b/tests/storage/base.py index 8397b4b3e..500de31f8 100644 --- a/tests/storage/base.py +++ b/tests/storage/base.py @@ -804,23 +804,23 @@ class StatisticsTest(DBTestBase): self.assertEqual(set(r['period_end'] for r in results), set([datetime.datetime(2012, 9, 25, 12, 28), datetime.datetime(2012, 9, 25, 14, 28)])) - for r in results: - if r['period_start'] == datetime.datetime(2012, 9, 25, 10, 0): - self.assertEqual(r['count'], 2) - self.assertEqual(r['avg'], 8.5) - self.assertEqual(r['min'], 8) - self.assertEqual(r['max'], 9) - self.assertEqual(r['sum'], 17) - self.assertEqual(r['period'], 7200) - self.assertEqual(isinstance(r['period'], int)) - self.assertEqual(r['period_end'], - r['period_start'] - + datetime.timedelta(seconds=7200)) - self.assertEqual(r['duration'], 3660) - self.assertEqual(r['duration_start'], - datetime.datetime(2012, 9, 25, 10, 30)) - self.assertEqual(r['duration_end'], - datetime.datetime(2012, 9, 25, 11, 31)) + r = results[0] + self.assertEqual(r['period_start'], + datetime.datetime(2012, 9, 25, 10, 28)) + self.assertEqual(r['count'], 2) + self.assertEqual(r['avg'], 8.5) + self.assertEqual(r['min'], 8) + self.assertEqual(r['max'], 9) + self.assertEqual(r['sum'], 17) + self.assertEqual(r['period'], 7200) + self.assertIsInstance(r['period'], int) + expected_end = r['period_start'] + datetime.timedelta(seconds=7200) + self.assertEqual(r['period_end'], expected_end) + self.assertEqual(r['duration'], 3660) + self.assertEqual(r['duration_start'], + datetime.datetime(2012, 9, 25, 10, 30)) + self.assertEqual(r['duration_end'], + datetime.datetime(2012, 9, 25, 11, 31)) def test_by_project(self): f = storage.EventFilter(