| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- from __future__ import annotations
- import sys
- import types
- from pathlib import Path
- from tests.conftest import (
- REPO_ROOT,
- SERVICE_IMPORT_CONFIGS,
- build_sqlite_database_url,
- prepare_known_service_import,
- )
- def test_prepare_known_service_import_resets_app_modules_and_orders_paths() -> None:
- sys.modules["app"] = types.ModuleType("app")
- sys.modules["app.fake"] = types.ModuleType("app.fake")
- prepare_known_service_import("workflow-service")
- assert "app" not in sys.modules
- assert "app.fake" not in sys.modules
- assert sys.path[0] == str(REPO_ROOT / "services" / "workflow-service")
- assert str(REPO_ROOT / "libs" / "core-dsl" / "src") in sys.path
- def test_service_import_configs_cover_services_with_database_tests() -> None:
- assert "runtime-service" in SERVICE_IMPORT_CONFIGS
- assert "workflow-service" in SERVICE_IMPORT_CONFIGS
- assert "core-db" in SERVICE_IMPORT_CONFIGS["runtime-service"].libs
- assert "core-dsl" in SERVICE_IMPORT_CONFIGS["workflow-service"].libs
- def test_build_sqlite_database_url_uses_tmp_path(tmp_path: Path) -> None:
- database_url = build_sqlite_database_url(tmp_path, "service.db")
- assert database_url.startswith("sqlite:///")
- assert str(tmp_path / "service.db") in database_url
- def test_gitlab_ci_installs_services_used_by_tests() -> None:
- ci_text = (REPO_ROOT / ".gitlab-ci.yml").read_text(encoding="utf-8")
- assert "pip install -e libs/core-dsl" in ci_text
- assert "pip install -e services/workflow-service" in ci_text
- assert "pip install -e services/runtime-service" in ci_text
|