Skip to content

Commit a4b592f

Browse files
committed
fix(ci): restore unit test stability and lint compliance
1 parent 5f34f05 commit a4b592f

6 files changed

Lines changed: 30 additions & 24 deletions

File tree

src/lerim/agents/tools.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,21 @@ def prune_history_processor(
10651065
return messages
10661066

10671067

1068+
# Test/compat helper: construct a minimal context wrapper exposing ctx.deps.
1069+
def build_test_ctx(
1070+
memory_root: Path,
1071+
trace_path: Path | None = None,
1072+
run_folder: Path | None = None,
1073+
):
1074+
"""Return a lightweight RunContext-like object for direct tool calls in tests."""
1075+
deps = ExtractDeps(
1076+
memory_root=Path(memory_root),
1077+
trace_path=Path(trace_path) if trace_path else None,
1078+
run_folder=Path(run_folder) if run_folder else None,
1079+
)
1080+
return SimpleNamespace(deps=deps)
1081+
1082+
10681083
# ── Legacy compatibility shim (DSPy maintain/ask agents only) ────────────
10691084

10701085

src/lerim/server/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ def api_queue_jobs(
862862
selected = _resolve_selected_projects(
863863
config=config, scope="project", project=project
864864
)
865-
except ValueError as exc:
865+
except ValueError:
866866
# Backward-compatible fallback for HTTP/API callers that still
867867
# pass free-form project substrings.
868868
selected = []

tests/unit/test_agent.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from __future__ import annotations
44

55
from dataclasses import replace
6-
from types import SimpleNamespace
7-
86
import httpx
97
import pytest
108
from openai import RateLimitError

tests/unit/test_extract_single_pass.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import inspect
1515
from dataclasses import fields
16-
from pathlib import Path
1716

1817
from pydantic_ai.models.test import TestModel
1918

@@ -26,15 +25,11 @@
2625
)
2726
from lerim.agents.tools import (
2827
ExtractDeps,
29-
Finding,
3028
compute_request_budget,
31-
context_pressure_injector,
3229
edit,
3330
grep,
3431
note,
35-
notes_state_injector,
3632
prune,
37-
prune_history_processor,
3833
read,
3934
verify_index,
4035
write,

tests/unit/test_runtime_orchestrator.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ def call(model):
114114
assert seen == ["primary"]
115115

116116
def test_retry_transient_error_same_model(self, tmp_path, monkeypatch):
117-
import lerim.server.runtime as runtime_mod
118-
119117
monkeypatch.setattr(time, "sleep", lambda *_: None)
120118
rt = _build_runtime(tmp_path, monkeypatch)
121119
attempts = 0

tests/unit/test_tools.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,12 +1343,12 @@ def test_low_pressure_status_only(self, tmp_path):
13431343
p.content for m in out
13441344
for p in m.parts if isinstance(p, SystemPromptPart)
13451345
]
1346-
assert any("CONTEXT:" in l for l in labels)
1346+
assert any("CONTEXT:" in line for line in labels)
13471347
# No pressure wording
1348-
for l in labels:
1349-
if "CONTEXT:" in l:
1350-
assert "pressure" not in l.lower()
1351-
assert "HARD" not in l
1348+
for line in labels:
1349+
if "CONTEXT:" in line:
1350+
assert "pressure" not in line.lower()
1351+
assert "HARD" not in line
13521352

13531353
def test_soft_pressure_label(self, tmp_path):
13541354
"""60-80% triggers soft pressure wording suggesting prune()."""
@@ -1366,10 +1366,10 @@ def test_soft_pressure_label(self, tmp_path):
13661366
p.content for m in messages
13671367
for p in m.parts if isinstance(p, SystemPromptPart)
13681368
]
1369-
ctx_labels = [l for l in labels if "CONTEXT:" in l]
1369+
ctx_labels = [line for line in labels if "CONTEXT:" in line]
13701370
assert ctx_labels, "Expected at least one CONTEXT: label"
1371-
assert any("soft pressure" in l for l in ctx_labels)
1372-
assert not any("HARD PRESSURE" in l for l in ctx_labels)
1371+
assert any("soft pressure" in line for line in ctx_labels)
1372+
assert not any("HARD PRESSURE" in line for line in ctx_labels)
13731373

13741374
def test_hard_pressure_label(self, tmp_path):
13751375
"""Above 80% triggers HARD PRESSURE wording demanding prune()."""
@@ -1385,9 +1385,9 @@ def test_hard_pressure_label(self, tmp_path):
13851385
p.content for m in messages
13861386
for p in m.parts if isinstance(p, SystemPromptPart)
13871387
]
1388-
ctx_labels = [l for l in labels if "CONTEXT:" in l]
1388+
ctx_labels = [line for line in labels if "CONTEXT:" in line]
13891389
assert ctx_labels
1390-
assert any("HARD PRESSURE" in l for l in ctx_labels)
1390+
assert any("HARD PRESSURE" in line for line in ctx_labels)
13911391

13921392

13931393
# ---------------------------------------------------------------------------
@@ -1414,7 +1414,7 @@ def test_empty_notes_shows_zero(self, tmp_path):
14141414
p.content for m in messages
14151415
for p in m.parts if isinstance(p, SystemPromptPart)
14161416
]
1417-
assert any("NOTES:" in l and "0 findings" in l for l in labels)
1417+
assert any("NOTES:" in line and "0 findings" in line for line in labels)
14181418

14191419
def test_notes_grouped_by_theme(self, tmp_path):
14201420
"""deps.notes with 8 findings across 3 themes produces a label listing all three."""
@@ -1438,7 +1438,7 @@ def test_notes_grouped_by_theme(self, tmp_path):
14381438
p.content for m in messages
14391439
for p in m.parts if isinstance(p, SystemPromptPart)
14401440
]
1441-
notes_line = next((l for l in labels if l.startswith("NOTES:")), None)
1441+
notes_line = next((line for line in labels if line.startswith("NOTES:")), None)
14421442
assert notes_line is not None
14431443
assert "8 findings" in notes_line
14441444
assert "3 theme" in notes_line
@@ -1465,7 +1465,7 @@ def test_reads_live_state_not_snapshot(self, tmp_path):
14651465
p.content for m in messages_1
14661466
for p in m.parts if isinstance(p, SystemPromptPart)
14671467
]
1468-
line_1 = next((l for l in labels_1 if l.startswith("NOTES:")), None)
1468+
line_1 = next((line for line in labels_1 if line.startswith("NOTES:")), None)
14691469
assert line_1 is not None
14701470
assert "1 theme" in line_1
14711471

@@ -1479,7 +1479,7 @@ def test_reads_live_state_not_snapshot(self, tmp_path):
14791479
p.content for m in messages_2
14801480
for p in m.parts if isinstance(p, SystemPromptPart)
14811481
]
1482-
line_2 = next((l for l in labels_2 if l.startswith("NOTES:")), None)
1482+
line_2 = next((line for line in labels_2 if line.startswith("NOTES:")), None)
14831483
assert line_2 is not None
14841484
assert "2 theme" in line_2
14851485
assert "theme2" in line_2

0 commit comments

Comments
 (0)