Skip to main content

No project description provided

Project description

EchoTester

Django app , that record requests that comes to your project then run them whenever you want to determine if things breaks while development (in case you don't have tests written) --- or you wanna to simulate a scenario each time you made a change

How to use it

Installation

Just install it from pip

pip install django-echo-tester

Then register is as an django app

INSTALLED_APPS = [
    ...    
    'echo_tester'
]

Then we need to record the requests to use it later.

MIDDLEWARE = [
    ...
    'echo_tester.middleware.TesterMiddleware',
]

Basic use

To run the saved requests, to test if there is breaking ones or not.

python manage.py runecho

Settings variables and advanced use

NOTE: Keys we use is just the path in the dictionary in other words you can consider the dictionary is an class instance and you get a value from it

for example:

request = {
    ...
    'headers': {
        'Content-Type': 'application/json',
        ...
    }
}

# To access the key wanted we use
path = 'headers.Content-Type'

Request

RequestObject

{
    "path": "/random/path/in/your/app/",
    "url": "http://domain.com/random/path/in/your/app/",
    "scheme": "http",
    "cookies": {
        "token": "12345"
    },
    "method": "GET",
    "headers": {
        "Content-Length": "",
        "Content-Type": "text/plain",
        "Accept": "*/*",
    },
    "payload": {
        "files": {},
        "get": {},
        "post": {},
        "json": null
    },
    "user": {
        "is_authenticated": false,
        "is_staff": false,
        "username": "",
        "id": null,
        "pk": null
    }
}
# How should identify the request is new or duplicated
ECHO_TESTER_REQUEST_IDENTIFIERS = [
    'method', 'user.pk', 'headers.Content-Type'
]

# Skip paths starts with this
ECHO_TESTER_SKIP_PATH = [
    '/admin',
    '/secret-app'
]

Response

ResponseObject

{
    "status_code": 404,
    "cookies": {},
    "headers": {
        "Content-Type": "text/html"
    },
    "data": "[DATA DROPPED]",
    "content_length": null,
    "content_encoding": null,
    "content_type": "text/html"
}
# What to check if response is changed or broken
ECHO_TESTER_RESPONSE_CHECKS = [
    'status_code', 'headers.Content-Type'
]

# Drop html from the response default is `True`
ECHO_TESTER_DROP_HTML_FROM_RESPONSE = True

Credentials

we need to track and update credentials to make sure saved requests and responses is always valid.

# Track & update credentials or not
ECHO_TESTER_CREDENTIALS_WATCH = True

# the key of who this credentials related for (credential owner id)
ECHO_TESTER_CREDENTIALS_IDENTIFIER_KEY = 'user.pk'

# what key uses to track credentials, if you use session/token based authentication
# just add the valid kays
ECHO_TESTER_CREDENTIALS_KEYS = [
    'cookies.sessionid'
]

General settings

# raise or skip errors that happened while listening 
ECHO_TESTER_RAISE_ERRORS = True 

# stop this middleware while running tests
# just provide a part of the name if you want
ECHO_TESTER_SKIP_MIDDLEWARE_CONTAIN = [
    # FOR Example: stop csrf and stop recording
    'csrf', apps.EchoTesterConfig.name
]

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

django-echo-tester-0.0.5.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

django_echo_tester-0.0.5-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file django-echo-tester-0.0.5.tar.gz.

File metadata

  • Download URL: django-echo-tester-0.0.5.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for django-echo-tester-0.0.5.tar.gz
Algorithm Hash digest
SHA256 7acaaaf1b0441439128958dadb3308b0814fe4871e33deba10dc2f67d48a9669
MD5 9bffa4ae6c3362a77d85accb9d7f1e2a
BLAKE2b-256 718621287c3456656c6c9468439aee3b6655b75854a1c1dd7b01611cd2626e85

See more details on using hashes here.

File details

Details for the file django_echo_tester-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_echo_tester-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 db6bf8ce9d9d60d49069eb6090d9608fee0102582a7d5efa0f0313df68f39c6c
MD5 97bbd7f38c5f05541baab89de293878a
BLAKE2b-256 4045fa3baadb01d30b217a093cad176e1c5df2d1afe3898de080599fc3591209

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