简化编写http rest服务集成测试的库
http-test-client的Python项目详细描述
库以简化编写http rest服务集成测试。
允许使用自动资源清理来构建http rest客户端。
示例
fromhttp_test_clientimportClient,HttpTransport,RestResources,resourcesclassArticleResources(RestResources):defsearch(self,query):returnself._request('/search',method='POST',data={'query':query})classResource(RestResources.Resource):defpublish(self):returnself._request('/publish',method='POST')comments=resources('/comments')classMyClient(Client):users=resources('/users')articles=resources('/articles',ArticleResources)client=MyClient(HttpTransport('http://localhost:8888'))# managing resourcesclient.users.list()# => [{'id': '1', 'name': 'John'}, ...]client.users.create({'name':'Jane'})# => {'id': '2'}client.users['1'].get()# => {'id': '1', 'name': 'John'}client.users['1'].delete()# delete all resources that were created during this client sessionclient.cleanup()# custom actionclient.articles['123'].publish()# nested resourcesclient.articles['123'].comments.list()
安装
$ pip install http-test-client
要求
- python>;=2.7和<;=3.6
- requests>;=2.14
- 六>;=1.10
项目链接
许可证
麻省理工学院许可有关详细信息,请参阅捆绑的LICENSE文件