Ticket #20099: 0001-Tests-for-user-agent-input-to-is_ignorable_404.patch

File 0001-Tests-for-user-agent-input-to-is_ignorable_404.patch, 1.3 KB (added by Ram Rachum, 12 years ago)

Tests

  • tests/middleware/tests.py

    From 7da91fe2fc52d098055085bf21533dc592fd6bcd Mon Sep 17 00:00:00 2001
    From: Ram Rachum <ram@rachum.com>
    Date: Fri, 22 Mar 2013 01:08:41 +0200
    Subject: [PATCH] Tests for user agent input to `is_ignorable_404`
    
    ---
     tests/middleware/tests.py |    9 +++++++++
     1 files changed, 9 insertions(+), 0 deletions(-)
    
    diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py
    index f2f7f4d..32e7b98 100644
    a b from io import BytesIO  
    66import random
    77import re
    88import warnings
     9import inspect
    910
    1011from django.conf import settings
    1112from django.core import mail
    class BrokenLinkEmailsMiddlewareTest(TestCase):  
    320321        BrokenLinkEmailsMiddleware().process_response(self.req, self.resp)
    321322        self.assertEqual(len(mail.outbox), 0)
    322323
     324    def test_is_ignorable_404_takes_user_agent(self):
     325        assert 'user_agent' in \
     326           inspect.getargspec(BrokenLinkEmailsMiddleware.is_ignorable_404).args
     327        broken_link_emails_middleware = BrokenLinkEmailsMiddleware()
     328        broken_link_emails_middleware.is_ignorable_404(
     329            'irrelevant_url', user_agent='Some user agent'
     330        )
     331
    323332
    324333class ConditionalGetMiddlewareTest(TestCase):
    325334    urls = 'middleware.cond_get_urls'
Back to Top