An open API service indexing awesome lists of open source software.

https://github.com/headsrooms/fistro

A fixture generator based on type annotations.
https://github.com/headsrooms/fistro

annotations dataclasses fixture-data fixture-generator fixture-test fixtures python test testing-library testing-tools

Last synced: 5 months ago
JSON representation

A fixture generator based on type annotations.

Awesome Lists containing this project

README

          

Fistro
======

![pypi](https://img.shields.io/pypi/v/fistro)
[![codecov](https://codecov.io/gh/headsrooms/fistro/branch/master/graph/badge.svg?token=7lhLh5bRD5)](https://codecov.io/gh/headsrooms/fistro)

A fixture generator based on type annotations.

Examples
--------

```python
from dataclasses import dataclass
from datetime import datetime, date
from typing import List

from fistro.fistro import generate

@dataclass
class Employee:
id: int
birthday: date
last_access: datetime
password: str
number_plates: List[int]
name: str = 'Carlos Sánchez'

employee = generate(Employee)()
print(employee)
```

It will show something like this:

```python
Employee(id=5809893100, birthday=datetime.date(559, 3, 6), last_access=datetime.datetime(1053, 8, 29, 19, 11, 14), password="iFZ>?)V0'", number_plates=[85863115, 3528889142, 2818728907, 6043092538, 4985672707], name='Carlos Sánchez')
```

`generate` function can be called with `to_json` or `to_dict`
boolean pararameters to return json or dict
representation respectively:

```python
class AreaOfCompany(BaseModel):
enable: bool
riskOwner: str
description: str
name: str
code: str

print(fistro.generate(AreaOfCompany, as_dict=True))
```

>>> {'enable': True, 'riskOwner': 'LqPqS\x0c{kZ', 'description': 'k1917GvOV', 'name': '`;ORxzQ7i', 'code': 'w2 |P\rEps'}

```python
print(fistro.generate(AreaOfCompany, as_json=True))
```

>>> {"enable": true, "riskOwner": "h@Ij34u?H", "description": ",R,G%0