Correct OpenAPI test for common prefixes.

This commit is contained in:
Carlton Gibson 2019-07-20 20:58:20 +02:00 committed by Carlton Gibson
parent 2138f558ce
commit 178a2dc786

View File

@ -229,18 +229,18 @@ class TestGenerator(TestCase):
assert 'post' in example_operations assert 'post' in example_operations
def test_prefixed_paths_construction(self): def test_prefixed_paths_construction(self):
"""Construction of the `paths` key with a common prefix.""" """Construction of the `paths` key maintains a common prefix."""
patterns = [ patterns = [
url(r'^api/v1/example/?$', views.ExampleListView.as_view()), url(r'^v1/example/?$', views.ExampleListView.as_view()),
url(r'^api/v1/example/{pk}/?$', views.ExampleDetailView.as_view()), url(r'^v1/example/{pk}/?$', views.ExampleDetailView.as_view()),
] ]
generator = SchemaGenerator(patterns=patterns) generator = SchemaGenerator(patterns=patterns)
generator._initialise_endpoints() generator._initialise_endpoints()
paths = generator.get_paths() paths = generator.get_paths()
assert '/example/' in paths assert '/v1/example/' in paths
assert '/example/{id}/' in paths assert '/v1/example/{id}/' in paths
def test_schema_construction(self): def test_schema_construction(self):
"""Construction of the top level dictionary.""" """Construction of the top level dictionary."""