Skip to content

Commit 30a21a9

Browse files
committed
Add test for OpenAPI SchemaGenerator url argument.
1 parent 178a2dc commit 30a21a9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/schemas/test_openapi.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,19 @@ def test_prefixed_paths_construction(self):
242242
assert '/v1/example/' in paths
243243
assert '/v1/example/{id}/' in paths
244244

245+
def test_mount_url_prefixed_to_paths(self):
246+
patterns = [
247+
url(r'^example/?$', views.ExampleListView.as_view()),
248+
url(r'^example/{pk}/?$', views.ExampleDetailView.as_view()),
249+
]
250+
generator = SchemaGenerator(patterns=patterns, url='/api/')
251+
generator._initialise_endpoints()
252+
253+
paths = generator.get_paths()
254+
255+
assert '/api/example/' in paths
256+
assert '/api/example/{id}/' in paths
257+
245258
def test_schema_construction(self):
246259
"""Construction of the top level dictionary."""
247260
patterns = [

0 commit comments

Comments
 (0)