From f42769d22932bdc3f0205886cddbe5a9ac02caa0 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 10 Dec 2015 18:21:17 +0000 Subject: [PATCH] Added test view --- django_client_reverse/test_urls.py | 16 ++++++++++++---- django_client_reverse/tests.py | 7 +++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/django_client_reverse/test_urls.py b/django_client_reverse/test_urls.py index 3d7fa1c..b1ccbb2 100644 --- a/django_client_reverse/test_urls.py +++ b/django_client_reverse/test_urls.py @@ -1,8 +1,16 @@ from django.conf.urls import url -from django_client_reverse.views import Reverser +from django.http import HttpResponse + + +PASS_TEXT = "PASS" + + +def test_view(request, *args, **kwargs): + return HttpResponse(PASS_TEXT) + urlpatterns = [ - url(r'^$', Reverser.as_view(), name="root"), - url(r'(?P[0-9a-f-]+)/$', Reverser.as_view(), name="uuid"), - url(r'(?P[0-9a-f-]+)/(?P[0-9a-f-]+)$', Reverser.as_view(), name="multi") + url(r'^$', test_view, name="root"), + url(r'(?P[0-9a-f-]+)/$', test_view, name="uuid"), + url(r'(?P[0-9a-f-]+)/(?P[0-9a-f-]+)$', test_view, name="multi") ] diff --git a/django_client_reverse/tests.py b/django_client_reverse/tests.py index 11ac3fa..b92a99b 100644 --- a/django_client_reverse/tests.py +++ b/django_client_reverse/tests.py @@ -1,6 +1,7 @@ from rest_framework.test import APITestCase from django.core.urlresolvers import reverse from uuid import uuid4 +from .test_urls import PASS_TEXT class ReverserTestCase(APITestCase): @@ -57,3 +58,9 @@ class ReverserTestCase(APITestCase): 'args': args }, format="json") self.assertEqual(response.data, reverse('tests:multi', args=args)) + + def test_url_valid(self): + lookup_response = self.client.post(reverse('reverser'), data={'ident': 'tests:root'}) + response = self.client.get(lookup_response.data) + self.assertEqual(response.status_code, 200) + self.assertContains(response, PASS_TEXT)