Skip to main content

Library to operate api with help of fild contracts

Project description

fild-api-hub v 0.0.5

Downloads Python Versions License Build Status

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

fild_api_hub-0.0.6.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fild_api_hub-0.0.6-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file fild_api_hub-0.0.6.tar.gz.

File metadata

  • Download URL: fild_api_hub-0.0.6.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for fild_api_hub-0.0.6.tar.gz
Algorithm Hash digest
SHA256 0d7aea4be25ab48c61d8fb0e9cfc0a0a9dd6fb4abb32418912ef0122ae5dd9c2
MD5 d36cceeb8b16e03e0adc9c0f64205082
BLAKE2b-256 1b38d7968401a654390c240bb917f00b29875803d8d63db63c94e4f5a7ce0e06

See more details on using hashes here.

File details

Details for the file fild_api_hub-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: fild_api_hub-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for fild_api_hub-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 757a97d7a6a255cb52853fed147b24ba793ba0a48acd712778287816e6a25760
MD5 530fa68f9338e2955bff0094f1c1f9cc
BLAKE2b-256 d50b5e01a7055560b190df6481c3ca94f7d4440772c27e31721ecdf37eba9fe8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page