Added more tests
This commit is contained in:
parent
e111a7041c
commit
46ac2f6f59
2 changed files with 29 additions and 1 deletions
|
@ -3,5 +3,6 @@ from django_client_reverse.views import Reverser
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', Reverser.as_view(), name="root"),
|
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")
|
||||||
]
|
]
|
||||||
|
|
|
@ -30,3 +30,30 @@ class ReverserTestCase(APITestCase):
|
||||||
'args': args
|
'args': args
|
||||||
}, format="json")
|
}, format="json")
|
||||||
self.assertEqual(response.data, reverse('tests:uuid', args=args))
|
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))
|
||||||
|
|
Reference in a new issue