django-hosts
django-hosts copied to clipboard
Tests that include MockViews fail.
I have some testcases in which i make use of a MockView to test my custom authentication classes.
class MockView(APIView):
permission_classes = (permissions.IsAuthenticated,)
def get(self, request):
return HttpResponse({'a': 1, 'b': 2, 'c': 3})
def post(self, request):
return HttpResponse({'a': 1, 'b': 2, 'c': 3})
def put(self, request):
return HttpResponse({'a': 1, 'b': 2, 'c': 3})
urlpatterns = [
url(
r'^organisationauth/$',
MockView.as_view(authentication_classes=[SymmetricOrganisationJWTAuth])
),
url(
r'^appauth/$',
MockView.as_view(authentication_classes=[SymmetricApplicationJWTAuth])
),
]
To use this mocks i had to use the override_settings
decorator:
@override_settings(ROOT_URLCONF='mysite.tests.test_auth')
class OrganiationSymmetricKeyTest(APITestCase):
...
After installing and configuring django-hosts that override doesn't seem to work anymore:
AssertionError: 404 != 403
All other tests pass. Any idea?
Of course i can override other settings like INSTALLED_APPS
and MIDDLEWARE
for these tests. But i am not quite sure whether this is a good approach.