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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sitescripts/notifications/parser.py ('k') | sitescripts/notifications/test/parser.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 def test_invalid_notification_not_returned(self): 292 def test_invalid_notification_not_returned(self):
293 self.load_notifications_mock.return_value = [ 293 self.load_notifications_mock.return_value = [
294 {"id": "1", "title": {}, "message": {}}, 294 {"id": "1", "title": {}, "message": {}},
295 {"id": "2", "title": {}}, 295 {"id": "2", "title": {}},
296 {"id": "3", "message": {}} 296 {"id": "3", "message": {}}
297 ] 297 ]
298 result = json.loads(notification.notification({}, lambda *args: None)) 298 result = json.loads(notification.notification({}, lambda *args: None))
299 self.assertEqual(len(result["notifications"]), 1) 299 self.assertEqual(len(result["notifications"]), 1)
300 self.assertEqual(result["notifications"][0]["id"], "1") 300 self.assertEqual(result["notifications"][0]["id"], "1")
301 301
302 def test_stays_in_group_when_notification_present(self):
303 self.load_notifications_mock.return_value = [
304 {"id": "a"}
305 ]
306 result = json.loads(notification.notification({
307 "QUERY_STRING": "lastVersion=197001010000-a/0-b/1"
308 }, lambda *args: None))
309 self.assertEqual(len(result["notifications"]), 0)
310 self.assertRegexpMatches(result["version"], r"-a/0")
311
312 def test_leaves_group_when_notification_absent(self):
313 self.load_notifications_mock.return_value = []
314 result = json.loads(notification.notification({
315 "QUERY_STRING": "lastVersion=197001010000-a/0-b/1"
316 }, lambda *args: None))
317 self.assertEqual(len(result["notifications"]), 0)
318 self.assertRegexpMatches(result["version"], r"[^-]*")
319
320 def test_stays_in_group_when_notification_inactive(self):
321 self.load_notifications_mock.return_value = [
322 {"id": "a", "inactive": True}
323 ]
324 result = json.loads(notification.notification({
325 "QUERY_STRING": "lastVersion=197001010000-a/0-b/1"
326 }, lambda *args: None))
327 self.assertEqual(len(result["notifications"]), 0)
328 self.assertRegexpMatches(result["version"], r"-a/0")
329
330 def test_inactive_notifications_not_returned(self):
331 self.load_notifications_mock.return_value = [
332 {"id": "a", "title": {}, "message": {}, "inactive": True},
333 {"id": "b", "title": {}, "message": {}, "inactive": False},
334 {"id": "c", "title": {}, "message": {}}
335 ]
336 result = json.loads(notification.notification({}, lambda *args: None))
337 self.assertEqual(len(result["notifications"]), 2)
338 self.assertEqual(result["notifications"][0]["id"], "b")
339 self.assertEqual(result["notifications"][1]["id"], "c")
340
302 if __name__ == '__main__': 341 if __name__ == '__main__':
303 unittest.main() 342 unittest.main()
OLDNEW
« 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