OLD | NEW |
(Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is govered by a BSD-style |
| 3 # license that can be found in the LICENSE file or at |
| 4 # https://developers.google.com/open-source/licenses/bsd |
| 5 |
| 6 """Tests for alert display helpers.""" |
| 7 |
| 8 import time |
| 9 import unittest |
| 10 |
| 11 from third_party import ezt |
| 12 |
| 13 from framework import alerts |
| 14 from testing import fake |
| 15 from testing import testing_helpers |
| 16 |
| 17 |
| 18 class AlertsViewTest(unittest.TestCase): |
| 19 |
| 20 def testTimestamp(self): |
| 21 """Tests that alerts are only shown when the timestamp is valid.""" |
| 22 project = fake.Project(project_name='testproj') |
| 23 |
| 24 now = int(time.time()) |
| 25 mr = testing_helpers.MakeMonorailRequest( |
| 26 path='/p/testproj/?updated=10&ts=%s' % now, project=project) |
| 27 alerts_view = alerts.AlertsView(mr) |
| 28 self.assertEqual(10, alerts_view.updated) |
| 29 self.assertEqual(ezt.boolean(True), alerts_view.show) |
| 30 |
| 31 now -= 10 |
| 32 mr = testing_helpers.MakeMonorailRequest( |
| 33 path='/p/testproj/?updated=10&ts=%s' % now, project=project) |
| 34 alerts_view = alerts.AlertsView(mr) |
| 35 self.assertEqual(ezt.boolean(False), alerts_view.show) |
| 36 |
| 37 mr = testing_helpers.MakeMonorailRequest( |
| 38 path='/p/testproj/?updated=10', project=project) |
| 39 alerts_view = alerts.AlertsView(mr) |
| 40 self.assertEqual(ezt.boolean(False), alerts_view.show) |
| 41 |
| 42 |
| 43 if __name__ == '__main__': |
| 44 unittest.main() |
OLD | NEW |