Тестовое задаине в файле Тестовое задание Backend python.docx
Настройки лежат в .env. Для локального запуска укажите DATABASE_URL с хостом localhost, например:
DATABASE_URL=postgresql+asyncpg://app:app@localhost:5432/app
API ключ задается через API_KEY и передается в заголовке X-API-Key.
docker compose up -d db adminerЗапуск приложения fastapi (или запустите run_dev.py в режиме отладки)
uv sync
uvicorn app.main:app --reloadДалее миграция, наполнение тестовыми данными
uv run alembic upgrade head
uv run python -m app.seedПроверить путь к базе в настройках .env.
DATABASE_URL=postgresql+asyncpg://app:app@db:5432/app
docker compose up -dЗапуск сидирования внутри контейнера:
docker compose exec -T api /bin/sh -c ". /app/.venv/bin/activate && python -m app.seed"Рекомендуемый способ — использовать файл tests/test_endpoints.http.
Базовый URL: http://localhost:8000
GET /health— проверка доступности
iwr http://localhost:8000/health -Headers @{ "X-API-Key" = "changeme" }GET /buildings— список зданий
iwr http://localhost:8000/buildings -Headers @{ "X-API-Key" = "changeme" }GET /organizations/{organization_id}— информация об организации
iwr http://localhost:8000/organizations/1 -Headers @{ "X-API-Key" = "changeme" }GET /organizations/by-building/{building_id}— организации в здании
iwr http://localhost:8000/organizations/by-building/1 -Headers @{ "X-API-Key" = "changeme" }GET /organizations/by-activity/{activity_id}— организации по виду деятельности
iwr http://localhost:8000/organizations/by-activity/2 -Headers @{ "X-API-Key" = "changeme" }GET /organizations/by-activity-tree/{activity_id}— организации по дереву деятельности
iwr http://localhost:8000/organizations/by-activity-tree/1 -Headers @{ "X-API-Key" = "changeme" }GET /organizations/by-activity-name?name=&include_children=— поиск по названию деятельности
iwr "http://localhost:8000/organizations/by-activity-name?name=Еда&include_children=true" -Headers @{ "X-API-Key" = "changeme" }GET /organizations/search?name=— поиск организаций по названию
iwr "http://localhost:8000/organizations/search?name=Авто" -Headers @{ "X-API-Key" = "changeme" }GET /organizations/near?lat=&lon=&radius_km=— организации в радиусе
iwr "http://localhost:8000/organizations/near?lat=55.76&lon=37.63&radius_km=10" -Headers @{ "X-API-Key" = "changeme" }GET /organizations/within-rect?min_lat=&max_lat=&min_lon=&max_lon=— организации в прямоугольной области
iwr "http://localhost:8000/organizations/within-rect?min_lat=55.7&max_lat=55.8&min_lon=37.5&max_lon=37.7" -Headers @{ "X-API-Key" = "changeme" }Swagger UI доступен по /docs, Redoc — по /redoc.
pytest