test_runtime_resolution.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """Keyless tests for the deepseek_harness_runtime resolution API.
  2. These never launch a runtime, so they run everywhere regardless of which
  3. bundled artifacts are present; the launch-and-boot coverage lives in
  4. ``test_bundled_runtime.py``.
  5. """
  6. from __future__ import annotations
  7. import pytest
  8. from deepseek_harness_runtime import (
  9. RUNTIME_MODE_ENV_VAR,
  10. bundled_default_config_path,
  11. bundled_package_dir,
  12. resolve_bundled_launch_args,
  13. )
  14. def test_default_config_is_shipped_with_the_package() -> None:
  15. path = bundled_default_config_path()
  16. assert path == bundled_package_dir() / "runtime" / "cordis.yml"
  17. assert "@deepseek-ai/dsh-agent-core" in path.read_text()
  18. def test_unknown_explicit_mode_fails_loud() -> None:
  19. with pytest.raises(ValueError, match="expected 'exe' or 'node'"):
  20. resolve_bundled_launch_args("bogus")
  21. def test_unknown_env_mode_fails_loud(monkeypatch: pytest.MonkeyPatch) -> None:
  22. monkeypatch.setenv(RUNTIME_MODE_ENV_VAR, "bogus")
  23. with pytest.raises(ValueError, match="expected 'exe' or 'node'"):
  24. resolve_bundled_launch_args()
  25. def test_explicit_mode_wins_over_env_mode(monkeypatch: pytest.MonkeyPatch) -> None:
  26. monkeypatch.setenv(RUNTIME_MODE_ENV_VAR, "bogus")
  27. try:
  28. args = resolve_bundled_launch_args("exe")
  29. except FileNotFoundError:
  30. return # explicit 'exe' was honored; only the artifact is missing
  31. assert args[0].endswith(("-x64", "-arm64"))