Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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._client.request(self._url + '/search', data={'query': query})

    class Resource(RestResources.Resource):
        def publish(self):
            return self._client.request(self._url + '/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

License

MIT licensed. See the bundled LICENSE file for more details.

Release History

This version
History Node

0.2.1

History Node

0.2

History Node

0.1

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
http_test_client-0.2.1-py2.py3-none-any.whl
(6.1 kB) Copy SHA256 Hash SHA256
Wheel py2.py3 Aug 1, 2017
http_test_client-0.2.1.tar.gz
(4.1 kB) Copy SHA256 Hash SHA256
Source None Aug 1, 2017

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting