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

Side by Side Diff: sitescripts/notifications/test/notification.py

Issue 29325919: Issue 2982 - Return all notifications that have title and message (Closed)
Patch Set: Address comments Created Sept. 7, 2015, 7:51 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 | « no previous file | sitescripts/notifications/web/notification.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 12 matching lines...) Expand all
23 23
24 class TestNotification(unittest.TestCase): 24 class TestNotification(unittest.TestCase):
25 def setUp(self): 25 def setUp(self):
26 self.load_notifications_patcher = mock.patch("sitescripts.notifications.web. notification.load_notifications") 26 self.load_notifications_patcher = mock.patch("sitescripts.notifications.web. notification.load_notifications")
27 self.load_notifications_mock = self.load_notifications_patcher.start() 27 self.load_notifications_mock = self.load_notifications_patcher.start()
28 28
29 def tearDown(self): 29 def tearDown(self):
30 self.load_notifications_patcher.stop() 30 self.load_notifications_patcher.stop()
31 31
32 def test_no_group(self): 32 def test_no_group(self):
33 self.load_notifications_mock.return_value = [{"id": "1"}] 33 self.load_notifications_mock.return_value = [
34 {"id": "1", "title": {}, "message": {}}
35 ]
34 result = json.loads(notification.notification({}, lambda *args: None)) 36 result = json.loads(notification.notification({}, lambda *args: None))
35 self.assertEqual(len(result["notifications"]), 1) 37 self.assertEqual(len(result["notifications"]), 1)
36 self.assertEqual(result["notifications"][0]["id"], "1") 38 self.assertEqual(result["notifications"][0]["id"], "1")
37 self.assertFalse("-" in result["version"]) 39 self.assertFalse("-" in result["version"])
38 40
39 def test_not_in_group(self): 41 def test_not_in_group(self):
40 self.load_notifications_mock.return_value = [ 42 self.load_notifications_mock.return_value = [
41 {"id": "1"}, 43 {"id": "1", "title": {}, "message": {}},
42 { 44 {"id": "a", "variants": [{"title": {}, "message": {}}]}
43 "id": "a",
44 "variants": [{}]
45 }
46 ] 45 ]
47 result = json.loads(notification.notification({ 46 result = json.loads(notification.notification({
48 "QUERY_STRING": "lastVersion=197001010000-a/0" 47 "QUERY_STRING": "lastVersion=197001010000-a/0"
49 }, lambda *args: None)) 48 }, lambda *args: None))
50 self.assertEqual(len(result["notifications"]), 1) 49 self.assertEqual(len(result["notifications"]), 1)
51 self.assertEqual(result["notifications"][0]["id"], "1") 50 self.assertEqual(result["notifications"][0]["id"], "1")
52 self.assertRegexpMatches(result["version"], r"-a/0") 51 self.assertRegexpMatches(result["version"], r"-a/0")
53 52
54 def test_in_group(self): 53 def test_in_group(self):
55 self.load_notifications_mock.return_value = [ 54 self.load_notifications_mock.return_value = [
56 {"id": "1"}, 55 {"id": "1", "title": {}, "message": {}},
57 { 56 {"id": "a", "variants": [{"title": {}, "message": {}}]}
58 "id": "a",
59 "variants": [{}]
60 }
61 ] 57 ]
62 result = json.loads(notification.notification({ 58 result = json.loads(notification.notification({
63 "QUERY_STRING": "lastVersion=197001010000-a/1" 59 "QUERY_STRING": "lastVersion=197001010000-a/1"
64 }, lambda *args: None)) 60 }, lambda *args: None))
65 self.assertEqual(len(result["notifications"]), 1) 61 self.assertEqual(len(result["notifications"]), 1)
66 self.assertEqual(result["notifications"][0]["id"], "a") 62 self.assertEqual(result["notifications"][0]["id"], "a")
67 self.assertRegexpMatches(result["version"], r"-a/1") 63 self.assertRegexpMatches(result["version"], r"-a/1")
68 64
69 def test_not_in_one_of_many_groups(self): 65 def test_not_in_one_of_many_groups(self):
70 self.load_notifications_mock.return_value = [ 66 self.load_notifications_mock.return_value = [
71 {"id": "1"}, 67 {"id": "1", "title": {}, "message": {}},
72 { 68 {"id": "a", "variants": [{"title": {}, "message": {}}]},
73 "id": "a", 69 {"id": "b", "variants": [{"title": {}, "message": {}}]},
74 "variants": [{}] 70 {"id": "c", "variants": [{"title": {}, "message": {}}]}
75 },
76 {
77 "id": "b",
78 "variants": [{}]
79 },
80 {
81 "id": "c",
82 "variants": [{}]
83 }
84 ] 71 ]
85 result = json.loads(notification.notification({ 72 result = json.loads(notification.notification({
86 "QUERY_STRING": "lastVersion=197001010000-a/0-b/0-c/0" 73 "QUERY_STRING": "lastVersion=197001010000-a/0-b/0-c/0"
87 }, lambda *args: None)) 74 }, lambda *args: None))
88 self.assertEqual(len(result["notifications"]), 1) 75 self.assertEqual(len(result["notifications"]), 1)
89 self.assertEqual(result["notifications"][0]["id"], "1") 76 self.assertEqual(result["notifications"][0]["id"], "1")
90 self.assertRegexpMatches(result["version"], r"-a/0-b/0-c/0") 77 self.assertRegexpMatches(result["version"], r"-a/0-b/0-c/0")
91 78
92 def test_in_one_of_many_groups(self): 79 def test_in_one_of_many_groups(self):
93 self.load_notifications_mock.return_value = [ 80 self.load_notifications_mock.return_value = [
94 {"id": "1"}, 81 {"id": "1", "title": {}, "message": {}},
95 { 82 {"id": "a", "variants": [{"title": {}, "message": {}}]},
96 "id": "a", 83 {"id": "b", "variants": [{"title": {}, "message": {}}]},
97 "variants": [{}] 84 {"id": "c", "variants": [{"title": {}, "message": {}}]}
98 },
99 {
100 "id": "b",
101 "variants": [{}]
102 },
103 {
104 "id": "c",
105 "variants": [{}]
106 }
107 ] 85 ]
108 result = json.loads(notification.notification({ 86 result = json.loads(notification.notification({
109 "QUERY_STRING": "lastVersion=197001010000-a/0-b/1-c/0" 87 "QUERY_STRING": "lastVersion=197001010000-a/0-b/1-c/0"
110 }, lambda *args: None)) 88 }, lambda *args: None))
111 self.assertEqual(len(result["notifications"]), 1) 89 self.assertEqual(len(result["notifications"]), 1)
112 self.assertEqual(result["notifications"][0]["id"], "b") 90 self.assertEqual(result["notifications"][0]["id"], "b")
113 self.assertRegexpMatches(result["version"], r"-a/0-b/1-c/0") 91 self.assertRegexpMatches(result["version"], r"-a/0-b/1-c/0")
114 92
115 def test_not_put_in_group(self): 93 def test_not_put_in_group(self):
116 self.load_notifications_mock.return_value = [ 94 self.load_notifications_mock.return_value = [
117 {"id": "1"}, 95 {"id": "1", "title": {}, "message": {}},
118 { 96 {"id": "a", "variants": [{"sample": 0, "title": {}, "message": {}}]}
119 "id": "a",
120 "variants": [{"sample": 0}]
121 }
122 ] 97 ]
123 result = json.loads(notification.notification({ 98 result = json.loads(notification.notification({
124 "QUERY_STRING": "lastVersion=197001010000" 99 "QUERY_STRING": "lastVersion=197001010000"
125 }, lambda *args: None)) 100 }, lambda *args: None))
126 self.assertEqual(len(result["notifications"]), 1) 101 self.assertEqual(len(result["notifications"]), 1)
127 self.assertEqual(result["notifications"][0]["id"], "1") 102 self.assertEqual(result["notifications"][0]["id"], "1")
128 self.assertRegexpMatches(result["version"], r"-a/0") 103 self.assertRegexpMatches(result["version"], r"-a/0")
129 104
130 def test_put_in_group(self): 105 def test_put_in_group(self):
131 self.load_notifications_mock.return_value = [ 106 self.load_notifications_mock.return_value = [
132 {"id": "1"}, 107 {"id": "1", "title": {}, "message": {}},
133 { 108 {"id": "a", "variants": [{"sample": 1, "title": {}, "message": {}}]}
134 "id": "a",
135 "variants": [{"sample": 1}]
136 }
137 ] 109 ]
138 result = json.loads(notification.notification({ 110 result = json.loads(notification.notification({
139 "QUERY_STRING": "lastVersion=197001010000" 111 "QUERY_STRING": "lastVersion=197001010000"
140 }, lambda *args: None)) 112 }, lambda *args: None))
141 self.assertEqual(len(result["notifications"]), 1) 113 self.assertEqual(len(result["notifications"]), 1)
142 self.assertEqual(result["notifications"][0]["id"], "a") 114 self.assertEqual(result["notifications"][0]["id"], "a")
143 self.assertRegexpMatches(result["version"], r"-a/1") 115 self.assertRegexpMatches(result["version"], r"-a/1")
144 116
145 def test_notification_variant_merged(self): 117 def test_notification_variant_merged(self):
146 self.load_notifications_mock.return_value = [ 118 self.load_notifications_mock.return_value = [
147 { 119 {
148 "id": "a", 120 "id": "a",
149 "title.en-GB": "default", 121 "title": {"en-US": "default"},
150 "message.en-GB": "default", 122 "message": {"en-US": "default"},
151 "message.de-DE": "vorgabe",
152 "variants": [ 123 "variants": [
153 { 124 {"sample": 1, "message": {"en-US": "variant"}}
154 "sample": 1,
155 "message.en-GB": "variant"
156 }
157 ] 125 ]
158 } 126 }
159 ] 127 ]
160 result = json.loads(notification.notification({}, lambda *args: None)) 128 result = json.loads(notification.notification({}, lambda *args: None))
161 self.assertEqual(len(result["notifications"]), 1) 129 self.assertEqual(len(result["notifications"]), 1)
162 self.assertEqual(result["notifications"][0]["id"], "a") 130 self.assertEqual(result["notifications"][0]["id"], "a")
163 self.assertEqual(result["notifications"][0]["title.en-GB"], "default") 131 self.assertEqual(result["notifications"][0]["title"]["en-US"], "default")
164 self.assertEqual(result["notifications"][0]["message.en-GB"], "variant") 132 self.assertEqual(result["notifications"][0]["message"]["en-US"], "variant")
165 self.assertEqual(result["notifications"][0]["message.de-DE"], "vorgabe")
166 self.assertFalse("variants" in result["notifications"][0]) 133 self.assertFalse("variants" in result["notifications"][0])
167 self.assertFalse("sample" in result["notifications"][0]) 134 self.assertFalse("sample" in result["notifications"][0])
168 135
169 def test_no_variant_no_notifications(self): 136 def test_no_variant_no_notifications(self):
170 self.load_notifications_mock.return_value = [ 137 self.load_notifications_mock.return_value = [
171 { 138 {"id": "a", "variants": [{"sample": 0}]}
172 "id": "a",
173 "variants": [{"sample": 0}]
174 }
175 ] 139 ]
176 result = json.loads(notification.notification({}, lambda *args: None)) 140 result = json.loads(notification.notification({}, lambda *args: None))
177 self.assertEqual(len(result["notifications"]), 0) 141 self.assertEqual(len(result["notifications"]), 0)
178 142
179 @mock.patch("random.random") 143 @mock.patch("random.random")
180 def test_probability_distribution_single_group(self, random_call): 144 def test_probability_distribution_single_group(self, random_call):
181 self.load_notifications_mock.return_value = [ 145 self.load_notifications_mock.return_value = [
182 { 146 {
183 "id": "a", 147 "id": "a",
184 "variants": [ 148 "variants": [
185 { 149 {"sample": 0.5, "title": {"en-US": "1"}, "message": {}},
186 "sample": 0.5, 150 {"sample": 0.25, "title": {"en-US": "2"}, "message": {}},
187 "title.en-GB": "1" 151 {"sample": 0.25, "title": {"en-US": "3"}, "message": {}}
188 },
189 {
190 "sample": 0.25,
191 "title.en-GB": "2"
192 },
193 {
194 "sample": 0.25,
195 "title.en-GB": "3"
196 }
197 ] 152 ]
198 } 153 }
199 ] 154 ]
200 random_call.return_value = 0 155 random_call.return_value = 0
201 result = json.loads(notification.notification({}, lambda *args: None)) 156 result = json.loads(notification.notification({}, lambda *args: None))
202 self.assertEqual(len(result["notifications"]), 1) 157 self.assertEqual(len(result["notifications"]), 1)
203 self.assertEqual(result["notifications"][0]["title.en-GB"], "1") 158 self.assertEqual(result["notifications"][0]["title"]["en-US"], "1")
204 self.assertRegexpMatches(result["version"], r"-a/1") 159 self.assertRegexpMatches(result["version"], r"-a/1")
205 random_call.return_value = 0.5 160 random_call.return_value = 0.5
206 result = json.loads(notification.notification({}, lambda *args: None)) 161 result = json.loads(notification.notification({}, lambda *args: None))
207 self.assertEqual(len(result["notifications"]), 1) 162 self.assertEqual(len(result["notifications"]), 1)
208 self.assertEqual(result["notifications"][0]["title.en-GB"], "1") 163 self.assertEqual(result["notifications"][0]["title"]["en-US"], "1")
209 self.assertRegexpMatches(result["version"], r"-a/1") 164 self.assertRegexpMatches(result["version"], r"-a/1")
210 random_call.return_value = 0.51 165 random_call.return_value = 0.51
211 result = json.loads(notification.notification({}, lambda *args: None)) 166 result = json.loads(notification.notification({}, lambda *args: None))
212 self.assertEqual(len(result["notifications"]), 1) 167 self.assertEqual(len(result["notifications"]), 1)
213 self.assertEqual(result["notifications"][0]["title.en-GB"], "2") 168 self.assertEqual(result["notifications"][0]["title"]["en-US"], "2")
214 self.assertRegexpMatches(result["version"], r"-a/2") 169 self.assertRegexpMatches(result["version"], r"-a/2")
215 random_call.return_value = 0.75 170 random_call.return_value = 0.75
216 result = json.loads(notification.notification({}, lambda *args: None)) 171 result = json.loads(notification.notification({}, lambda *args: None))
217 self.assertEqual(len(result["notifications"]), 1) 172 self.assertEqual(len(result["notifications"]), 1)
218 self.assertEqual(result["notifications"][0]["title.en-GB"], "2") 173 self.assertEqual(result["notifications"][0]["title"]["en-US"], "2")
219 self.assertRegexpMatches(result["version"], r"-a/2") 174 self.assertRegexpMatches(result["version"], r"-a/2")
220 random_call.return_value = 0.751 175 random_call.return_value = 0.751
221 result = json.loads(notification.notification({}, lambda *args: None)) 176 result = json.loads(notification.notification({}, lambda *args: None))
222 self.assertEqual(len(result["notifications"]), 1) 177 self.assertEqual(len(result["notifications"]), 1)
223 self.assertEqual(result["notifications"][0]["title.en-GB"], "3") 178 self.assertEqual(result["notifications"][0]["title"]["en-US"], "3")
224 self.assertRegexpMatches(result["version"], r"-a/3") 179 self.assertRegexpMatches(result["version"], r"-a/3")
225 random_call.return_value = 1 180 random_call.return_value = 1
226 result = json.loads(notification.notification({}, lambda *args: None)) 181 result = json.loads(notification.notification({}, lambda *args: None))
227 self.assertEqual(len(result["notifications"]), 1) 182 self.assertEqual(len(result["notifications"]), 1)
228 self.assertEqual(result["notifications"][0]["title.en-GB"], "3") 183 self.assertEqual(result["notifications"][0]["title"]["en-US"], "3")
229 self.assertRegexpMatches(result["version"], r"-a/3") 184 self.assertRegexpMatches(result["version"], r"-a/3")
230 185
231 @mock.patch("random.random") 186 @mock.patch("random.random")
232 def test_probability_distribution_multiple_groups(self, random_call): 187 def test_probability_distribution_multiple_groups(self, random_call):
233 self.load_notifications_mock.return_value = [ 188 self.load_notifications_mock.return_value = [
234 { 189 {
235 "id": "a", 190 "id": "a",
236 "variants": [ 191 "variants": [
237 { 192 {"sample": 0.25, "title": {"en-US": "1"}, "message": {}},
238 "sample": 0.25, 193 {"sample": 0.25, "title": {"en-US": "2"}, "message": {}}
239 "title.en-GB": "1"
240 },
241 {
242 "sample": 0.25,
243 "title.en-GB": "2"
244 }
245 ] 194 ]
246 }, 195 },
247 { 196 {
248 "id": "b", 197 "id": "b",
249 "variants": [ 198 "variants": [
250 { 199 {"sample": 0.25, "title": {"en-US": "1"}, "message": {}},
251 "sample": 0.25, 200 {"sample": 0.25, "title": {"en-US": "2"}, "message": {}}
252 "title.en-GB": "1"
253 },
254 {
255 "sample": 0.25,
256 "title.en-GB": "2"
257 }
258 ] 201 ]
259 } 202 }
260 ] 203 ]
261 random_call.return_value = 0 204 random_call.return_value = 0
262 result = json.loads(notification.notification({}, lambda *args: None)) 205 result = json.loads(notification.notification({}, lambda *args: None))
263 self.assertEqual(len(result["notifications"]), 1) 206 self.assertEqual(len(result["notifications"]), 1)
264 self.assertEqual(result["notifications"][0]["id"], "a") 207 self.assertEqual(result["notifications"][0]["id"], "a")
265 self.assertEqual(result["notifications"][0]["title.en-GB"], "1") 208 self.assertEqual(result["notifications"][0]["title"]["en-US"], "1")
266 self.assertRegexpMatches(result["version"], r"-a/1-b/0") 209 self.assertRegexpMatches(result["version"], r"-a/1-b/0")
267 random_call.return_value = 0.251 210 random_call.return_value = 0.251
268 result = json.loads(notification.notification({}, lambda *args: None)) 211 result = json.loads(notification.notification({}, lambda *args: None))
269 self.assertEqual(len(result["notifications"]), 1) 212 self.assertEqual(len(result["notifications"]), 1)
270 self.assertEqual(result["notifications"][0]["id"], "a") 213 self.assertEqual(result["notifications"][0]["id"], "a")
271 self.assertEqual(result["notifications"][0]["title.en-GB"], "2") 214 self.assertEqual(result["notifications"][0]["title"]["en-US"], "2")
272 self.assertRegexpMatches(result["version"], r"-a/2-b/0") 215 self.assertRegexpMatches(result["version"], r"-a/2-b/0")
273 random_call.return_value = 0.51 216 random_call.return_value = 0.51
274 result = json.loads(notification.notification({}, lambda *args: None)) 217 result = json.loads(notification.notification({}, lambda *args: None))
275 self.assertEqual(len(result["notifications"]), 1) 218 self.assertEqual(len(result["notifications"]), 1)
276 self.assertEqual(result["notifications"][0]["id"], "b") 219 self.assertEqual(result["notifications"][0]["id"], "b")
277 self.assertEqual(result["notifications"][0]["title.en-GB"], "1") 220 self.assertEqual(result["notifications"][0]["title"]["en-US"], "1")
278 self.assertRegexpMatches(result["version"], r"-a/0-b/1") 221 self.assertRegexpMatches(result["version"], r"-a/0-b/1")
279 random_call.return_value = 0.751 222 random_call.return_value = 0.751
280 result = json.loads(notification.notification({}, lambda *args: None)) 223 result = json.loads(notification.notification({}, lambda *args: None))
281 self.assertEqual(len(result["notifications"]), 1) 224 self.assertEqual(len(result["notifications"]), 1)
282 self.assertEqual(result["notifications"][0]["id"], "b") 225 self.assertEqual(result["notifications"][0]["id"], "b")
283 self.assertEqual(result["notifications"][0]["title.en-GB"], "2") 226 self.assertEqual(result["notifications"][0]["title"]["en-US"], "2")
284 self.assertRegexpMatches(result["version"], r"-a/0-b/2") 227 self.assertRegexpMatches(result["version"], r"-a/0-b/2")
285 228
286 def test_invalid_last_version(self): 229 def test_invalid_last_version(self):
287 self.load_notifications_mock.return_value = [] 230 self.load_notifications_mock.return_value = []
288 notification.notification({"QUERY_STRING": "lastVersion="}, 231 notification.notification({"QUERY_STRING": "lastVersion="},
289 lambda *args: None) 232 lambda *args: None)
290 notification.notification({"QUERY_STRING": "lastVersion=-"}, 233 notification.notification({"QUERY_STRING": "lastVersion=-"},
291 lambda *args: None) 234 lambda *args: None)
292 notification.notification({"QUERY_STRING": "lastVersion=-/"}, 235 notification.notification({"QUERY_STRING": "lastVersion=-/"},
293 lambda *args: None) 236 lambda *args: None)
294 notification.notification({"QUERY_STRING": "lastVersion=-//"}, 237 notification.notification({"QUERY_STRING": "lastVersion=-//"},
295 lambda *args: None) 238 lambda *args: None)
296 239
297 def test_version_header_present(self): 240 def test_version_header_present(self):
298 self.load_notifications_mock.return_value = [{"id": "1"}] 241 self.load_notifications_mock.return_value = [
242 {"id": "1", "title": {}, "message": {}}
243 ]
299 response_header_map = {} 244 response_header_map = {}
300 def start_response(status, response_headers): 245 def start_response(status, response_headers):
301 for name, value in response_headers: 246 for name, value in response_headers:
302 response_header_map[name] = value 247 response_header_map[name] = value
303 result = json.loads(notification.notification({}, start_response)) 248 result = json.loads(notification.notification({}, start_response))
304 self.assertEqual(result["version"], 249 self.assertEqual(result["version"],
305 response_header_map["ABP-Notification-Version"]) 250 response_header_map["ABP-Notification-Version"])
306 251
252 def test_default_group_notification_returned_if_valid(self):
253 self.load_notifications_mock.return_value = [
254 {"id": "1", "title": {}, "message": {}},
255 {
256 "id": "a",
257 "title": {"en-US": "0"},
258 "message": {"en-US": "0"},
259 "variants": [
260 {"title": {"en-US": "1"}, "message": {"en-US": "1"}}
261 ]
262 }
263 ]
264 result = json.loads(notification.notification({
265 "QUERY_STRING": "lastVersion=197001010000-a/0"
266 }, lambda *args: None))
267 self.assertEqual(len(result["notifications"]), 2)
268 self.assertEqual(result["notifications"][0]["id"], "1")
269 self.assertEqual(result["notifications"][1]["id"], "a")
270 self.assertEqual(result["notifications"][1]["title"]["en-US"], "0")
271 self.assertNotIn("variants", result["notifications"][1])
272 self.assertRegexpMatches(result["version"], r"-a/0")
273
274 def test_default_group_notification_not_returned_if_invalid(self):
275 self.load_notifications_mock.return_value = [
276 {"id": "1", "title": {}, "message": {}},
277 {
278 "id": "a",
279 "title": {"en-US": "0"},
280 "variants": [
281 {"title": {"en-US": "1"}, "message": {"en-US": "1"}}
282 ]
283 }
284 ]
285 result = json.loads(notification.notification({
286 "QUERY_STRING": "lastVersion=197001010000-a/0"
287 }, lambda *args: None))
288 self.assertEqual(len(result["notifications"]), 1)
289 self.assertEqual(result["notifications"][0]["id"], "1")
290 self.assertRegexpMatches(result["version"], r"-a/0")
291
292 def test_invalid_notification_not_returned(self):
293 self.load_notifications_mock.return_value = [
294 {"id": "1", "title": {}, "message": {}},
295 {"id": "2", "title": {}},
296 {"id": "3", "message": {}}
297 ]
298 result = json.loads(notification.notification({}, lambda *args: None))
299 self.assertEqual(len(result["notifications"]), 1)
300 self.assertEqual(result["notifications"][0]["id"], "1")
301
307 if __name__ == '__main__': 302 if __name__ == '__main__':
308 unittest.main() 303 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | sitescripts/notifications/web/notification.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld