Falcon API单元测试与Bravado的集成。
bravado-falcon的Python项目详细描述
Falcon API单元测试与Bravado的集成。用于测试应用程序的合同
您可以很容易地为其他基于框架的单元测试(例如Flask的)实现Bravado集成 关于这个密码。
这个库做的不多,但它实际上已经完成了功能(没有那么多功能 执行
未来可以改变的一件事是Falcon请求的模拟方式。 现在已经用pytest-falcon完成了,但是你 不必在测试中使用Pytest(但这很好,至少应该检查一下 它出来了)。
用法
frombravado.clientimportSwaggerClientfrombravado_falconimportFalconHttpClientapi=get_falcon_api()# get a falcon.APIswagger_spec=get_swagger_spec()# dict created by loading a YAML or JSON from a fileclient=SwaggerClient.from_spec(swagger_spec,http_client=FalconHttpClient(api))# "v1" is the first part of a path (e.g. "/v1/shopping/lists")# "getList" is the "operationId" element for an endpoint from Swagger# "id" is a path parameter (let's say from "/v1/shopping/lists/{id}")# See Bravado docs for more information.list_object=client.v1.getList(id='list-id').result()# now make assertions about the returned object