diff --git a/django_client_reverse/test_urls.py b/django_client_reverse/test_urls.py index 50b5847..3d7fa1c 100644 --- a/django_client_reverse/test_urls.py +++ b/django_client_reverse/test_urls.py @@ -3,5 +3,6 @@ from django_client_reverse.views import Reverser 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-]+)/$', Reverser.as_view(), name="uuid"), + url(r'(?P[0-9a-f-]+)/(?P[0-9a-f-]+)$', Reverser.as_view(), name="multi") ] diff --git a/django_client_reverse/tests.py b/django_client_reverse/tests.py index 47bbb64..11ac3fa 100644 --- a/django_client_reverse/tests.py +++ b/django_client_reverse/tests.py @@ -30,3 +30,30 @@ class ReverserTestCase(APITestCase): 'args': args }, format="json") self.assertEqual(response.data, reverse('tests:uuid', args=args)) + + def test_invalid_kwargs(self): + kwargs = {'not_uuid': str(uuid4())} + response = self.client.post(reverse('reverser'), data={ + 'ident': 'tests:uuid', + 'kwargs': kwargs + }, format="json") + self.assertEqual(response.status_code, 404) + + def test_multi_kwargs(self): + kwargs = { + 'uuid': str(uuid4()), + 'pk': str(uuid4()) + } + response = self.client.post(reverse('reverser'), data={ + 'ident': 'tests:multi', + 'kwargs': kwargs + }, format="json") + self.assertEqual(response.data, reverse('tests:multi', kwargs=kwargs)) + + def test_multi_args(self): + args = (str(uuid4()), str(uuid4())) + response = self.client.post(reverse('reverser'), data={ + 'ident': 'tests:multi', + 'args': args + }, format="json") + self.assertEqual(response.data, reverse('tests:multi', args=args))