test_start_scripts.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from __future__ import annotations
  2. import os
  3. import subprocess
  4. import sys
  5. from pathlib import Path
  6. def test_legacy_start_scripts_removed() -> None:
  7. project_root = Path("/home/sophomores/zhuce6")
  8. assert not (project_root / "scripts/start_register_loop.sh").exists()
  9. assert not (project_root / "scripts/start_register_burst_scheduler.sh").exists()
  10. assert not (project_root / "scripts/start_dashboard.sh").exists()
  11. assert not (project_root / "scripts/start_full_stack.sh").exists()
  12. assert not (project_root / "scripts/_common.sh").exists()
  13. assert not (project_root / "start_register.sh").exists()
  14. def test_main_module_bootstraps_env_file_on_import(tmp_path: Path) -> None:
  15. env_file = tmp_path / "test.env"
  16. env_file.write_text("ZHUCE6_TEST_VAR=hello\n", encoding="utf-8")
  17. env = os.environ.copy()
  18. env["ZHUCE6_ENV_FILE"] = str(env_file)
  19. env["PYTHONPATH"] = "/home/sophomores/zhuce6"
  20. result = subprocess.run(
  21. [
  22. sys.executable,
  23. "-c",
  24. (
  25. "import os, sys; "
  26. "sys.argv=['main.py','status']; "
  27. "import main; "
  28. "print(os.environ.get('ZHUCE6_TEST_VAR'))"
  29. ),
  30. ],
  31. capture_output=True,
  32. text=True,
  33. env=env,
  34. check=True,
  35. )
  36. assert result.stdout.strip().endswith("hello")