mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-08-10 14:27:00 -04:00
test: apply linux ruff formatting
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
cbd21a2880
commit
a5a4486a30
7 changed files with 34 additions and 26 deletions
|
|
@ -199,9 +199,11 @@ def test_tools_install_covers_unknown_pypi_force_and_failures(
|
|||
monkeypatch.setattr(
|
||||
cli_tools.binaries,
|
||||
"resolve",
|
||||
lambda name: (_ for _ in ()).throw(binaries.OfflineError("offline"))
|
||||
if name == "broken"
|
||||
else Path(f"C:\\cache\\{name}.exe"),
|
||||
lambda name: (
|
||||
(_ for _ in ()).throw(binaries.OfflineError("offline"))
|
||||
if name == "broken"
|
||||
else Path(f"C:\\cache\\{name}.exe")
|
||||
),
|
||||
)
|
||||
|
||||
result = runner.invoke(
|
||||
|
|
|
|||
|
|
@ -895,8 +895,9 @@ async def test_memory_handler_misc_helpers(monkeypatch: pytest.MonkeyPatch, tmp_
|
|||
__import__("sys").modules,
|
||||
"headroom.memory.tools",
|
||||
SimpleNamespace(
|
||||
get_memory_tools_optimized=lambda: calls.__setitem__("count", calls["count"] + 1)
|
||||
or [{"name": "tool"}]
|
||||
get_memory_tools_optimized=lambda: (
|
||||
calls.__setitem__("count", calls["count"] + 1) or [{"name": "tool"}]
|
||||
)
|
||||
),
|
||||
)
|
||||
cache_handler = MemoryHandler(MemoryConfig(enabled=False), agent_type="codex")
|
||||
|
|
|
|||
|
|
@ -159,8 +159,9 @@ def test_wrapped_completions_create_injects_parses_and_stores(
|
|||
)
|
||||
monkeypatch.setattr(
|
||||
"headroom.memory.wrapper.inject_memory_instruction",
|
||||
lambda messages, short=True: messages
|
||||
+ [{"role": "system", "content": "memory-instruction"}],
|
||||
lambda messages, short=True: (
|
||||
messages + [{"role": "system", "content": "memory-instruction"}]
|
||||
),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"headroom.memory.wrapper.parse_response_with_memory",
|
||||
|
|
|
|||
|
|
@ -39,14 +39,16 @@ def test_discover_pipeline_extensions_handles_load_and_init_failures(
|
|||
monkeypatch.setattr(
|
||||
importlib.metadata,
|
||||
"entry_points",
|
||||
lambda group=None: [
|
||||
FakeEntryPoint("working-instance", WorkingExtension()),
|
||||
FakeEntryPoint("working-class", WorkingExtension),
|
||||
FakeEntryPoint("bad-load", RuntimeError("bad load")),
|
||||
FakeEntryPoint("bad-init", NeedsInit),
|
||||
]
|
||||
if group == ENTRY_POINT_GROUP
|
||||
else [],
|
||||
lambda group=None: (
|
||||
[
|
||||
FakeEntryPoint("working-instance", WorkingExtension()),
|
||||
FakeEntryPoint("working-class", WorkingExtension),
|
||||
FakeEntryPoint("bad-load", RuntimeError("bad load")),
|
||||
FakeEntryPoint("bad-init", NeedsInit),
|
||||
]
|
||||
if group == ENTRY_POINT_GROUP
|
||||
else []
|
||||
),
|
||||
)
|
||||
|
||||
discovered = discover_pipeline_extensions()
|
||||
|
|
|
|||
|
|
@ -836,12 +836,14 @@ async def test_handle_google_batch_create_covers_passthrough_revert_and_store_fa
|
|||
|
||||
pipeline_calls: list[dict[str, object]] = []
|
||||
handler.openai_pipeline = SimpleNamespace(
|
||||
apply=lambda **kwargs: pipeline_calls.append(kwargs)
|
||||
or SimpleNamespace(
|
||||
messages=[{"role": "user", "content": "inflated"}],
|
||||
timing={},
|
||||
tokens_before=40,
|
||||
tokens_after=80,
|
||||
apply=lambda **kwargs: (
|
||||
pipeline_calls.append(kwargs)
|
||||
or SimpleNamespace(
|
||||
messages=[{"role": "user", "content": "inflated"}],
|
||||
timing={},
|
||||
tokens_before=40,
|
||||
tokens_after=80,
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -107,9 +107,9 @@ def test_embedding_score_and_batch_with_fake_model(monkeypatch) -> None:
|
|||
monkeypatch.setattr(
|
||||
scorer,
|
||||
"_encode",
|
||||
lambda texts: [[1.0, 0.0], [0.5, 0.5]]
|
||||
if len(texts) == 2
|
||||
else [[1.0, 0.0], [0.0, 1.0], [1.0, 0.0]],
|
||||
lambda texts: (
|
||||
[[1.0, 0.0], [0.5, 0.5]] if len(texts) == 2 else [[1.0, 0.0], [0.0, 1.0], [1.0, 0.0]]
|
||||
),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
embedding, "_cosine_similarity", lambda a, b: 0.75 if a == [1.0, 0.0] else 0.25
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ def test_create_storage_builtin_entrypoint_and_fallback(monkeypatch, tmp_path: P
|
|||
|
||||
monkeypatch.setattr(
|
||||
"importlib.metadata.entry_points",
|
||||
lambda group: [SimpleNamespace(name="other", load=lambda: (lambda url: created))],
|
||||
lambda group: [SimpleNamespace(name="other", load=lambda: lambda url: created)],
|
||||
)
|
||||
missing_ep = create_storage("custom://missing.db")
|
||||
assert isinstance(missing_ep, FakeSQLiteStorage)
|
||||
|
|
@ -289,6 +289,6 @@ def test_sqlite_storage_get_conn_reuses_connection_and_create_storage_entrypoint
|
|||
created = DummyStorage()
|
||||
monkeypatch.setattr(
|
||||
"importlib.metadata.entry_points",
|
||||
lambda group: [SimpleNamespace(name="custom", load=lambda: (lambda url: created))],
|
||||
lambda group: [SimpleNamespace(name="custom", load=lambda: lambda url: created)],
|
||||
)
|
||||
assert create_storage("custom://db") is created
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue