added failing test for nested namespaces versioning

This commit is contained in:
Krzysztof Nazarewski 2016-03-21 15:50:18 +01:00
parent 85e57afc20
commit 10fa40a0c3

View File

@ -271,8 +271,12 @@ class TestHyperlinkedRelatedField(UsingURLPatterns, APITestCase):
class TestNamespaceVersioningHyperlinkedRelatedFieldScheme(UsingURLPatterns, APITestCase):
nested = [
url(r'^namespaced/(?P<pk>\d+)/$', dummy_pk_view, name='nested'),
]
included = [
url(r'^namespaced/(?P<pk>\d+)/$', dummy_pk_view, name='namespaced'),
url(r'^nested/', include(nested, namespace='nested-namespace'))
]
urlpatterns = [
@ -296,6 +300,10 @@ class TestNamespaceVersioningHyperlinkedRelatedFieldScheme(UsingURLPatterns, API
field = self._create_field('namespaced', 'v1')
assert field.to_representation(PKOnlyObject(3)) == 'http://testserver/v1/namespaced/3/'
def test_api_url_is_properly_reversed_with_nested(self):
field = self._create_field('nested', 'v1:nested-namespace')
assert field.to_representation(PKOnlyObject(3)) == 'http://testserver/v1/nested/namespaced/3/'
def test_api_url_is_properly_reversed_with_v2(self):
field = self._create_field('namespaced', 'v2')
assert field.to_representation(PKOnlyObject(5)) == 'http://testserver/v2/namespaced/5/'