DEPRECATED — This package is no longer maintained. Migrate to surety-api:
pip install surety-apiReplace
from fildapi import ApiCaller, ApiMethod, MockServer, HttpMethodwithfrom surety.api import ApiCaller, ApiContract, MockServer, HttpMethod. Note:ApiMethodwas renamed toApiContractinsurety-api.
fild-api-hub v 0.0.8
The FILD Api Hub is a set of tools enabling using FILD described contracts in tests.
Configure your project with yaml files in etc/config.yaml containing
App:
url: http://localhost:8000
MockServer:
host: localhost
port: 8088
Override any local configuration variables by adding etc/local.yaml
MockServer:
port: 8080
Use ApiMethod to describe the API
from fild.sdk import Dictionary, Int, String, Uuid
from fildapi import ApiMethod, HttpMethod
SERVICE = 'customer_api'
BASE_URL = 'http://mydomain.customerapi'
class CreateUserRequest(Dictionary):
Name = String(name='name')
Email = String(name='email')
Age = Int(name='age', min_val=18, max_val=120)
class CreateUserResponse(Dictionary):
Id = Uuid(name='id')
class CreateUser(ApiMethod):
method = HttpMethod.POST
url = 'api/users'
req_body = CreateUserRequest
resp_body = CreateUserResponse
Use ApiMethod for mocking and verifying integrations
from customer_api import CreateUser
def test_failed_to_create_user():
CreateUser.reply(status=400)
# Test action to check error
def test_verify_call_to_customer_api():
CreateUser.reply()
# Some test action
CreateUser.verify_called()
Use ApiCaller to test the api:
from fildapi import ApiCaller
from customer_api import CreateUser
class CreateUserCall(ApiCaller):
method = CreateUser
def test_create_user():
CreateUserCall().request().verify_response()
Release files for fild-api-hub 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fild_api_hub-0.0.9.tar.gz | 21.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fild_api_hub-0.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.5 kB
Release files / fild_api_hub-0.0.9.tar.gz
| Download URL | fild_api_hub-0.0.9.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d2de812cdb488b0509ddcd7e09869aa752c28db0e5eb50312609777f5207b39
|
|
BLAKE2b-256 checksum How to use checksums |
76ba7e985ebe5cf070bd05627c2c7076e3db86296855909a4057a04ead206b4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / fild_api_hub-0.0.9-py3-none-any.whl
| Download URL | fild_api_hub-0.0.9-py3-none-any.whl |
|---|---|
| Size | 21.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ff776e65188866387538c4101dce7e5e74aa287ab01e6a6178542808558c4f4
|
|
BLAKE2b-256 checksum How to use checksums |
c6d138c97fecde2f39b3f458e926fcf2418349d66fdb3ea57fd903328fd3a2a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|