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

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

Issue 29756624: Noissue - Adapt best practices for trailing commas (sitescripts) (Closed)
Patch Set: Re-run script on Python 2, added flake8-commas extension Created April 19, 2018, 2:35 p.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/management/bin/installChanges.py ('k') | sitescripts/notifications/web/notification.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
@@ -30,7 +30,7 @@
def test_no_group(self):
self.load_notifications_mock.return_value = [
- {'id': '1', 'title': {'en-US': ''}, 'message': {'en-US': ''}}
+ {'id': '1', 'title': {'en-US': ''}, 'message': {'en-US': ''}},
]
result = json.loads(notification.notification({}, lambda *args: None))
self.assertEqual(len(result['notifications']), 1)
@@ -41,11 +41,11 @@
self.load_notifications_mock.return_value = [
{'id': '1', 'title': {'en-US': ''}, 'message': {'en-US': ''}},
{'id': 'a', 'variants': [
- {'title': {'en-US': ''}, 'message': {'en-US': ''}}
- ]}
+ {'title': {'en-US': ''}, 'message': {'en-US': ''}},
+ ]},
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000-a/0'
+ 'QUERY_STRING': 'lastVersion=197001010000-a/0',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 1)
self.assertEqual(result['notifications'][0]['id'], '1')
@@ -55,11 +55,11 @@
self.load_notifications_mock.return_value = [
{'id': '1', 'title': {'en-US': ''}, 'message': {'en-US': ''}},
{'id': 'a', 'variants': [
- {'title': {'en-US': ''}, 'message': {'en-US': ''}}
- ]}
+ {'title': {'en-US': ''}, 'message': {'en-US': ''}},
+ ]},
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000-a/1'
+ 'QUERY_STRING': 'lastVersion=197001010000-a/1',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 1)
self.assertEqual(result['notifications'][0]['id'], 'a')
@@ -69,17 +69,17 @@
self.load_notifications_mock.return_value = [
{'id': '1', 'title': {'en-US': ''}, 'message': {'en-US': ''}},
{'id': 'a', 'variants': [
- {'title': {'en-US': ''}, 'message': {'en-US': ''}}
+ {'title': {'en-US': ''}, 'message': {'en-US': ''}},
]},
{'id': 'b', 'variants': [
- {'title': {'en-US': ''}, 'message': {'en-US': ''}}
+ {'title': {'en-US': ''}, 'message': {'en-US': ''}},
]},
{'id': 'c', 'variants': [
- {'title': {'en-US': ''}, 'message': {'en-US': ''}}
- ]}
+ {'title': {'en-US': ''}, 'message': {'en-US': ''}},
+ ]},
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000-a/0-b/0-c/0'
+ 'QUERY_STRING': 'lastVersion=197001010000-a/0-b/0-c/0',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 1)
self.assertEqual(result['notifications'][0]['id'], '1')
@@ -89,17 +89,17 @@
self.load_notifications_mock.return_value = [
{'id': '1', 'title': {'en-US': ''}, 'message': {'en-US': ''}},
{'id': 'a', 'variants': [
- {'title': {'en-US': ''}, 'message': {'en-US': ''}}
+ {'title': {'en-US': ''}, 'message': {'en-US': ''}},
]},
{'id': 'b', 'variants': [
- {'title': {'en-US': ''}, 'message': {'en-US': ''}}
+ {'title': {'en-US': ''}, 'message': {'en-US': ''}},
]},
{'id': 'c', 'variants': [
- {'title': {'en-US': ''}, 'message': {'en-US': ''}}
- ]}
+ {'title': {'en-US': ''}, 'message': {'en-US': ''}},
+ ]},
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000-a/0-b/1-c/0'
+ 'QUERY_STRING': 'lastVersion=197001010000-a/0-b/1-c/0',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 1)
self.assertEqual(result['notifications'][0]['id'], 'b')
@@ -109,11 +109,11 @@
self.load_notifications_mock.return_value = [
{'id': '1', 'title': {'en-US': ''}, 'message': {'en-US': ''}},
{'id': 'a', 'variants': [
- {'sample': 0, 'title': {'en-US': ''}, 'message': {'en-US': ''}}
- ]}
+ {'sample': 0, 'title': {'en-US': ''}, 'message': {'en-US': ''}},
+ ]},
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000'
+ 'QUERY_STRING': 'lastVersion=197001010000',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 1)
self.assertEqual(result['notifications'][0]['id'], '1')
@@ -123,11 +123,11 @@
self.load_notifications_mock.return_value = [
{'id': '1', 'title': {'en-US': ''}, 'message': {'en-US': ''}},
{'id': 'a', 'variants': [
- {'sample': 1, 'title': {'en-US': ''}, 'message': {'en-US': ''}}
- ]}
+ {'sample': 1, 'title': {'en-US': ''}, 'message': {'en-US': ''}},
+ ]},
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000'
+ 'QUERY_STRING': 'lastVersion=197001010000',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 1)
self.assertEqual(result['notifications'][0]['id'], 'a')
@@ -140,9 +140,9 @@
'title': {'en-US': 'default'},
'message': {'en-US': 'default'},
'variants': [
- {'sample': 1, 'message': {'en-US': 'variant'}}
- ]
- }
+ {'sample': 1, 'message': {'en-US': 'variant'}},
+ ],
+ },
]
result = json.loads(notification.notification({}, lambda *args: None))
self.assertEqual(len(result['notifications']), 1)
@@ -154,7 +154,7 @@
def test_no_variant_no_notifications(self):
self.load_notifications_mock.return_value = [
- {'id': 'a', 'variants': [{'sample': 0}]}
+ {'id': 'a', 'variants': [{'sample': 0}]},
]
result = json.loads(notification.notification({}, lambda *args: None))
self.assertEqual(len(result['notifications']), 0)
@@ -167,9 +167,9 @@
'variants': [
{'sample': 0.5, 'title': {'en-US': '1'}, 'message': {'en-US': ''}},
{'sample': 0.25, 'title': {'en-US': '2'}, 'message': {'en-US': ''}},
- {'sample': 0.25, 'title': {'en-US': '3'}, 'message': {'en-US': ''}}
- ]
- }
+ {'sample': 0.25, 'title': {'en-US': '3'}, 'message': {'en-US': ''}},
+ ],
+ },
]
random_call.return_value = 0
result = json.loads(notification.notification({}, lambda *args: None))
@@ -209,16 +209,16 @@
'id': 'a',
'variants': [
{'sample': 0.25, 'title': {'en-US': '1'}, 'message': {'en-US': ''}},
- {'sample': 0.25, 'title': {'en-US': '2'}, 'message': {'en-US': ''}}
- ]
+ {'sample': 0.25, 'title': {'en-US': '2'}, 'message': {'en-US': ''}},
+ ],
},
{
'id': 'b',
'variants': [
{'sample': 0.25, 'title': {'en-US': '1'}, 'message': {'en-US': ''}},
- {'sample': 0.25, 'title': {'en-US': '2'}, 'message': {'en-US': ''}}
- ]
- }
+ {'sample': 0.25, 'title': {'en-US': '2'}, 'message': {'en-US': ''}},
+ ],
+ },
]
random_call.return_value = 0
result = json.loads(notification.notification({}, lambda *args: None))
@@ -258,7 +258,7 @@
def test_version_header_present(self):
self.load_notifications_mock.return_value = [
- {'id': '1', 'title': {'en-US': ''}, 'message': {'en-US': ''}}
+ {'id': '1', 'title': {'en-US': ''}, 'message': {'en-US': ''}},
]
response_header_map = {}
@@ -277,12 +277,12 @@
'title': {'en-US': '0'},
'message': {'en-US': '0'},
'variants': [
- {'title': {'en-US': '1'}, 'message': {'en-US': '1'}}
- ]
- }
+ {'title': {'en-US': '1'}, 'message': {'en-US': '1'}},
+ ],
+ },
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000-a/0'
+ 'QUERY_STRING': 'lastVersion=197001010000-a/0',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 2)
self.assertEqual(result['notifications'][0]['id'], '1')
@@ -298,12 +298,12 @@
'id': 'a',
'title': {'en-US': '0'},
'variants': [
- {'title': {'en-US': '1'}, 'message': {'en-US': '1'}}
- ]
- }
+ {'title': {'en-US': '1'}, 'message': {'en-US': '1'}},
+ ],
+ },
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000-a/0'
+ 'QUERY_STRING': 'lastVersion=197001010000-a/0',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 1)
self.assertEqual(result['notifications'][0]['id'], '1')
@@ -316,7 +316,7 @@
{'id': '3', 'title': {}, 'message': {'en-US': ''}},
{'id': '4', 'title': {}},
{'id': '5', 'message': {}},
- {'id': '6'}
+ {'id': '6'},
]
result = json.loads(notification.notification({}, lambda *args: None))
self.assertEqual(len(result['notifications']), 1)
@@ -324,10 +324,10 @@
def test_stays_in_group_when_notification_present(self):
self.load_notifications_mock.return_value = [
- {'id': 'a'}
+ {'id': 'a'},
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000-a/0-b/1'
+ 'QUERY_STRING': 'lastVersion=197001010000-a/0-b/1',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 0)
self.assertRegexpMatches(result['version'], r'-a/0')
@@ -335,17 +335,17 @@
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'
+ '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}
+ {'id': 'a', 'inactive': True},
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000-a/0-b/1'
+ 'QUERY_STRING': 'lastVersion=197001010000-a/0-b/1',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 0)
self.assertRegexpMatches(result['version'], r'-a/0')
@@ -359,7 +359,7 @@
]},
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000-1/0'
+ 'QUERY_STRING': 'lastVersion=197001010000-1/0',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 1)
self.assertRegexpMatches(result['version'], r'-1/0-2/1')
@@ -368,7 +368,7 @@
self.load_notifications_mock.return_value = [
{'id': 'a', 'title': {'en-US': ''}, 'message': {'en-US': ''}, 'inactive': True},
{'id': 'b', 'title': {'en-US': ''}, 'message': {'en-US': ''}, 'inactive': False},
- {'id': 'c', 'title': {'en-US': ''}, 'message': {'en-US': ''}}
+ {'id': 'c', 'title': {'en-US': ''}, 'message': {'en-US': ''}},
]
result = json.loads(notification.notification({}, lambda *args: None))
self.assertEqual(len(result['notifications']), 2)
@@ -377,10 +377,10 @@
def test_inactive_notification_variant_not_returned(self):
self.load_notifications_mock.return_value = [
- {'id': 'a', 'inactive': True}
+ {'id': 'a', 'inactive': True},
]
result = json.loads(notification.notification({
- 'QUERY_STRING': 'lastVersion=197001010000-a/1'
+ 'QUERY_STRING': 'lastVersion=197001010000-a/1',
}, lambda *args: None))
self.assertEqual(len(result['notifications']), 0)
« no previous file with comments | « sitescripts/management/bin/installChanges.py ('k') | sitescripts/notifications/web/notification.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld