from contextlib import AbstractAsyncContextManager as AsyncContextManager
from typing import Any

from server.config import AppConfig
from server.infra.db.abc import AbstractDB, AbstractSession


class MockBeginSession(AbstractSession):
    async def __aenter__(self):
        pass

    async def __aexit__(self, exc_type, exc, tb):
        pass


class MockSession(AbstractSession):
    async def __aenter__(self) -> "AbstractSession":
        return self

    async def __aexit__(self, exc_type, exc, tb):
        pass

    def begin(self) -> AsyncContextManager:
        return MockBeginSession()

    async def execute(self, data: Any):
        pass

    async def commit(self):
        pass


class MockDB(AbstractDB):
    """Mock realiztion for DB"""

    def __init__(self, cnf: AppConfig):
        pass

    async def __aenter__(self):
        pass

    async def __aenxit__(self, exc_type, exc, tb):
        pass

    def session(self) -> MockSession:
        return MockSession()
