Skip to content

Commit 9d5c3c5

Browse files
committed
Fixtures and pytest config cleanup
1 parent 44eed24 commit 9d5c3c5

File tree

8 files changed

+39
-248
lines changed

8 files changed

+39
-248
lines changed

tests/conftest.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import inspect
22
import os
33
from contextlib import _AsyncGeneratorContextManager, asynccontextmanager
4-
from typing import Tuple, Type
4+
from typing import Tuple, Type, Union
55
from uuid import uuid4
66

77
import pytest
88
from sqlalchemy import Column, ForeignKey, Integer, String
99
from sqlalchemy.orm import clear_mappers, relationship
1010

1111
from sqlalchemy_bind_manager import SQLAlchemyAsyncConfig, SQLAlchemyConfig
12-
from sqlalchemy_bind_manager._bind_manager import SQLAlchemyBind, SQLAlchemyBindManager
12+
from sqlalchemy_bind_manager._bind_manager import (
13+
SQLAlchemyAsyncBind,
14+
SQLAlchemyBind,
15+
SQLAlchemyBindManager,
16+
)
17+
from sqlalchemy_bind_manager._repository import (
18+
SQLAlchemyAsyncRepository,
19+
SQLAlchemyRepository,
20+
)
21+
from sqlalchemy_bind_manager._session_handler import AsyncSessionHandler, SessionHandler
22+
from sqlalchemy_bind_manager.repository import AsyncUnitOfWork, UnitOfWork
1323

1424

1525
@pytest.fixture
@@ -148,3 +158,30 @@ class ChildModel(sa_bind.model_declarative_base):
148158
@pytest.fixture
149159
async def model_class(model_classes: Tuple[Type, Type]) -> Type:
150160
return model_classes[0]
161+
162+
163+
@pytest.fixture
164+
def session_handler_class(sa_bind):
165+
return (
166+
AsyncSessionHandler
167+
if isinstance(sa_bind, SQLAlchemyAsyncBind)
168+
else SessionHandler
169+
)
170+
171+
172+
@pytest.fixture
173+
def repository_class(
174+
sa_bind: Union[SQLAlchemyBind, SQLAlchemyAsyncBind]
175+
) -> Type[Union[SQLAlchemyAsyncRepository, SQLAlchemyRepository]]:
176+
base_class = (
177+
SQLAlchemyRepository
178+
if isinstance(sa_bind, SQLAlchemyBind)
179+
else SQLAlchemyAsyncRepository
180+
)
181+
182+
return base_class
183+
184+
185+
@pytest.fixture
186+
def uow_class(sa_bind):
187+
return AsyncUnitOfWork if isinstance(sa_bind, SQLAlchemyAsyncBind) else UnitOfWork

tests/repository/conftest.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

tests/session_handler/conftest.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/unit_of_work/async_/__init__.py

Whitespace-only changes.

tests/unit_of_work/async_/conftest.py

Lines changed: 0 additions & 72 deletions
This file was deleted.

tests/unit_of_work/conftest.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/unit_of_work/sync/__init__.py

Whitespace-only changes.

tests/unit_of_work/sync/conftest.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)