From 76ff0c658777b673883cbd7f5d966855c6a32af2 Mon Sep 17 00:00:00 2001 From: claude-bot Date: Fri, 15 May 2026 17:05:46 +0300 Subject: [PATCH] feat: add pyproject.toml, dev dependencies, first unit test --- .gitea/workflows/ci.yml | 23 +++++++++++------------ pyproject.toml | 37 +++++++++++++++++++++++++++++++++++++ tests/__init__.py | 0 tests/unit/__init__.py | 0 tests/unit/test_health.py | 13 +++++++++++++ 5 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 pyproject.toml create mode 100644 tests/__init__.py create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/test_health.py diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 5c56a0b..9c4a761 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -8,28 +8,27 @@ on: jobs: lint: runs-on: ubuntu-latest + container: + image: python:3.12 steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - run: pip install ruff - - run: ruff check src/api/ + - run: pip install -e ".[dev]" + - run: ruff check src/ test: runs-on: ubuntu-latest + container: + image: python:3.12 steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - run: pip install -r src/api/requirements.txt - - run: pip install pytest - - run: pytest tests/ -v + - run: pip install -e ".[dev]" + - run: pytest tests/ build: runs-on: ubuntu-latest + container: + image: python:3.12 needs: [lint, test] steps: - uses: actions/checkout@v4 - - run: docker build -t enduro-trails:ci . + - run: docker build . diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ce1f77c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,37 @@ +[project] +name = "enduro-trails" +version = "0.1.0" +requires-python = ">=3.12" +description = "Карта эндуро-маршрутов с рельефом, навигацией и слоями terrain/TRI/hillshade" +readme = "README.md" +dependencies = [ + "fastapi==0.111.0", + "uvicorn==0.29.0", + "shapely==2.0.4", + "mapbox-vector-tile==2.2.0", + "httpx==0.27.0", +] + +[project.optional-dependencies] +dev = [ + "ruff>=0.4.0", + "pytest>=8.0", + "httpx>=0.27", + "pytest-asyncio>=0.23", +] + +[build-system] +requires = ["setuptools>=68", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +where = ["."] +include = ["src*"] + +[tool.ruff] +target-version = "py312" +line-length = 120 + +[tool.pytest.ini_options] +asyncio_mode = "auto" +testpaths = ["tests"] diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/test_health.py b/tests/unit/test_health.py new file mode 100644 index 0000000..1435507 --- /dev/null +++ b/tests/unit/test_health.py @@ -0,0 +1,13 @@ +import pytest +from httpx import AsyncClient, ASGITransport +from src.api.main import app + + +@pytest.mark.asyncio +async def test_health_endpoint(): + transport = ASGITransport(app=app) + async with AsyncClient(transport=transport, base_url="http://test") as client: + resp = await client.get("/api/health") + assert resp.status_code == 200 + data = resp.json() + assert data["status"] == "ok"