Ticket #22721: fallback_encoding_msie.diff

File fallback_encoding_msie.diff, 2.2 KB (added by Henrik Ossipoff Hansen, 10 years ago)

Patch for test case show-casing the MSIE behaviour under certain conditions

  • new file tests/fallback_encoding_msie/tests.py

    diff --git a/tests/fallback_encoding_msie/__init__.py b/tests/fallback_encoding_msie/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/fallback_encoding_msie/models.py b/tests/fallback_encoding_msie/models.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/fallback_encoding_msie/tests.py b/tests/fallback_encoding_msie/tests.py
    new file mode 100644
    index 0000000..892da05
    - +  
     1# -*- coding: utf-8 -*-
     2from __future__ import unicode_literals
     3try:
     4    from urllib import unquote
     5except ImportError:
     6    from urllib.parse import unquote
     7
     8from django.test.client import Client
     9from django.test import TestCase
     10
     11
     12class IEClient(Client):
     13    def request(self, **kwargs):
     14        try:
     15            kwargs['QUERY_STRING'] = unquote(kwargs['QUERY_STRING'])
     16        except:
     17            pass
     18        return super(IEClient, self).request(**kwargs)
     19
     20
     21class IETestCase(TestCase):
     22    client_class = IEClient
     23
     24
     25class TestFallbackEncodingMSIE(IETestCase):
     26    '''Describes issue related to MSIE and GET parameters, issue #22721'''
     27
     28    urls = 'tests.fallback_encoding_msie.urls'
     29
     30    def test_query_string_msie(self):
     31        qs = {'q': 'æøåÆØÅ'}
     32        response = self.client.get('/fallback-encoding-msie/', qs)
     33        self.assertEqual(200, response.status_code)
  • new file tests/fallback_encoding_msie/urls.py

    diff --git a/tests/fallback_encoding_msie/urls.py b/tests/fallback_encoding_msie/urls.py
    new file mode 100644
    index 0000000..5e8b1ac
    - +  
     1# -*- coding: utf-8 -*-
     2from __future__ import unicode_literals
     3
     4from django.conf.urls import patterns
     5
     6from .views import simple_view
     7
     8urlpatterns = patterns('',
     9    (r'^fallback-encoding-msie/$', simple_view),
     10)
  • new file tests/fallback_encoding_msie/views.py

    diff --git a/tests/fallback_encoding_msie/views.py b/tests/fallback_encoding_msie/views.py
    new file mode 100644
    index 0000000..7484aac
    - +  
     1# -*- coding: utf-8 -*-
     2from __future__ import unicode_literals
     3
     4from django.http import HttpResponse
     5
     6
     7def simple_view(request):
     8    return HttpResponse(request.GET['q'])
Back to Top