Skip to main content

Library to describe contracts and generate data

Project description

Downloads Python Versions License Build Status

FILD is a lightweight Python library for automated contract testing. FILD allows to store descriptive structure of the API and use it further for generating test data based on Faker.

The basic type for usage is Field, any other types should inherit from. Field supports the description of the API parameter within the following:
name: key in json
required: identifies the necessity of presense of the key in the resulting json.
allow_none: should be true if the value can be null in the json.
default: default value to be used in regular generation. Can either be the value or the callable to generate.

Abstract method generate_value is used to specify the rules based on which the value should be generated. When defining new type, inherited from Field, the method should be overriden to describe the generation procedure.

Library supports multi-level hierarchy with Arrays and Dictionaries.

Library also provides some dict operating methods.
filter_dict: allows to apply value/callable filter to dict by values
merge_with_updates: merges two dicts with either overriding or only adding values to the target dictionary.
normalize: sorts lists - both top level and embeded - to represent the desired order.

Examples

Field object is used to describe data structures

from fild.sdk import Dictionary, Enum, Int, String, Uuid


class Gender(Enum):
    Male = 'male'
    Femail = 'female'
    Other = 'other'


class Customer(Dictionary):
    Id = Uuid(name='id')
    Name = String(name='name', max_len=100)
    Age = Int(name='age', min_val=18, max_val=120)
    Gender = Gender(name='gender', required=False)
    Email = String(name='email')

Based on the description the data can be generated by calling constructor with or without parameters

generated_customer = Customer()
generated_full_customer = Customer(is_full=True)

Install from PyPI

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-0.1.10.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

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

fild-0.1.10-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file fild-0.1.10.tar.gz.

File metadata

  • Download URL: fild-0.1.10.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for fild-0.1.10.tar.gz
Algorithm Hash digest
SHA256 3c2bfca583c90f64fb6dad67edfcac258692085d6fe6ba5c3235b850f237eb11
MD5 591236e069f3aa1f7a96e4b80ce91def
BLAKE2b-256 d76a3984192d4270ba307dba54d3332b90b230c011fcc8c1d901370b24e9443d

See more details on using hashes here.

File details

Details for the file fild-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: fild-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for fild-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 748a0e80613860278ea70a6aae29220c290d2f7b49bb6a0c8b764e44d22dc490
MD5 c0c1d4b70d81793e6f687afee9d9b542
BLAKE2b-256 06372d3dfc47c56e30fc438ee6eae713b31180b532badff8ae416d365624fa2f

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