https://github.com/kuzxnia/async_factory_boy
factory_boy extension with asynchronous ORM support
https://github.com/kuzxnia/async_factory_boy
factory-boy python testing unit-testing
Last synced: 5 months ago
JSON representation
factory_boy extension with asynchronous ORM support
- Host: GitHub
- URL: https://github.com/kuzxnia/async_factory_boy
- Owner: kuzxnia
- License: mit
- Created: 2022-09-02T11:37:34.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-12T16:31:54.000Z (about 2 years ago)
- Last Synced: 2025-09-30T03:16:14.292Z (9 months ago)
- Topics: factory-boy, python, testing, unit-testing
- Language: Python
- Homepage: https://pypi.org/project/async-factory-boy/
- Size: 23.4 KB
- Stars: 24
- Watchers: 2
- Forks: 10
- Open Issues: 6
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
async_factory_boy
=================
`factory_boy `__ extension
with asynchronous ORM support
Requirements
------------
- python (3.8, 3.9, 3.10)
Instalation
-----------
Install using ``pip``
::
pip install async_factory_boy
Usage
-----
async_factory_boy integrate with Object Relational Mapping (ORM) through
subclass of ``factory.Factory``. All supported are listed below.
- SQLAlchemy, with
``async_factory_boy.factory.sqlalchemy.AsyncSQLAlchemyFactory``
.. code:: python
from async_factory_boy.factory.sqlalchemy import AsyncSQLAlchemyFactory
class TestModelFactory(AsyncSQLAlchemyFactory):
class Meta:
model = TestModel
session = session
name = Faker("name")
created_at = Faker("date_time")
- Tortoise ORM, with
``async_factory_boy.factory.tortoise.AsyncTortoiseFactory``
.. code:: python
from async_factory_boy.factory.tortoise import AsyncTortoiseFactory
class TestModelFactory(AsyncTortoiseFactory):
class Meta:
model = TestModel
name = Faker("name")
created_at = Faker("date_time")
and factory usage
.. code:: python
test = await TestModelFactory.create()
test = await TestModelFactory.build()
For test configuration examples check ``tests/`` directory.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^