Files
ss-tools/agent/tests/test_agent/test_package_install.py
root 632b730fff chore: migrate GRACE-Poly anchors to hierarchical dotted naming
Systematic rename of all semantic anchors (#region, [DEF], @RELATION)
across 1400+ files — backend Python, frontend Svelte/TS, specs, docs:
- Flat anchors become Namespace.Module.Entity
- @RELATION references updated to match new anchor paths
- Zero business logic changes
2026-07-22 11:48:15 +03:00

58 lines
2.3 KiB
Python

# #region Test.AgentChat.Packaging [C:3] [TYPE Module] [SEMANTICS test,agent,packaging,entrypoint,subprocess]
# @BRIEF Verifies the installed agent package exposes the production module entry point.
# @RELATION BINDS_TO -> [EXT:Python:ModuleEntrypoint]
# @TEST_FIXTURE: installed_packages -> INLINE_JSON
# @TEST_EDGE: missing_field -> Imports resolve without agent/src added to PYTHONPATH.
# @TEST_EDGE: invalid_type -> Both shared and agent distributions are installed as packages.
# @TEST_EDGE: external_fail -> pip installation failures surface through the subprocess result.
# @RATIONALE Tests normally insert agent/src into sys.path, which can hide a broken editable or
# wheel installation even though run.sh executes python -m ss_tools.agent.run.
# @REJECTED Importing directly from agent/src was rejected because it cannot prove packaging works.
import os
from pathlib import Path
import subprocess
import sys
# #region Test.AgentChat.TestInstalledPackagesExposeAgentEntrypoint [C:2] [TYPE Function] [SEMANTICS test,agent,packaging,entrypoint]
# @BRIEF Install shared and agent distributions into an isolated target and import the entry point.
def test_installed_packages_expose_agent_entrypoint(tmp_path: Path) -> None:
"""run.sh's module entry point is available without source-tree path injection."""
repository_root = Path(__file__).parents[3]
package_target = tmp_path / "site-packages"
install = subprocess.run(
[
sys.executable,
"-m",
"pip",
"install",
"--no-deps",
"--target",
str(package_target),
str(repository_root / "shared"),
str(repository_root / "agent"),
],
cwd=tmp_path,
capture_output=True,
text=True,
check=False,
)
assert install.returncode == 0, install.stderr
environment = os.environ.copy()
environment["PYTHONPATH"] = str(package_target)
imported = subprocess.run(
[sys.executable, "-c", "import ss_tools.agent.run; import ss_tools.shared"],
cwd=tmp_path,
env=environment,
capture_output=True,
text=True,
check=False,
)
assert imported.returncode == 0, imported.stderr
# #endregion Test.AgentChat.TestInstalledPackagesExposeAgentEntrypoint
# #endregion Test.AgentChat.Packaging