add test case for schema generator

This commit is contained in:
Dhaval Mehta 2020-05-26 02:56:00 +05:30
parent 2978f14864
commit 2b47ec4e1c

View File

@ -1109,3 +1109,21 @@ class TestGenerator(TestCase):
schema = generator.get_schema(request=create_request('/')) schema = generator.get_schema(request=create_request('/'))
assert 'components' not in schema assert 'components' not in schema
assert 'content' not in schema['paths']['/example/']['delete']['responses']['204'] 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