From 2b47ec4e1cbd56361df21868c8f2b83c501a3137 Mon Sep 17 00:00:00 2001 From: Dhaval Mehta <20968146+dhaval-mehta@users.noreply.github.com> Date: Tue, 26 May 2020 02:56:00 +0530 Subject: [PATCH] add test case for schema generator --- tests/schemas/test_openapi.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/schemas/test_openapi.py b/tests/schemas/test_openapi.py index 0e86a7f50..f829a6038 100644 --- a/tests/schemas/test_openapi.py +++ b/tests/schemas/test_openapi.py @@ -1109,3 +1109,21 @@ class TestGenerator(TestCase): schema = generator.get_schema(request=create_request('/')) assert 'components' not in schema assert 'content' not in schema['paths']['/example/']['delete']['responses']['204'] + + def test_tag_objects(self): + patterns = [ + url(r'^example/?$', views.ExampleGenericAPIViewModel.as_view()), + ] + generator = SchemaGenerator(patterns=patterns, tag_objects=[{"name": "pet", "description": "Pets operations"}]) + request = create_request('/') + schema = generator.get_schema(request=request) + assert schema['tags'] == [{"name": "pet", "description": "Pets operations"}] + + def test_schema_without_tag_objects(self): + patterns = [ + url(r'^example/?$', views.ExampleGenericAPIViewModel.as_view()), + ] + generator = SchemaGenerator(patterns=patterns) + request = create_request('/') + schema = generator.get_schema(request=request) + assert 'tags' not in schema