aman/tests/test_aman_entrypoint.py
Thales Maciel 4d0081d1d0 Split aman.py into focused CLI and runtime modules
Break the old god module into flat siblings for CLI parsing, run lifecycle, daemon state, shared processing helpers, benchmark tooling, and maintainer-only model sync so changes stop sharing one giant import graph.

Keep aman as a thin shim over aman_cli, move sync-default-model behind the hidden aman-maint entrypoint plus Make wrappers, and update packaging metadata plus maintainer docs to reflect the new surface.

Retarget the tests to the new seams with dedicated runtime, run, benchmark, maintainer, and entrypoint suites, and verify with python3 -m unittest discover -s tests -p "test_*.py", python3 -m py_compile src/*.py tests/*.py, PYTHONPATH=src python3 -m aman --help, PYTHONPATH=src python3 -m aman version, and PYTHONPATH=src python3 -m aman_maint --help.
2026-03-14 14:54:57 -03:00

51 lines
1.3 KiB
Python

import re
import subprocess
import sys
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SRC = ROOT / "src"
if str(SRC) not in sys.path:
sys.path.insert(0, str(SRC))
import aman
import aman_cli
class AmanEntrypointTests(unittest.TestCase):
def test_aman_module_only_reexports_main(self):
self.assertIs(aman.main, aman_cli.main)
self.assertFalse(hasattr(aman, "Daemon"))
def test_python_m_aman_version_succeeds_without_config_ui(self):
script = f"""
import builtins
import sys
sys.path.insert(0, {str(SRC)!r})
real_import = builtins.__import__
def blocked(name, globals=None, locals=None, fromlist=(), level=0):
if name == "config_ui":
raise ModuleNotFoundError("blocked config_ui")
return real_import(name, globals, locals, fromlist, level)
builtins.__import__ = blocked
import aman
raise SystemExit(aman.main(["version"]))
"""
result = subprocess.run(
[sys.executable, "-c", script],
cwd=ROOT,
text=True,
capture_output=True,
check=False,
)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertRegex(result.stdout.strip(), re.compile(r"\S+"))
if __name__ == "__main__":
unittest.main()