diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py
index f2f7f4d..49c94cf 100644
a
|
b
|
class BrokenLinkEmailsMiddlewareTest(TestCase):
|
320 | 320 | BrokenLinkEmailsMiddleware().process_response(self.req, self.resp) |
321 | 321 | self.assertEqual(len(mail.outbox), 0) |
322 | 322 | |
| 323 | def test_custom_is_ignorable_404(self): |
| 324 | class SubclassedMiddleware(BrokenLinkEmailsMiddleware): |
| 325 | """Ignoring based on UA only""" |
| 326 | ua_patterns = (re.compile(r'Spider.*'), re.compile(r'Robot.*')) |
| 327 | def is_ignorable_404(self, uri, user_agent): |
| 328 | return any(pattern.search(user_agent) for pattern in self.ua_patterns) |
| 329 | |
| 330 | self.req.META['HTTP_REFERER'] = '/another/url/' |
| 331 | self.req.META['HTTP_USER_AGENT'] = 'Spider machine 3.4' |
| 332 | SubclassedMiddleware().process_response(self.req, self.resp) |
| 333 | self.assertEqual(len(mail.outbox), 0) |
| 334 | self.req.META['HTTP_USER_AGENT'] = 'My user agent' |
| 335 | SubclassedMiddleware().process_response(self.req, self.resp) |
| 336 | self.assertEqual(len(mail.outbox), 1) |
| 337 | |
323 | 338 | |
324 | 339 | class ConditionalGetMiddlewareTest(TestCase): |
325 | 340 | urls = 'middleware.cond_get_urls' |