mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-08-27 14:17:10 -04:00
fix(tests): patch headroom.rtk.get_rtk_path, not the helpers alias
CI failed on `test_rtk_subprocess_failure_logs_structured_warning` because the test patched `headroom.proxy.helpers.get_rtk_path` but `_read_rtk_lifetime_stats` does a LOCAL import (`from headroom.rtk import get_rtk_path`) inside the function body — so the patched attribute on `helpers` was never read. In CI (no rtk installed), the LOCAL import returned `None`, the function took the early-return branch, and the structured warning the test expected was never emitted. Fix: patch `headroom.rtk.get_rtk_path` directly so the local import returns the test's stub. The subprocess.run patch then takes effect, the fake non-zero exit triggers the `event=rtk_stats_subprocess_failed` warning, and the assertion holds. Pure test-side fix; production code unchanged.
This commit is contained in:
parent
f68090c5b4
commit
317dffe58f
1 changed files with 5 additions and 8 deletions
|
|
@ -560,16 +560,13 @@ def test_rtk_subprocess_failure_logs_structured_warning(
|
|||
|
||||
import subprocess as _subprocess
|
||||
|
||||
# `_read_rtk_lifetime_stats` does a LOCAL import: `from headroom.rtk
|
||||
# import get_rtk_path`. That means patching the alias on `helpers`
|
||||
# doesn't bind — we must patch the source module.
|
||||
import headroom.rtk as _rtk
|
||||
from headroom.proxy import helpers as _helpers
|
||||
|
||||
monkeypatch.setattr(_helpers, "get_rtk_path", lambda: None, raising=False)
|
||||
|
||||
# The above branch returns early before invoking subprocess — not the
|
||||
# one we want. Instead, force the subprocess to fail.
|
||||
monkeypatch.setattr(
|
||||
"headroom.proxy.helpers.get_rtk_path",
|
||||
lambda: "/tmp/nonexistent-rtk",
|
||||
)
|
||||
monkeypatch.setattr(_rtk, "get_rtk_path", lambda: "/tmp/nonexistent-rtk")
|
||||
|
||||
class FakeResult:
|
||||
returncode = 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue