mock_api
mocks api function returning fake data with specified shape. Every url can have different shape, these are represented in skema format in a yaml file,
/posts/: |
Response:
ok: Bool
data: [
postName: Str
date: Str
id: Int
]
/post/: |
Response:
ok: Bool
data:
author:
name: Str
id: Int
description: Str
The shape of the data can change based on url hostname or path. an example:
from mock_api import mock_function
from myapi import api_call
with mock_function('myapi.api_call', 'api_shape.yml', arg=0):
data = api_call('/posts/')
print(data) # {'ok': True, 'data': {'postName': 'sdfsdgx', 'date': 'sdfg4'}}
genrating the api shapes
You can generating the shapes calling many times the api
from mock_api import track_function
from myapi import api_call
with track_function('myapi.api_call', 'api_shape.yaml', ):
api_call('/posts/')
api_call('/post/34')
api_call('/post/14')
api_call('/data/')
# a file api_shape.yaml is created
assert os.path.exists('api_shape)
todo:
- change shape based on POST, GET ...
- change shape based on parameters
- add url parameters, like posts/:id/
- remove Response root key maybe (but i can't use root arrays, Root: [...])
- add possible codes, like 200, 400, then change shape based on them
Metadata
Release files for mock-api 0.0.7
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 | |
|---|---|---|---|---|
| mock_api-0.0.7.tar.gz | 4.8 kB | Without provenance | Details |
Release files / mock_api-0.0.7.tar.gz
| Download URL | mock_api-0.0.7.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c2fac6ce14aec02671e0b376a6044664a438d73c4f525a9adfe19a6e31ea650
|
|
BLAKE2b-256 checksum How to use checksums |
aca9912690eed3d363c04b3425ee47a98a85fadbf93b50a6f108b3cf07fb4ec4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
|
Security for mock-api 0.0.7
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.