drf-chaos extension
drf-chaos is a small collection of decorators and middlewares for testing Django REST Framework API under unexpected circumstances.
Settings
DRF_CHAOS_ENABLED
Decorators
Delay
Delay response of a specific amount of milliseconds
@delay(rate, milliseconds)
Params:
rate: probability that an unexpected event happens
milliseconds: suspend execution of the current thread for the given number of milliseconds
Error
Return a different response HTTP status code
@error(rate, status)
Params:
rate: probability that an unexpected event happens
status: integer corresponding to any valid HTTP status code. See DRF HTTP status codes
Mime
Return a random Mime Content-type
@mime(rate)
Params:
rate: probability that an unexpected event happens
Chaos
Apply a random unexpected event to the HTTP response. (A delay between 0 to 3 second and a random HTTP status code)
@chaos(rate)
Params:
rate: probability that an unexpected event happens
Middlewares
ChaosMiddleware
Example
from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
from drf_chaos.decorators import delay, error, mime, chaos
class DelayApiView(APIView):
@delay(rate=0.5, milliseconds=700)
def get(self, request):
return Response(status=status.HTTP_204_NO_CONTENT)
class ErrorApiView(APIView):
@error(rate=0.5, status=500)
def get(self, request):
return Response(status=status.HTTP_204_NO_CONTENT)
class MimeTypeApiView(APIView):
@mime(rate=0.5)
def get(self, request):
return Response(status=status.HTTP_204_NO_CONTENT)
class ChaosApiView(APIView):
@chaos(rate=0.5)
def get(self, request):
return Response(status=status.HTTP_204_NO_CONTENT)
Requirements
Python (2.7)
Django (1.6+, 1.7+, 1.8)
Installation
Install using pip
pip install drf-chaos
Add ‘drf_chaos’ to your INSTALLED_APPS setting.
INSTALLED_APPS = (
...
'drf_chaos',
)
Metadata
Release files for drf-chaos 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| drf-chaos-0.1.3.tar.gz | 3.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| drf-chaos-0.1.3.macosx-10.10-intel.exe | Details |
Total release size: 71.8 kB
Release files / drf-chaos-0.1.3.tar.gz
| Download URL | drf-chaos-0.1.3.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1141ec3f75289b7c66cd8b760da7ebeb371b15ea21b976658d483b9bc5db9555
|
|
BLAKE2b-256 checksum How to use checksums |
4e7026c1925d21a63b356735122b6d511f45a55a3f86281bebb4f3244ec9d0ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / drf-chaos-0.1.3.macosx-10.10-intel.exe
| Download URL | drf-chaos-0.1.3.macosx-10.10-intel.exe |
|---|---|
| Size | 68.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea1802b455ae9aca8d4864ed7469a8386c914557cabba75c5485a0dedca5b8cc
|
|
BLAKE2b-256 checksum How to use checksums |
65cd1811c6b9f1cc18aea80a824372f8c00ba69c13bdee1ed8a006d0ca724f4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for drf-chaos 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.