feat: restructure test infrastructure with unit/integration/system separation

Test Organization:
- Create tests/unit/, tests/integration/, tests/system/ directories
- Move existing tests into appropriate categories
- Add pytest markers (@pytest.mark.unit, @pytest.mark.integration)

Shared Fixtures:
- Create conftest.py with SQLite engine (for unit tests)
- Add PostgreSQL session fixture with transaction rollback
- Add TestClient fixture for API tests

Configuration:
- Update pyproject.toml with asyncio_mode=auto
- Add test markers and default addopts
- Add aiosqlite dependency for SQLite support

E2E Testing:
- Initialize Playwright in e2e/ directory
- Add playwright.config.ts
- Create login flow E2E test

Build:
- Add test-unit, test-integration, test-system, test-e2e to Makefile
- Update test target to run all categories
- Add testing documentation to README

Note: Some tests have import issues due to missing python-jose
package in dev environment. This needs to be addressed separately.
This commit is contained in:
Fusion
2026-05-18 15:00:33 +02:00
parent a441ea2fac
commit 3ccd94f661
26 changed files with 627 additions and 11 deletions
+31 -11
View File
@@ -1,18 +1,22 @@
.PHONY: help up down logs migrate test lint clean build
.PHONY: help up down logs migrate test test-unit test-integration test-system test-e2e lint clean build
# Default target
help:
@echo "Headquarter Development Commands"
@echo "================================"
@echo "make up - Start all services"
@echo "make down - Stop all services"
@echo "make logs - View service logs"
@echo "make migrate - Run database migrations"
@echo "make test - Run test suites"
@echo "make lint - Run linting"
@echo "make build - Build all Docker images"
@echo "make clean - Remove containers and volumes"
@echo "make shell - Open shell in API container"
@echo "make up - Start all services"
@echo "make down - Stop all services"
@echo "make logs - View service logs"
@echo "make migrate - Run database migrations"
@echo "make test - Run all test suites"
@echo "make test-unit - Run unit tests only"
@echo "make test-integration - Run integration tests only"
@echo "make test-system - Run system tests only"
@echo "make test-e2e - Run E2E tests (Playwright)"
@echo "make lint - Run linting"
@echo "make build - Build all Docker images"
@echo "make clean - Remove containers and volumes"
@echo "make shell - Open shell in API container"
# Start services
up:
@@ -49,10 +53,26 @@ migrate:
migration:
docker compose exec api alembic revision --autogenerate -m "$(message)"
# Run tests
# Run all tests
test:
docker compose exec api pytest -v
# Run unit tests only (fast, no external dependencies)
test-unit:
docker compose exec api pytest -v -m unit tests/unit/
# Run integration tests only (requires database)
test-integration:
docker compose exec api pytest -v -m integration tests/integration/
# Run system tests only (full stack)
test-system:
docker compose exec api pytest -v -m system tests/system/
# Run E2E tests (requires full application stack)
test-e2e:
cd e2e && npx playwright test
# Run linting
lint:
docker compose exec api ruff check .