test_test_harness.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from __future__ import annotations
  2. import sys
  3. import types
  4. from pathlib import Path
  5. from tests.conftest import (
  6. REPO_ROOT,
  7. SERVICE_IMPORT_CONFIGS,
  8. build_sqlite_database_url,
  9. prepare_known_service_import,
  10. )
  11. def test_prepare_known_service_import_resets_app_modules_and_orders_paths() -> None:
  12. sys.modules["app"] = types.ModuleType("app")
  13. sys.modules["app.fake"] = types.ModuleType("app.fake")
  14. prepare_known_service_import("workflow-service")
  15. assert "app" not in sys.modules
  16. assert "app.fake" not in sys.modules
  17. assert sys.path[0] == str(REPO_ROOT / "services" / "workflow-service")
  18. assert str(REPO_ROOT / "libs" / "core-dsl" / "src") in sys.path
  19. def test_service_import_configs_cover_services_with_database_tests() -> None:
  20. assert "runtime-service" in SERVICE_IMPORT_CONFIGS
  21. assert "workflow-service" in SERVICE_IMPORT_CONFIGS
  22. assert "core-db" in SERVICE_IMPORT_CONFIGS["runtime-service"].libs
  23. assert "core-dsl" in SERVICE_IMPORT_CONFIGS["workflow-service"].libs
  24. def test_build_sqlite_database_url_uses_tmp_path(tmp_path: Path) -> None:
  25. database_url = build_sqlite_database_url(tmp_path, "service.db")
  26. assert database_url.startswith("sqlite:///")
  27. assert str(tmp_path / "service.db") in database_url
  28. def test_gitlab_ci_installs_services_used_by_tests() -> None:
  29. ci_text = (REPO_ROOT / ".gitlab-ci.yml").read_text(encoding="utf-8")
  30. assert "pip install -e libs/core-dsl" in ci_text
  31. assert "pip install -e services/workflow-service" in ci_text
  32. assert "pip install -e services/runtime-service" in ci_text