Project import generated by Copybara.

GitOrigin-RevId: d9e9e3fb4e31372ec1fb43b178994ca78fa8fe70
diff --git a/framework/test/alerts_test.py b/framework/test/alerts_test.py
new file mode 100644
index 0000000..0c398c1
--- /dev/null
+++ b/framework/test/alerts_test.py
@@ -0,0 +1,43 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""Tests for alert display helpers."""
+from __future__ import print_function
+from __future__ import division
+from __future__ import absolute_import
+
+import time
+import unittest
+
+import ezt
+
+from framework import alerts
+from testing import fake
+from testing import testing_helpers
+
+
+class AlertsViewTest(unittest.TestCase):
+
+  def testTimestamp(self):
+    """Tests that alerts are only shown when the timestamp is valid."""
+    project = fake.Project(project_name='testproj')
+
+    now = int(time.time())
+    mr = testing_helpers.MakeMonorailRequest(
+        path='/p/testproj/?updated=10&ts=%s' % now, project=project)
+    alerts_view = alerts.AlertsView(mr)
+    self.assertEqual(10, alerts_view.updated)
+    self.assertEqual(ezt.boolean(True), alerts_view.show)
+
+    now -= 10
+    mr = testing_helpers.MakeMonorailRequest(
+        path='/p/testproj/?updated=10&ts=%s' % now, project=project)
+    alerts_view = alerts.AlertsView(mr)
+    self.assertEqual(ezt.boolean(False), alerts_view.show)
+
+    mr = testing_helpers.MakeMonorailRequest(
+        path='/p/testproj/?updated=10', project=project)
+    alerts_view = alerts.AlertsView(mr)
+    self.assertEqual(ezt.boolean(False), alerts_view.show)