add tests and docker infra

This commit is contained in:
ivankirpichnikov
2025-10-17 02:21:46 +03:00
parent 31d06fc0b4
commit 45d7926af1
24 changed files with 806 additions and 24 deletions
@@ -8,13 +8,13 @@ from template_project.web_api.configuration import DatabaseConfiguration
class ConnectionProvider(Provider):
@provide(scope=Scope.APP)
async def make_engine(self, configuration: DatabaseConfiguration) -> AsyncIterable[AsyncEngine]:
async def engine(self, configuration: DatabaseConfiguration) -> AsyncIterable[AsyncEngine]:
engine = create_async_engine(configuration.url.get_value())
yield engine
await engine.dispose()
@provide()
async def make_connection(self, engine: AsyncEngine) -> AsyncIterable[AsyncSession]:
@provide(scope=Scope.REQUEST)
async def async_session(self, engine: AsyncEngine) -> AsyncIterable[AsyncSession]:
session = AsyncSession(
bind=engine,
expire_on_commit=True,