From 2f31a0a01138653be65b655d2a27dbfb720f9786 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Sat, 20 Jul 2019 20:59:03 +0200 Subject: [PATCH] Add test for OpenAPI SchemaGenerator url argument. --- tests/schemas/test_openapi.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/schemas/test_openapi.py b/tests/schemas/test_openapi.py index 24e5f525d..3f579dbd5 100644 --- a/tests/schemas/test_openapi.py +++ b/tests/schemas/test_openapi.py @@ -228,6 +228,19 @@ class TestGenerator(TestCase): assert '/v1/example/' in paths assert '/v1/example/{id}/' in paths + def test_mount_url_prefixed_to_paths(self): + patterns = [ + url(r'^example/?$', views.ExampleListView.as_view()), + url(r'^example/{pk}/?$', views.ExampleDetailView.as_view()), + ] + generator = SchemaGenerator(patterns=patterns, url='/api/') + generator._initialise_endpoints() + + paths = generator.get_paths() + + assert '/api/example/' in paths + assert '/api/example/{id}/' in paths + def test_schema_construction(self): """Construction of the top level dictionary.""" patterns = [