1
Fork 0

Added more tests

This commit is contained in:
Jake Howard 2015-12-10 18:10:11 +00:00
parent e111a7041c
commit 46ac2f6f59
2 changed files with 29 additions and 1 deletions

View file

@ -3,5 +3,6 @@ from django_client_reverse.views import Reverser
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-]+)/$', Reverser.as_view(), name="uuid"),
url(r'(?P<uuid>[0-9a-f-]+)/(?P<pk>[0-9a-f-]+)$', Reverser.as_view(), name="multi")
]

View file

@ -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))