Skip to main content

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.

Metadata

Release files for savida 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for savida 0.2.2
File Size Uploaded
savida-0.2.2.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for savida 0.2.2
File Interpreter ABI Platform
savida-0.2.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 14.6 kB

Release files / savida-0.2.2.tar.gz

Download URL savida-0.2.2.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
058352e81fae83bad849a45ecc2dccc9ec83d6ffafc06602eb29a4cb30488ced
BLAKE2b-256 checksum
How to use checksums
5e28157efe47bcf5a58e002e0ad4c6a4f29ac63f5cd2fe66f4702e9bed3ecc06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / savida-0.2.2-py2.py3-none-any.whl

Download URL savida-0.2.2-py2.py3-none-any.whl
Size 10.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9ee72f4b469ca75166a10bf09765971955355d06c42aeb37da25ebe9771d0785
BLAKE2b-256 checksum
How to use checksums
5d037ac16d3bab604b2d13904a3a2dfbf82db79c919889ea0acb88e5fd490a7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page