Added test view
This commit is contained in:
parent
46ac2f6f59
commit
f42769d229
2 changed files with 19 additions and 4 deletions
|
@ -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<uuid>[0-9a-f-]+)/$', Reverser.as_view(), name="uuid"),
|
||||
url(r'(?P<uuid>[0-9a-f-]+)/(?P<pk>[0-9a-f-]+)$', Reverser.as_view(), name="multi")
|
||||
url(r'^$', test_view, name="root"),
|
||||
url(r'(?P<uuid>[0-9a-f-]+)/$', test_view, name="uuid"),
|
||||
url(r'(?P<uuid>[0-9a-f-]+)/(?P<pk>[0-9a-f-]+)$', test_view, name="multi")
|
||||
]
|
||||
|
|
|
@ -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)
|
||||
|
|
Reference in a new issue