بدون توضیح

Wiliam Souza a3cae5c8c1 Add protocol 9 سال پیش
docs c5d472f69f Keep docs build dir 9 سال پیش
echo a3cae5c8c1 Add protocol 9 سال پیش
tests 98c7a65649 Update pytest-asyncio and remove workaround to it work 9 سال پیش
.coveragerc e255655250 Adds env files, docker files and coverage conf 9 سال پیش
.gitignore 31091d4778 Moved to echo/echod.py, add support to env var configuration 9 سال پیش
.travis.yml 98c7a65649 Update pytest-asyncio and remove workaround to it work 9 سال پیش
AUTHORS 4651521daa Add project basic files 9 سال پیش
CHANGES.md 2f4db3f1a6 Add tox and version commands to setup 9 سال پیش
Dockerfile e255655250 Adds env files, docker files and coverage conf 9 سال پیش
MANIFEST.in ad2c3c4209 Add docs and tox commands 9 سال پیش
Makefile dc5756d4f5 Add make commands 9 سال پیش
README.md 78dbec4d8c Add travis and coverage badge 9 سال پیش
docker-compose.yml e255655250 Adds env files, docker files and coverage conf 9 سال پیش
docker_env e255655250 Adds env files, docker files and coverage conf 9 سال پیش
dot_env e255655250 Adds env files, docker files and coverage conf 9 سال پیش
repos.sh 4651521daa Add project basic files 9 سال پیش
setup.py 98c7a65649 Update pytest-asyncio and remove workaround to it work 9 سال پیش
tox.ini 98c7a65649 Update pytest-asyncio and remove workaround to it work 9 سال پیش

README.md

echo

Build Status Coverage Status

Echo is a fully configurable mock server, TCP chaos monkey proxy and an HTTP callback recorder. It is perfect to test external services.

The Echo make extensive use of Python context managers. This make it easy to controlling Echo on the fly from your code or using your testing framework setup mechanism.

The main part of Echo is an HTTP server with an REST API, the Echo HTTP server have a lot of flexibility and support many start up methods.

Echo server can be run as:

  • A standalone using echo command line tool.
  • A WSGI HTTP Server application.
  • A Docker instance container.

Mock

import echo


mock_response = {
    'status_code': 200,
    'body': {...},
}

request_contain = {
    'body': {...}
}

expectation = {
    'method': 'POST',
    'path': '/v1/users/',
    'request': request_contain,
    'response': mock_response,
}

with echo.mock(**expectation) as client:
    response = client.post()
    response.status_code == 200

Proxy

import settings


expectation = {
    'backend': 'google.com:80',
    'behaviour': {'20:delay': {'before': True, 'sleep': 1}},
    'protocol': {'http': {'buffer': 8124, 'keep_alive': False,
                          'overwrite_host_header': True,
                          'reuse_socket': False}}
}

with echo.proxy(**expectation) as proxy:
    settings.external_service_url = proxy.url
    proxy.post()

callback

import requests


with echo.callback() as webhook:
    settings.callback_url = webhook.url
    requests.post()
    webhook.wait_callback(timeout=10)
    webhook.response.data == {...}