Files
headquarter/apps/api/tests/unit/test_migration_metadata.py
T
alex 22c035984e feat: add config profiles data model and migrations
- Add ConfigProfile model with user ownership, name, description
- Add ConfigInclude model for ordered profile self-references
- Add ConfigMount model for mount/file definitions
- Add selected_profile_id to ToolInstance for per-instance profile selection
- Add default profile properties to UserConfig JSONB config
- Create Alembic migration 0013 for new tables and columns
- Register new models in models/__init__.py
- Mark config_folders.is_active as deprecated
- Add migration metadata test

Quality gates: syntax check passed (all files parse successfully)
OpenSpec: add-config-profiles task 1.1
2026-05-24 12:54:45 +00:00

57 lines
1.7 KiB
Python

import pytest
from importlib.util import module_from_spec, spec_from_file_location
from pathlib import Path
@pytest.mark.unit
def test_initial_migration_defines_all_core_tables() -> None:
migration_path = Path(__file__).resolve().parents[2] / "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",
]
@pytest.mark.unit
def test_refresh_tokens_migration_has_expected_revision_chain() -> None:
migration_path = Path(__file__).resolve().parents[2] / "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"
@pytest.mark.unit
def test_config_profiles_migration_has_expected_revision_chain() -> None:
migration_path = Path(__file__).resolve().parents[2] / "alembic" / "versions" / "0013_add_config_profiles.py"
spec = spec_from_file_location("add_config_profiles", 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 == "0013_add_config_profiles"
assert module.down_revision == "0012_default_port_req"