跳转到主要内容

简化编写HTTP REST服务集成测试的库

项目描述

简化编写HTTP REST服务集成测试的库。

允许构建具有自动资源清理的HTTP REST客户端。

示例

from http_test_client import Client, HttpTransport, RestResources, resources

class ArticleResources(RestResources):
    def search(self, query):
        return self._request('/search', method='POST', data={'query': query})

    class Resource(RestResources.Resource):
        def publish(self):
            return self._request('/publish', method='POST')

        comments = resources('/comments')

class MyClient(Client):
    users = resources('/users')
    articles = resources('/articles', ArticleResources)

client = MyClient(HttpTransport('https://:8888'))

# managing resources
client.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 session
client.cleanup()

# custom action
client.articles['123'].publish()

# nested resources
client.articles['123'].comments.list()

安装

$ pip install http-test-client

需求

  • Python >= 2.7 and <= 3.6

  • requests >= 2.14

  • six >= 1.10

许可证

MIT许可证。有关更多详细信息,请参阅捆绑的LICENSE文件。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装软件包的信息。

源分发

http_test_client-0.3.2.tar.gz (4.6 kB 查看哈希值)

上传时间:

构建分发

http_test_client-0.3.2-py2.py3-none-any.whl (6.6 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误记录StatusPageStatusPage状态页面