mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-09-17 09:42:29 +03:00
additional basename tests
This commit is contained in:
parent
91a74068b3
commit
d3954efc9c
|
@ -493,13 +493,12 @@ class TestViewInitkwargs(URLPatternsTestCase, TestCase):
|
||||||
assert initkwargs['basename'] == 'routertestmodel'
|
assert initkwargs['basename'] == 'routertestmodel'
|
||||||
|
|
||||||
|
|
||||||
class TestDuplicateBasename(TestCase):
|
class BasenameTestCase:
|
||||||
def test_conflicting_autogenerated_basenames(self):
|
def test_conflicting_autogenerated_basenames(self):
|
||||||
"""
|
"""
|
||||||
Ensure 2 routers with the same model, and no basename specified
|
Ensure 2 routers with the same model, and no basename specified
|
||||||
throws an ImproperlyConfigured exception
|
throws an ImproperlyConfigured exception
|
||||||
"""
|
"""
|
||||||
self.router = SimpleRouter(trailing_slash=False)
|
|
||||||
self.router.register(r'notes', NoteViewSet)
|
self.router.register(r'notes', NoteViewSet)
|
||||||
|
|
||||||
with pytest.raises(ImproperlyConfigured):
|
with pytest.raises(ImproperlyConfigured):
|
||||||
|
@ -513,7 +512,6 @@ class TestDuplicateBasename(TestCase):
|
||||||
Ensure 2 routers with the same model, and no basename specified on 1
|
Ensure 2 routers with the same model, and no basename specified on 1
|
||||||
throws an ImproperlyConfigured exception
|
throws an ImproperlyConfigured exception
|
||||||
"""
|
"""
|
||||||
self.router = SimpleRouter(trailing_slash=False)
|
|
||||||
self.router.register(r'notes', NoteViewSet)
|
self.router.register(r'notes', NoteViewSet)
|
||||||
|
|
||||||
with pytest.raises(ImproperlyConfigured):
|
with pytest.raises(ImproperlyConfigured):
|
||||||
|
@ -527,7 +525,6 @@ class TestDuplicateBasename(TestCase):
|
||||||
Ensure 2 routers with the same model, and a distinct basename
|
Ensure 2 routers with the same model, and a distinct basename
|
||||||
specified on the second router does not fail
|
specified on the second router does not fail
|
||||||
"""
|
"""
|
||||||
self.router = SimpleRouter(trailing_slash=False)
|
|
||||||
self.router.register(r'notes', NoteViewSet)
|
self.router.register(r'notes', NoteViewSet)
|
||||||
self.router.register(r'notes_kwduplicate', KWargedNoteViewSet, basename='routertestmodel_kwduplicate')
|
self.router.register(r'notes_kwduplicate', KWargedNoteViewSet, basename='routertestmodel_kwduplicate')
|
||||||
self.router.register(r'notes_duplicate', NoteViewSet, basename='routertestmodel_duplicate')
|
self.router.register(r'notes_duplicate', NoteViewSet, basename='routertestmodel_duplicate')
|
||||||
|
@ -537,7 +534,6 @@ class TestDuplicateBasename(TestCase):
|
||||||
Ensure 2 routers with the same model, and the same basename specified
|
Ensure 2 routers with the same model, and the same basename specified
|
||||||
on both throws an ImproperlyConfigured exception
|
on both throws an ImproperlyConfigured exception
|
||||||
"""
|
"""
|
||||||
self.router = SimpleRouter(trailing_slash=False)
|
|
||||||
self.router.register(r'notes', NoteViewSet, basename='notes')
|
self.router.register(r'notes', NoteViewSet, basename='notes')
|
||||||
|
|
||||||
with pytest.raises(ImproperlyConfigured):
|
with pytest.raises(ImproperlyConfigured):
|
||||||
|
@ -551,7 +547,6 @@ class TestDuplicateBasename(TestCase):
|
||||||
Ensure 2 routers with the same model, and a distinct basename specified
|
Ensure 2 routers with the same model, and a distinct basename specified
|
||||||
on each does not throw an exception
|
on each does not throw an exception
|
||||||
"""
|
"""
|
||||||
self.router = SimpleRouter(trailing_slash=False)
|
|
||||||
self.router.register(r'notes', NoteViewSet, basename='notes')
|
self.router.register(r'notes', NoteViewSet, basename='notes')
|
||||||
self.router.register(r'notes_kwduplicate', KWargedNoteViewSet, basename='notes_kwduplicate')
|
self.router.register(r'notes_kwduplicate', KWargedNoteViewSet, basename='notes_kwduplicate')
|
||||||
self.router.register(r'notes_duplicate', NoteViewSet, basename='notes_duplicate')
|
self.router.register(r'notes_duplicate', NoteViewSet, basename='notes_duplicate')
|
||||||
|
@ -561,7 +556,6 @@ class TestDuplicateBasename(TestCase):
|
||||||
Ensure 2 routers with different models, and a distinct basename specified
|
Ensure 2 routers with different models, and a distinct basename specified
|
||||||
on each does not throw an exception
|
on each does not throw an exception
|
||||||
"""
|
"""
|
||||||
self.router = SimpleRouter(trailing_slash=False)
|
|
||||||
self.router.register(r'notes', NoteViewSet, basename='notes')
|
self.router.register(r'notes', NoteViewSet, basename='notes')
|
||||||
self.router.register(r'notes_basename', BasenameViewSet, basename='notes_basename')
|
self.router.register(r'notes_basename', BasenameViewSet, basename='notes_basename')
|
||||||
|
|
||||||
|
@ -570,7 +564,6 @@ class TestDuplicateBasename(TestCase):
|
||||||
Ensure 2 routers with different models, and a conflicting basename specified
|
Ensure 2 routers with different models, and a conflicting basename specified
|
||||||
throws an exception
|
throws an exception
|
||||||
"""
|
"""
|
||||||
self.router = SimpleRouter(trailing_slash=False)
|
|
||||||
self.router.register(r'notes', NoteViewSet)
|
self.router.register(r'notes', NoteViewSet)
|
||||||
with pytest.raises(ImproperlyConfigured):
|
with pytest.raises(ImproperlyConfigured):
|
||||||
self.router.register(r'notes_basename', BasenameViewSet, basename='routertestmodel')
|
self.router.register(r'notes_basename', BasenameViewSet, basename='routertestmodel')
|
||||||
|
@ -580,6 +573,21 @@ class TestDuplicateBasename(TestCase):
|
||||||
Ensure 2 routers with different models, and a distinct basename specified
|
Ensure 2 routers with different models, and a distinct basename specified
|
||||||
on each does not throw an exception
|
on each does not throw an exception
|
||||||
"""
|
"""
|
||||||
self.router = SimpleRouter(trailing_slash=False)
|
|
||||||
self.router.register(r'notes', NoteViewSet)
|
self.router.register(r'notes', NoteViewSet)
|
||||||
self.router.register(r'notes_basename', BasenameViewSet)
|
self.router.register(r'notes_basename', BasenameViewSet)
|
||||||
|
|
||||||
|
|
||||||
|
class TestDuplicateBasenameSimpleRouter(BasenameTestCase, TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.router = SimpleRouter(trailing_slash=False)
|
||||||
|
|
||||||
|
|
||||||
|
class TestDuplicateBasenameDefaultRouter(BasenameTestCase, TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.router = DefaultRouter()
|
||||||
|
|
||||||
|
|
||||||
|
class TestDuplicateBasenameDefaultRouterRootViewName(BasenameTestCase, TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.router = DefaultRouter()
|
||||||
|
self.router.root_view_name = 'nameable-root'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user