Library to simplify writing HTTP REST service integration tests
Project description
Library to simplify writing HTTP REST service integration tests.
Allows to build a HTTP REST client with automatic resource cleanup.
Example
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('http://localhost: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()
Installation
$ pip install http-test-client
Requirements
Python >= 2.7 and <= 3.6
requests >= 2.14
six >= 1.10
Project Links
License
MIT licensed. See the bundled LICENSE file for more details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file http_test_client-0.3.2.tar.gz.
File metadata
- Download URL: http_test_client-0.3.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5fce02c84ceba05fcc28fc742ed73b9f9dcc1cf71c8649a91413b93c311a7b3
|
|
| MD5 |
9a1cad65c4486c4905a1918344bd6969
|
|
| BLAKE2b-256 |
20ac918658f2f4c83720b249965583f65ae013ec9517a9afb86ff58e191abc8c
|
File details
Details for the file http_test_client-0.3.2-py2.py3-none-any.whl.
File metadata
- Download URL: http_test_client-0.3.2-py2.py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58ff645d5ee53e1d6d2560744242221982902e8d9c6733ea81d3cbfd14ab6426
|
|
| MD5 |
29ee0b385bcb341416157c12f1cdc7df
|
|
| BLAKE2b-256 |
db341d32dc7d4a2e28bfc616d17b85986ee022ad303cc6b4b04c69c2db0862a5
|