Skip to main content

Savida - Testing HTTP Server Fixture

Project description

Savida Testing Web Server Fixture

Savida is a testing-oriented HTTP server wrapper. It allows to easily launch a Web server during an automated test, define its behavior (i.e. how to respond to different requests) and shut it down easily when the test ends.

This is useful when testing complex HTTP-client based systems - for example at Shoppimon it is used to test our Web monitoring system infrastructure, which needs to access Websites using a complex browser and return different information based on entire page behaviors or even entire passes through the site.

Testing such systems is not possible using current mock HTTP client libraries or naive test server implementations, and this is why we created Savida.

Note that while the examples below refer to py.test, this module is in no way tied to a specific testing framework or methodology.

Usage

In testing frameworks like py.test, usage usually looks something like:

from savida.fixture import http_server

def test_my_browser_works():
    # Set up the server with a static document root directory
    with http_server(document_root='fixtures/webroot') as server:

        # Return 404 on /js/main.js even if it exists in our docroot
        server.when('/js/main.js').response(
            status=404, response='Gone to Lunch')

        # Wait 10 seconds before responding to /slow.php
        server.when('/slow.php').wait(10)

        server.start()

        response = requests.get(server.url + '/js/main.js')
        assert response.status_code == 404

Usage in module setup / teardown functions

TBD

API

TBD

TODO

  • Add documentation
  • Clean up API, replace wait method with something more concise
  • Add support for matching based on HTTP method

License

Copyright (c) 2017 Shoppimon LTD

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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

savida-0.2.1.dev0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

savida-0.2.1.dev0-py2.py3-none-any.whl (5.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file savida-0.2.1.dev0.tar.gz.

File metadata

  • Download URL: savida-0.2.1.dev0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for savida-0.2.1.dev0.tar.gz
Algorithm Hash digest
SHA256 b9fd9fc14c19a5ab95c9ecb59b4f95a50ca087707479d7c2e258d15cabb02df4
MD5 146caca9b54085bff5463bba053bf28e
BLAKE2b-256 aa15eae374959eb2aa5028f1a93ecfa563fba37f3a8a0701623ab38eeb8c3456

See more details on using hashes here.

File details

Details for the file savida-0.2.1.dev0-py2.py3-none-any.whl.

File metadata

  • Download URL: savida-0.2.1.dev0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for savida-0.2.1.dev0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1fd903e18ac0e5ab590153e4f5704c2604827ecb5f4160505f8af6026532b82e
MD5 f82da897481d05a379f0d06653587659
BLAKE2b-256 2deba83fdb5674285ab4b00188fd9b0074bfecc18bd72b41c68384c764052363

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page