Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.6:Update
python-djet
support-public-httpresponse.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File support-public-httpresponse.patch of Package python-djet
From f97c37afeb1b6f17055d2eebadaa42bc316cd15f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Ga=C5=82uszka?= <kamil.galuszka@solution4future.com> Date: Sat, 31 Jul 2021 07:26:59 +0200 Subject: [PATCH] fix: Django 2.2 made HttpResponse headers public field --- djet/assertions.py | 2 +- djet/restframework.py | 13 +++------ djet/testcases.py | 15 ++++------ testproject/testapp/tests/test_testcases.py | 32 +++++++++------------ 4 files changed, 24 insertions(+), 38 deletions(-) Index: djet-0.3.0/djet/assertions.py =================================================================== --- djet-0.3.0.orig/djet/assertions.py +++ djet-0.3.0/djet/assertions.py @@ -57,7 +57,7 @@ class StatusCodeAssertionsMixin(object): self._get_redirect_assertion_message(response), ) if expected_url: - location_header = response._headers.get('location', None) + location_header = response._headers.get('Location', None) self.assertEqual( location_header, ('Location', str(expected_url)), Index: djet-0.3.0/djet/restframework.py =================================================================== --- djet-0.3.0.orig/djet/restframework.py +++ djet-0.3.0/djet/restframework.py @@ -1,4 +1,3 @@ -import django from rest_framework import test from djet import testcases @@ -28,10 +27,9 @@ class APIViewTestCase(testcases.ViewTest return super(APIViewTestCase, self)._get_view(request) -if django.VERSION >= (1, 4): - class APIViewLiveServerTestCase(testcases.ViewLiveServerTestCase): - factory_class = APIRequestFactory - -if django.VERSION >= (1, 5): - class APIViewSimpleTestCase(testcases.ViewSimpleTestCase): - factory_class = APIRequestFactory +class APIViewLiveServerTestCase(testcases.ViewLiveServerTestCase): + factory_class = APIRequestFactory + + +class APIViewSimpleTestCase(testcases.ViewSimpleTestCase): + factory_class = APIRequestFactory Index: djet-0.3.0/djet/testcases.py =================================================================== --- djet-0.3.0.orig/djet/testcases.py +++ djet-0.3.0/djet/testcases.py @@ -1,5 +1,4 @@ from functools import partial -import django from django import test as django_test @@ -93,7 +92,7 @@ class ViewTestCaseMixin(object): middleware_classes = self.middleware_classes or [] for mw_class in middleware_classes: mw_class, mw_types = self._unpack_middleware(mw_class) - mw_instance = mw_class() + mw_instance = mw_class(self._get_response) if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_REQUEST): self._request_middleware.append(mw_instance.process_request) @@ -184,10 +183,8 @@ class ViewTestCase(ViewTestCaseMixin, dj pass -if django.VERSION >= (1, 4): - class ViewLiveServerTestCase(ViewTestCaseMixin, django_test.LiveServerTestCase): - pass - -if django.VERSION >= (1, 5): - class ViewSimpleTestCase(ViewTestCaseMixin, django_test.SimpleTestCase): - pass +class ViewLiveServerTestCase(ViewTestCaseMixin, django_test.LiveServerTestCase): + pass + +class ViewSimpleTestCase(ViewTestCaseMixin, django_test.SimpleTestCase): + pass Index: djet-0.3.0/testproject/testapp/tests/test_testcases.py =================================================================== --- djet-0.3.0.orig/testproject/testapp/tests/test_testcases.py +++ djet-0.3.0/testproject/testapp/tests/test_testcases.py @@ -1,4 +1,3 @@ -import django from django import test as django_test from django.core.handlers.wsgi import WSGIRequest from django.http import HttpResponse @@ -9,6 +8,8 @@ from djet import testcases class MockMiddleware(object): + def __init__(self, get_response): + self.get_response = get_response def process_request(self, request): request.process_request_was_here = True @@ -38,6 +39,8 @@ class NewStyleMiddleware(object): class ProcessViewMockMiddleware(object): + def __init__(self, get_response): + self.get_response = get_response def process_view(self, request, view_func, view_args, view_kwargs): response = HttpResponse() @@ -144,13 +147,11 @@ class ViewTransactionTestCaseTest(ViewTe pass -if django.VERSION >= (1, 4): - class ViewLiveServerTestCaseTest(ViewTestCaseTestMixin, testcases.ViewLiveServerTestCase): - pass - -if django.VERSION >= (1, 5): - class ViewSimpleTestCaseTest(ViewTestCaseTestMixin, testcases.ViewSimpleTestCase): - pass +class ViewLiveServerTestCaseTest(ViewTestCaseTestMixin, testcases.ViewLiveServerTestCase): + pass + +class ViewSimpleTestCaseTest(ViewTestCaseTestMixin, testcases.ViewSimpleTestCase): + pass class ProcessExceptionMiddlewareViewTestCaseTest(testcases.ViewTestCase): @@ -235,14 +236,9 @@ class NewStyleMiddlewareTest(testcases.V def test_new_middleware(self): request = self.factory.get() - try: - response = self.view(request) - except NotImplementedError: - if django.VERSION >= (1, 10): - assert True + response = self.view(request) - if django.VERSION >= (1, 10): - self.assertTrue(response.new_middleware) + self.assertTrue(response.new_middleware) class NoViewClassDefined(testcases.ViewTestCase):
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor