init update (#1)

Co-authored-by: Sergey Vanyushkin <pi3c@yandex.ru>
Co-committed-by: Sergey Vanyushkin <pi3c@yandex.ru>
This commit is contained in:
2026-04-25 17:47:07 +00:00
parent 9c3b44b561
commit 66ce5ae746
34 changed files with 1078 additions and 0 deletions

0
tests/unit/__init__.py Normal file
View File

18
tests/unit/conftest.py Normal file
View File

@@ -0,0 +1,18 @@
# Unit test fixtures
# Provides: mocks, stubs, isolated test data
from unittest.mock import AsyncMock, Mock
import pytest
@pytest.fixture
def mock_service():
"""Create a mock service for unit testing."""
return Mock()
@pytest.fixture
def mock_async_service():
"""Create an async mock service for unit testing."""
return AsyncMock()

View File

@@ -0,0 +1,33 @@
from contextlib import asynccontextmanager
from unittest.mock import patch
import pytest
from fastapi import FastAPI
from app.main import app_factory, lifespan, main
@pytest.mark.asyncio
async def test_lifespan():
app = FastAPI()
assert isinstance(lifespan, asynccontextmanager(lifespan).__class__)
async with lifespan(app):
pass
def test_app_factory():
app = app_factory()
assert isinstance(app, FastAPI)
assert app.router.lifespan_context == lifespan
@patch("app.main.uvicorn.run")
def test_main(mock_uvicorn_run):
main()
mock_uvicorn_run.assert_called_once_with(
app_factory,
factory=True,
host="0.0.0.0",
port=8000,
)