semvec/pypi-packages huggingface dataset:
fild 0.1.10
Library to describe contracts and generate data
License: MIT
Requires Python: >=3.7
Keywords: testing, automation, python, pytest plugin


![Downloads](https://img.shields.io/pypi/dm/fild.svg?style=flat)
![Python Versions](https://img.shields.io/pypi/pyversions/fild.svg?style=flat)
![License](https://img.shields.io/pypi/l/fild.svg?version=latest)
[![Build Status](https://github.com/elenakulgavaya/fild/workflows/Tests/badge.svg)](https://github.com/elenakulgavaya/fild/actions)

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
```python
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
```python
generated_customer = Customer()
generated_full_customer = Customer(is_full=True)
```

[Install from PyPI](https://pypi.org/project/fild/)