Placebo 
Placebo is a utility that help mock api endpoints in a reusable and composable way.
To use placebo first we should create a placebo class for our mock. Placebo class represents a response for certain request. If url and http method of any request matches with mock, response that is described in placebo class will be return. We can create a placebo mock like this:
from placebo import Placebo
class UsersResponse(Placebo):
url = 'http://www.acme.com/api/v1/users/'
body = json.dumps([{'name': 'Huseyin',
'last_name': 'Yilmaz'}])
Main interface for a placebo object is a decorator. Any function that decorated with a placebo class will be mocked with that placebo class.
@UserResponse.decorate
def users_api_test(self):
...
You can decorate any function or method with this decorator. Even django views! This makes development against external apis very easy.
@UserResponse.decorate
def users_list_view(request):
...
If your code is using multiple api endpoints you can easily stack placebo decorators on top of each other.
@AuthResponse.decorate
@UserResponse.decorate
def test_valid_get_user(request):
...
@AuthResponse.decorate(status=401)
@UserResponse.decorate
def test_cannot_authenticate(request):
...
@AuthResponse.decorate
@UserResponse.decorate(status=503)
def test_api_is_not_available(request):
...
For more information, please refer to documentation
Metadata
Release files for python-placebo 1.0.1
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 | Actions |
|---|---|---|---|---|
| python-placebo-1.0.1.tar.gz | 7.9 kB | Without provenance | Details for python-placebo-1.0.1.tar.gz |
Release files / python-placebo-1.0.1.tar.gz
| Download URL | python-placebo-1.0.1.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
271b3692fea5a45c918c9c4fa26fb90bbe921788336dd211b9506fdeda924e2a
|
|
BLAKE2b-256 checksum How to use checksums |
e9977ef9683099972fc33c6ecf85fccb9f14dfc0891a27fa68a679d8a8b1a491
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for python-placebo 1.0.1
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.