3ccd94f661
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.
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
import pytest
|
|
|
|
from importlib.util import module_from_spec, spec_from_file_location
|
|
from pathlib import Path
|
|
|
|
|
|
n@pytest.mark.unit
|
|
|
|
def test_initial_migration_defines_all_core_tables() -> None:
|
|
migration_path = Path(__file__).resolve().parents[1] / "alembic" / "versions" / "0001_initial_schema.py"
|
|
spec = spec_from_file_location("initial_schema", migration_path)
|
|
|
|
assert spec is not None
|
|
assert spec.loader is not None
|
|
|
|
module = module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
|
|
assert module.TABLE_NAMES == [
|
|
"users",
|
|
"ssh_keys",
|
|
"projects",
|
|
"git_repositories",
|
|
"user_configs",
|
|
]
|
|
|
|
|
|
n@pytest.mark.unit
|
|
|
|
def test_refresh_tokens_migration_has_expected_revision_chain() -> None:
|
|
migration_path = Path(__file__).resolve().parents[1] / "alembic" / "versions" / "0002_refresh_tokens.py"
|
|
spec = spec_from_file_location("refresh_tokens", migration_path)
|
|
|
|
assert spec is not None
|
|
assert spec.loader is not None
|
|
|
|
module = module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
|
|
assert module.revision == "0002_refresh_tokens"
|
|
assert module.down_revision == "0001_initial_schema"
|