Files
hermes-webui/tests/test_cli_entry_point.py
T
69d5647b60 Batch release exp-v0.52.237 — profile goal isolation (#6899) + hermes-webui entry point (#6742) (#7108)
* fix(goals): delegate profile evaluation to native manager

Use Hermes' context-local home override to run profile-scoped goal operations through the native GoalManager, preserving current judge, wait, and failure semantics while retaining the explicit-DB legacy fallback.

* docs(goals): describe profile ownership boundary

* fix(goals): gate native profile persistence capability

* feat(cli): add packaged hermes-webui CLI entry point (#6739)

* fix(cli): route hermes-webui entry through bootstrap:main for wheel install (#6742)

* docs(changelog): note #6899 profile goal isolation + #6742 hermes-webui entry point

* test(goals): guard hermes_cli import with importorskip for CI (agent not installed)

#6899's native-contract tests imported hermes_cli unconditionally, failing
CI with ModuleNotFoundError. Match the repo's established importorskip pattern
so they skip cleanly when the agent isn't installed and run when it is.
Co-authored-by: ticketclosed-wontfix

---------

Co-authored-by: Nick <202622897+ticketclosed-wontfix@users.noreply.github.com>
Co-authored-by: webtecnica <webtecnica@gmail.com>
Co-authored-by: n <a@n>
2026-08-17 10:45:59 +00:00

65 lines
2.3 KiB
Python

"""Smoke tests for the packaged ``hermes-webui`` CLI entry point (#6739).
The console script is declared in ``pyproject.toml`` under
``[project.scripts]`` and must keep resolving to ``bootstrap.main`` — the
bootstrap entry point runs launcher-python discovery and dep-ensure before
launching the server, matching the effective behavior of
``python server.py`` / ``python -m server``. These tests
guard the wiring without booting a real server:
1. The console script is declared in the packaging metadata.
2. The declared target (``bootstrap:main``) actually resolves to a callable.
3. When the package is installed in the test environment (e.g. CI editable
install), the real ``importlib.metadata`` entry point resolves end-to-end.
"""
from __future__ import annotations
import importlib
import importlib.metadata
import os
import tomllib
import pytest
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
EXPECTED_SCRIPT = "hermes-webui"
EXPECTED_TARGET = "bootstrap:main"
def _pyproject_scripts() -> dict:
"""Parse the [project.scripts] table from pyproject.toml."""
with open(os.path.join(REPO_ROOT, "pyproject.toml"), "rb") as fh:
pyproject = tomllib.load(fh)
return dict(pyproject.get("project", {}).get("scripts", {}))
def test_console_script_declared_in_pyproject():
"""The packaged CLI entry point is declared and maps to bootstrap.main."""
scripts = _pyproject_scripts()
assert scripts.get(EXPECTED_SCRIPT) == EXPECTED_TARGET
def test_console_script_target_resolves_to_callable():
"""The declared module:attr target imports and is callable."""
module_name, _, attr = EXPECTED_TARGET.partition(":")
module = importlib.import_module(module_name)
target = getattr(module, attr)
assert callable(target)
def _installed_entry_point():
"""Return the installed hermes-webui console-script EntryPoint, or None."""
selected = importlib.metadata.entry_points().select(
group="console_scripts", name=EXPECTED_SCRIPT
)
return selected[0] if selected else None
def test_installed_entry_point_wiring():
"""When installed, the console script must resolve to bootstrap.main."""
ep = _installed_entry_point()
if ep is None:
pytest.skip("hermes-webui not installed in this test environment")
assert ep.value == EXPECTED_TARGET
assert callable(ep.load())