58 lines
1.4 KiB
Python
58 lines
1.4 KiB
Python
"""Common test fixtures for ddd_domain package.
|
|
|
|
This file provides base fixtures for database integration tests.
|
|
Developers can add schema-specific or table-specific fixtures by creating
|
|
conftest.py files in the appropriate subdirectories.
|
|
|
|
Generated by half_orm v1.0.0-a32
|
|
"""
|
|
import pytest
|
|
import pytest_asyncio
|
|
from half_orm.relation import Relation
|
|
from ddd_domain import MODEL, aconnect, adisconnect
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def database_model():
|
|
"""
|
|
Provide database Model for integration tests (sync).
|
|
|
|
Scope: session (created once per test session)
|
|
Returns: Model instance for ddd_domain database
|
|
|
|
Example:
|
|
def test_query(database_model):
|
|
users = database_model.get_relation_class('public.users')
|
|
assert users is not None
|
|
"""
|
|
return MODEL
|
|
|
|
|
|
@pytest.fixture
|
|
def relation_class():
|
|
"""
|
|
Provide Relation base class for tests.
|
|
|
|
Returns: half_orm.relation.Relation class
|
|
|
|
Example:
|
|
def test_inheritance(relation_class):
|
|
from ddd_domain.public.users import Users
|
|
assert issubclass(Users, relation_class)
|
|
"""
|
|
return Relation
|
|
|
|
|
|
@pytest_asyncio.fixture(scope="session", autouse=True)
|
|
async def _async_pool():
|
|
"""Establish and tear down the async connection pool for the test session."""
|
|
await aconnect()
|
|
yield
|
|
await adisconnect()
|
|
|
|
|
|
try:
|
|
from .custom_conftest import *
|
|
except ImportError:
|
|
pass
|