b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
Build Skills Index / trigger-deploy (push) Waiting to run
CI / Deny unrelated histories (push) Has been skipped
CI / CI timing report (push) Blocked by required conditions
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / All required checks pass (push) Waiting to run
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
from unittest.mock import MagicMock, patch
|
|
|
|
from cli import HermesCLI
|
|
|
|
|
|
class _InsightsEngineStub:
|
|
calls = []
|
|
|
|
def __init__(self, db):
|
|
self.db = db
|
|
|
|
def generate(self, *, days=30, source=None):
|
|
self.calls.append({"days": days, "source": source})
|
|
return {"days": days, "source": source}
|
|
|
|
def format_terminal(self, report):
|
|
return f"days={report['days']} source={report['source']}"
|
|
|
|
|
|
def _run_show_insights(command: str):
|
|
cli_obj = HermesCLI.__new__(HermesCLI)
|
|
db = MagicMock()
|
|
_InsightsEngineStub.calls = []
|
|
with patch("hermes_state.SessionDB", return_value=db), \
|
|
patch("agent.insights.InsightsEngine", _InsightsEngineStub):
|
|
cli_obj._show_insights(command)
|
|
return _InsightsEngineStub.calls, db
|
|
|
|
|
|
def test_cli_insights_accepts_positional_days(capsys):
|
|
calls, db = _run_show_insights("/insights 7")
|
|
|
|
assert calls == [{"days": 7, "source": None}]
|
|
db.close.assert_called_once()
|
|
assert "days=7 source=None" in capsys.readouterr().out
|
|
|
|
|
|
def test_cli_insights_keeps_days_flag_and_source(capsys):
|
|
calls, db = _run_show_insights("/insights --days 14 --source discord")
|
|
|
|
assert calls == [{"days": 14, "source": "discord"}]
|
|
db.close.assert_called_once()
|
|
assert "days=14 source=discord" in capsys.readouterr().out
|