Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 self.assertEqual(notifications[1]['severity'], 'critical') | 153 self.assertEqual(notifications[1]['severity'], 'critical') |
154 self.assertEqual(notifications[2]['severity'], 'normal') | 154 self.assertEqual(notifications[2]['severity'], 'normal') |
155 self.assertEqual(notifications[3]['severity'], 'relentless') | 155 self.assertEqual(notifications[3]['severity'], 'relentless') |
156 | 156 |
157 def test_urls(self): | 157 def test_urls(self): |
158 self.notification_to_load = [ | 158 self.notification_to_load = [ |
159 ('1', '\nurls = adblockplus.org\n'), | 159 ('1', '\nurls = adblockplus.org\n'), |
160 ('1', '\nurls = adblockplus.org eyeo.com\n'), | 160 ('1', '\nurls = adblockplus.org eyeo.com\n'), |
161 ] | 161 ] |
162 notifications = parser.load_notifications() | 162 notifications = parser.load_notifications() |
163 self.assertEqual(len(notifications), 2) | 163 |
164 self.assertEqual( | 164 assert len(notifications) == 2 |
165 notifications[0]['urlFilters'], ['ADBLOCKPLUS.ORG^$document']) | 165 assert notifications[0]['urlFilters'] == ['ADBLOCKPLUS.ORG^$document'] |
166 self.assertEqual(notifications[1]['urlFilters'], [ | 166 assert notifications[1]['urlFilters'] == [ |
167 'ADBLOCKPLUS.ORG^$document', | 167 'ADBLOCKPLUS.ORG^$document', |
168 'EYEO.COM^$document']) | 168 'EYEO.COM^$document'] |
169 | 169 |
170 def test_target(self): | 170 def test_target(self): |
171 self.notification_to_load = [ | 171 self.notification_to_load = [ |
172 ('1', '\ntarget = extension=adblockplus\n'), | 172 ('1', '\ntarget = extension=adblockplus\n'), |
173 ('2', '\ntarget = extensionVersion=1.2.3\n'), | 173 ('2', '\ntarget = extensionVersion=1.2.3\n'), |
174 ('3', '\ntarget = extensionVersion>=1.2.3\n'), | 174 ('3', '\ntarget = extensionVersion>=1.2.3\n'), |
175 ('4', '\ntarget = extensionVersion<=1.2.3\n'), | 175 ('4', '\ntarget = extensionVersion<=1.2.3\n'), |
176 ('5', '\ntarget = application=chrome\n'), | 176 ('5', '\ntarget = application=chrome\n'), |
177 ('6', '\ntarget = applicationVersion=1.2.3\n'), | 177 ('6', '\ntarget = applicationVersion=1.2.3\n'), |
178 ('7', '\ntarget = applicationVersion>=1.2.3\n'), | 178 ('7', '\ntarget = applicationVersion>=1.2.3\n'), |
179 ('8', '\ntarget = applicationVersion<=1.2.3\n'), | 179 ('8', '\ntarget = applicationVersion<=1.2.3\n'), |
180 ('9', '\ntarget = platform=chromium\n'), | 180 ('9', '\ntarget = platform=chromium\n'), |
181 ('10', '\ntarget = platformVersion=1.2.3\n'), | 181 ('10', '\ntarget = platformVersion=1.2.3\n'), |
182 ('11', '\ntarget = platformVersion>=1.2.3\n'), | 182 ('11', '\ntarget = platformVersion>=1.2.3\n'), |
183 ('12', '\ntarget = platformVersion<=1.2.3\n'), | 183 ('12', '\ntarget = platformVersion<=1.2.3\n'), |
184 ('13', '\ntarget = blockedTotal=10\n'), | 184 ('13', '\ntarget = blockedTotal=10\n'), |
185 ('14', '\ntarget = blockedTotal>=10\n'), | 185 ('14', '\ntarget = blockedTotal>=10\n'), |
186 ('15', '\ntarget = blockedTotal<=10\n'), | 186 ('15', '\ntarget = blockedTotal<=10\n'), |
187 ('16', '\ntarget = locales=en-US\n'), | 187 ('16', '\ntarget = locales=en-US\n'), |
188 ('17', '\ntarget = locales=en-US,de-DE\n'), | 188 ('17', '\ntarget = locales=en-US,de-DE\n'), |
189 ] | 189 ] |
190 | 190 |
191 notifications = parser.load_notifications() | 191 notifications = parser.load_notifications() |
192 | 192 |
193 assert len(notifications) == 17 | 193 assert len(notifications) == 17 |
Wladimir Palant
2017/09/21 09:24:02
I'd recommend switching back to self.assertEqual()
Vasily Kuznetsov
2017/09/21 09:41:30
Here's the error message that I get (after changin
wspee
2017/09/21 10:15:11
I agree with Vasily, using assert only provides ad
| |
194 | 194 assert notifications[0]['targets'] == [{'extension': 'adblockplus'}] |
195 self.assertEqual( | 195 assert notifications[1]['targets'] == [{ |
196 notifications[0]['targets'][0]['extension'], 'adblockplus') | 196 'extensionMinVersion': '1.2.3', |
Wladimir Palant
2017/09/21 09:24:02
You should verify that there are no additional tar
wspee
2017/09/21 10:15:11
Done.
| |
197 self.assertEqual( | 197 'extensionMaxVersion': '1.2.3'}] |
198 notifications[1]['targets'][0]['extensionMinVersion'], '1.2.3') | 198 assert notifications[2]['targets'] == [ |
199 self.assertEqual( | 199 {'extensionMinVersion': '1.2.3'}] |
200 notifications[1]['targets'][0]['extensionMaxVersion'], '1.2.3') | 200 assert notifications[3]['targets'] == [{ |
201 self.assertEqual( | 201 'extensionMaxVersion': '1.2.3'}] |
202 notifications[2]['targets'][0]['extensionMinVersion'], '1.2.3') | 202 assert notifications[4]['targets'] == [{'application': 'chrome'}] |
203 self.assertEqual( | 203 assert notifications[5]['targets'] == [{ |
204 notifications[3]['targets'][0]['extensionMaxVersion'], '1.2.3') | 204 'applicationMinVersion': '1.2.3', |
205 self.assertEqual( | 205 'applicationMaxVersion': '1.2.3'}] |
206 notifications[4]['targets'][0]['application'], 'chrome') | 206 assert notifications[6]['targets'] == [{ |
207 self.assertEqual( | 207 'applicationMinVersion': '1.2.3'}] |
208 notifications[5]['targets'][0]['applicationMinVersion'], '1.2.3') | 208 assert notifications[7]['targets'] == [{ |
209 self.assertEqual( | 209 'applicationMaxVersion': '1.2.3'}] |
210 notifications[5]['targets'][0]['applicationMaxVersion'], '1.2.3') | 210 assert notifications[8]['targets'] == [{'platform': 'chromium'}] |
211 self.assertEqual( | 211 assert notifications[9]['targets'] == [{ |
212 notifications[6]['targets'][0]['applicationMinVersion'], '1.2.3') | 212 'platformMinVersion': '1.2.3', |
213 self.assertEqual( | 213 'platformMaxVersion': '1.2.3'}] |
214 notifications[7]['targets'][0]['applicationMaxVersion'], '1.2.3') | 214 assert notifications[10]['targets'] == [{ |
215 self.assertEqual( | 215 'platformMinVersion': '1.2.3'}] |
216 notifications[8]['targets'][0]['platform'], 'chromium') | 216 assert notifications[11]['targets'] == [{ |
217 self.assertEqual( | 217 'platformMaxVersion': '1.2.3'}] |
218 notifications[9]['targets'][0]['platformMinVersion'], '1.2.3') | 218 assert notifications[12]['targets'] == [{ |
219 self.assertEqual( | 219 'blockedTotalMin': 10, |
220 notifications[9]['targets'][0]['platformMaxVersion'], '1.2.3') | 220 'blockedTotalMax': 10}] |
221 self.assertEqual( | 221 assert notifications[13]['targets'] == [{'blockedTotalMin': 10}] |
222 notifications[10]['targets'][0]['platformMinVersion'], '1.2.3') | 222 assert notifications[14]['targets'] == [{'blockedTotalMax': 10}] |
223 self.assertEqual( | 223 assert notifications[15]['targets'] == [{'locales': ['en-US']}] |
224 notifications[11]['targets'][0]['platformMaxVersion'], '1.2.3') | 224 assert notifications[16]['targets'] == [{ |
225 self.assertEqual( | 225 'locales': ['en-US', 'de-DE']}] |
226 notifications[12]['targets'][0]['blockedTotalMin'], 10) | |
227 self.assertEqual( | |
228 notifications[12]['targets'][0]['blockedTotalMax'], 10) | |
229 self.assertEqual( | |
230 notifications[13]['targets'][0]['blockedTotalMin'], 10) | |
231 self.assertEqual( | |
232 notifications[14]['targets'][0]['blockedTotalMax'], 10) | |
233 self.assertEqual( | |
234 notifications[15]['targets'][0]['locales'], ['en-US']) | |
235 self.assertEqual( | |
236 notifications[16]['targets'][0]['locales'], ['en-US', 'de-DE']) | |
237 | 226 |
238 | 227 |
239 if __name__ == '__main__': | 228 if __name__ == '__main__': |
240 unittest.main() | 229 unittest.main() |
LEFT | RIGHT |