hapic
hapic copied to clipboard
Test for doc generated by serpyco is unconsistent with last version of hapic/apispec_plugin
With last version for hapic/apispec-serpyco (not released yet), tests
test_func__test_fake_api_doc_ok__aiohttp_serpyco
is unconsistent. sometime it work correctly, sometime it just failed: Issue may come from apispec_serpyco.
test_client = <function aiohttp_client.<locals>.go at 0x7f22a4a32950>
async def test_func__test_fake_api_doc_ok__aiohttp_serpyco(test_client):
app = web.Application()
controllers = AiohttpSerpycoController()
controllers.bind(app)
hapic = get_aiohttp_serpyco_app_hapic(app)
doc = hapic.generate_doc(
title="Fake API", description="just an example of hapic API"
)
# FIXME BS 2018-11-26: Test produced doc atomic
> assert serpyco_SWAGGER_DOC_API == doc
E AssertionError: assert {'definitions...er'}})]), ...} == {'definitions'...er'}})]), ...}
E Common items:
E {'info': {'description': 'just an example of hapic API',
E 'title': 'Fake API',
E 'version': '1.0.0'},
E 'parameters': {},
E 'paths': OrderedDict([('/about',
E {'get': {'description': 'General information about '
E 'this API.',
E 'responses': {200: {'description': '200',
E 'schema': {'$ref': '#/definitions/AboutResponseSchema'}}}}}),
E ('/users',
E {'get': {'description': 'Obtain users list.',
E 'responses': {200: {'description': '200',
E 'schema': {'$ref': '#/definitions/ListsUserSchema'}}}}}),
E ('/users2',
E {'get': {'description': 'Obtain users list.',
E 'responses': {200: {'description': '200',
E 'schema': {'$ref': '#/definitions/UserSchema_exclude_first_name_last_name_email_address'}}}}}),
E ('/users/{id}',
E {'delete': {'description': 'delete user',
E 'parameters': [{'in': 'path',
E 'minimum': 1,
E 'name': 'id',
E 'required': True,
E 'type': 'integer'}],
E 'responses': {204: {'description': '204',
E 'schema': {'$ref': '#/definitions/NoContentSchema'}}}},
E 'get': {'description': 'Obtain one user',
E 'parameters': [{'in': 'path',
E 'minimum': 1,
E 'name': 'id',
E 'required': True,
E 'type': 'integer'}],
E 'responses': {200: {'description': '200',
E 'schema': {'$ref': '#/definitions/UserSchema'}}}}}),
E ('/users/',
E {'post': {'description': 'Add new user',
E 'parameters': [{'in': 'body',
E 'name': 'body',
E 'schema': {'$ref': '#/definitions/UserSchema_exclude_id'}}],
E 'responses': {200: {'description': '200',
E 'schema': {'$ref': '#/definitions/UserSchema'}}}}})]),
E 'responses': {},
E 'securityDefinitions': {},
E 'swagger': '2.0',
E 'tags': []}
E Differing items:
E {'definitions': {'AboutResponseSchema': {'description': 'A docstring to prevent auto generated docstring', 'properties...integer'}, 'last_id': {'type': 'integer'}}, 'required': ['first_id', 'last_id', 'current_id'], 'type': 'object'}, ...}} != {'definitions': {'AboutResponseSchema': {'description': 'A docstring to prevent auto generated docstring', 'properties...integer'}, 'last_id': {'type': 'integer'}}, 'required': ['first_id', 'last_id', 'current_id'], 'type': 'object'}, ...}}
E Full diff:
E {'definitions': {'AboutResponseSchema': {'description': 'A docstring to '
E 'prevent auto '
E 'generated docstring',
E 'properties': {'datetime': {'format': 'date-time',
E 'type': 'string'},
E 'version': {'type': 'string'}},
E 'required': ['datetime', 'version'],
E 'type': 'object'},
E 'ListsUserSchema': {'description': 'A docstring to prevent '
E 'auto generated docstring',
E 'properties': {'item_nb': {'minimum': 0,
E 'type': 'integer'},
E 'items': {'items': {'$ref': '#/definitions/UserSchema_exclude_first_name_last_name_email_address'},
E 'type': 'array'},
E 'pagination': {'$ref': '#/definitions/PaginationSchema'}},
E 'required': ['item_nb',
E 'items',
E 'pagination'],
E 'type': 'object'},
E 'NoContentSchema': {'description': 'A docstring to prevent '
E 'auto generated docstring',
E 'properties': {},
E 'type': 'object'},
E 'PaginationSchema': {'description': 'A docstring to prevent '
E 'auto generated docstring',
E 'properties': {'current_id': {'type': 'integer'},
E 'first_id': {'type': 'integer'},
E 'last_id': {'type': 'integer'}},
E 'required': ['first_id',
E 'last_id',
E 'current_id'],
E 'type': 'object'},
E 'UserPathSchema': {'description': 'A docstring to prevent '
E 'auto generated docstring',
E 'properties': {'id': {'minimum': 1,
E 'type': 'integer'}},
E 'required': ['id'],
E 'type': 'object'},
E 'UserSchema': {'description': 'A docstring to prevent auto '
E 'generated docstring',
E 'properties': {'company': {'type': 'string'},
E 'display_name': {'type': 'string'},
E 'email_address': {'format': <StringFormat.EMAIL: 'email'>,
E 'type': 'string'},
E 'first_name': {'type': 'string'},
E 'id': {'type': 'integer'},
E 'last_name': {'type': 'string'},
E 'username': {'pattern': '[\\w-]+',
E 'type': 'string'}},
E 'required': ['company',
E 'display_name',
E 'email_address',
E 'first_name',
E 'last_name',
E 'username'],
E 'type': 'object'},
E 'UserSchema_exclude_first_name_last_name_email_address': {'description': 'A '
E 'docstring '
E 'to '
E 'prevent '
E 'auto '
E 'generated '
E 'docstring',
E 'properties': {'company': {'type': 'string'},
E 'display_name': {'type': 'string'},
E - 'id': {'type': 'integer'},
E + 'id': {'anyOf': [{'type': 'integer'},
E ? +++++++++++
E + {'type': 'null'}],
E + 'default': None},
E 'username': {'pattern': '[\\w-]+',
E 'type': 'string'}},
E - 'required': ['company',
E ? ^^ ^^^^
E + 'required': ['display_name',
E ? ^^^^^^^^^^ ^
E - 'display_name',
E ? ^^^ - -----
E + 'company',
E ? ^^^ +
E 'username'],
E 'type': 'object'},
E 'UserSchema_exclude_id': {'description': 'A docstring to '
E 'prevent auto '
E 'generated docstring',
E 'properties': {'company': {'type': 'string'},
E 'display_name': {'type': 'string'},
E 'email_address': {'format': <StringFormat.EMAIL: 'email'>,
E 'type': 'string'},
E 'first_name': {'type': 'string'},
E 'last_name': {'type': 'string'},
E 'username': {'pattern': '[\\w-]+',
E 'type': 'string'}},
E 'required': ['company',
E 'display_name',
E 'email_address',
E 'first_name',
E 'last_name',
E 'username'],
E 'type': 'object'}},
E 'info': {'description': 'just an example of hapic API',
E 'title': 'Fake API',
E 'version': '1.0.0'},
E 'parameters': {},
E 'paths': OrderedDict([('/about',
E {'get': {'description': 'General information about '
E 'this API.',
E 'responses': {200: {'description': '200',
E 'schema': {'$ref': '#/definitions/AboutResponseSchema'}}}}}),
E ('/users',
E {'get': {'description': 'Obtain users list.',
E 'responses': {200: {'description': '200',
E 'schema': {'$ref': '#/definitions/ListsUserSchema'}}}}}),
E ('/users2',
E {'get': {'description': 'Obtain users list.',
E 'responses': {200: {'description': '200',
E 'schema': {'$ref': '#/definitions/UserSchema_exclude_first_name_last_name_email_address'}}}}}),
E ('/users/{id}',
E {'delete': {'description': 'delete user',
E 'parameters': [{'in': 'path',
E 'minimum': 1,
E 'name': 'id',
E 'required': True,
E 'type': 'integer'}],
E 'responses': {204: {'description': '204',
E 'schema': {'$ref': '#/definitions/NoContentSchema'}}}},
E 'get': {'description': 'Obtain one user',
E 'parameters': [{'in': 'path',
E 'minimum': 1,
E 'name': 'id',
E 'required': True,
E 'type': 'integer'}],
E 'responses': {200: {'description': '200',
E 'schema': {'$ref': '#/definitions/UserSchema'}}}}}),
E ('/users/',
E {'post': {'description': 'Add new user',
E 'parameters': [{'in': 'body',
E 'name': 'body',
E 'schema': {'$ref': '#/definitions/UserSchema_exclude_id'}}],
E 'responses': {200: {'description': '200',
E 'schema': {'$ref': '#/definitions/UserSchema'}}}}})]),
E 'responses': {},
E 'securityDefinitions': {},
E 'swagger': '2.0',
E 'tags': []}