Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: sitescripts/notifications/test/notification.py

Issue 29327106: Issue 3048 - Mark inactive notifications instead of removing them (Closed)
Patch Set: Simplify range selection and inactive check Created Sept. 11, 2015, 7:03 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sitescripts/notifications/parser.py ('k') | sitescripts/notifications/test/parser.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/notifications/test/notification.py
===================================================================
--- a/sitescripts/notifications/test/notification.py
+++ b/sitescripts/notifications/test/notification.py
@@ -299,5 +299,44 @@
self.assertEqual(len(result["notifications"]), 1)
self.assertEqual(result["notifications"][0]["id"], "1")
+ def test_stays_in_group_when_notification_present(self):
+ self.load_notifications_mock.return_value = [
+ {"id": "a"}
+ ]
+ result = json.loads(notification.notification({
+ "QUERY_STRING": "lastVersion=197001010000-a/0-b/1"
+ }, lambda *args: None))
+ self.assertEqual(len(result["notifications"]), 0)
+ self.assertRegexpMatches(result["version"], r"-a/0")
+
+ def test_leaves_group_when_notification_absent(self):
+ self.load_notifications_mock.return_value = []
+ result = json.loads(notification.notification({
+ "QUERY_STRING": "lastVersion=197001010000-a/0-b/1"
+ }, lambda *args: None))
+ self.assertEqual(len(result["notifications"]), 0)
+ self.assertRegexpMatches(result["version"], r"[^-]*")
+
+ def test_stays_in_group_when_notification_inactive(self):
+ self.load_notifications_mock.return_value = [
+ {"id": "a", "inactive": True}
+ ]
+ result = json.loads(notification.notification({
+ "QUERY_STRING": "lastVersion=197001010000-a/0-b/1"
+ }, lambda *args: None))
+ self.assertEqual(len(result["notifications"]), 0)
+ self.assertRegexpMatches(result["version"], r"-a/0")
+
+ def test_inactive_notifications_not_returned(self):
+ self.load_notifications_mock.return_value = [
+ {"id": "a", "title": {}, "message": {}, "inactive": True},
+ {"id": "b", "title": {}, "message": {}, "inactive": False},
+ {"id": "c", "title": {}, "message": {}}
+ ]
+ result = json.loads(notification.notification({}, lambda *args: None))
+ self.assertEqual(len(result["notifications"]), 2)
+ self.assertEqual(result["notifications"][0]["id"], "b")
+ self.assertEqual(result["notifications"][1]["id"], "c")
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « sitescripts/notifications/parser.py ('k') | sitescripts/notifications/test/parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld