Library to operate api with help of fild contracts
Project description
fild-api-hub
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()
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fild_api_hub-0.0.5.tar.gz.
File metadata
- Download URL: fild_api_hub-0.0.5.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ce7a4ee58aba6e80bef22663c80bb3b59fe06052540b4944a6d1646b21d3b0d
|
|
| MD5 |
7fcf27b24eed56cdf660f0ef0e80fc16
|
|
| BLAKE2b-256 |
31b3f83432ec4d0a483919a099c1b56966ef74db0bc706b56cd91495331bb7d6
|
File details
Details for the file fild_api_hub-0.0.5-py3-none-any.whl.
File metadata
- Download URL: fild_api_hub-0.0.5-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
290d3b66a0fc2e0a8e2bd74309a73161fb5db5fa6adaeb79766491762d88d25c
|
|
| MD5 |
9b76028d9a25c2354ce8d43265802ceb
|
|
| BLAKE2b-256 |
32bc8f640d4fa05cbc80a16f468790d87084affd09874b4cad6befcc127cb244
|