test(core): add 26 edge case tests across core components - #427
Conversation
Add comprehensive edge case testing for boundary conditions and error handling across 4 core component areas: - Agent execution (7 tests): stall detector disabled states, timeout boundaries, activity reset, error propagation with edge inputs - Task management (6 tests): empty title, invalid transitions, missing tasks, empty workspace queries - Quality gates (7 tests): empty repos, unknown gates, ruff parsing, status aggregation, mixed statuses - Context management (6 tests): missing tasks, encoding fallbacks, token budget overflow, keyword extraction, relevance scoring Register `edge_case` pytest marker for targeted test selection.
WalkthroughThis PR adds comprehensive edge case testing across four core components: context management, quality gates, stall detection, and task management. It introduces a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
Code Review: Edge Case Tests (#427)Good addition — the tests are well-structured, target real v2 modules, and the docstrings clearly explain intent. A few things worth addressing: Issue 1:
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/core/test_context_edge_cases.py (1)
90-99: Consider documenting the magic numbers.The assertion
score >= 0.22is derived from0.1 + 0.12(extension bonus + filename bonus). While the inline comment explains these values, they appear to be implementation details that could change.This is acceptable for now, but if these bonus values are configurable or change frequently, consider importing them as constants from the context module.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/core/test_context_edge_cases.py` around lines 90 - 99, The test test_calculate_relevance_no_keywords uses magic numbers (0.1 and 0.12) to assert the expected minimum relevance for a FileInfo with extension ".py" and filename "main.py"; update the test to reference the actual bonus constants (or configuration) used by ContextLoader._calculate_relevance instead of hardcoding values: import or access the extension bonus and filename bonus symbols from the module that defines ContextLoader (or expose them on ContextLoader) and compute expected_min = extension_bonus + filename_bonus so the test remains correct if those values change.tests/core/test_gates_edge_cases.py (1)
49-63: Consider testing auto-detection flow directly.This test constructs a
GateResultmanually to verify the invariant that SKIPPED-only results pass. While this validates the data model, it doesn't exercise the actual auto-detection code path that would produce such a result.Consider adding a test that exercises
_detect_available_gatesorrun()in a scenario where unknown gates are encountered during auto-detection, to verify the end-to-end behavior.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/core/test_gates_edge_cases.py` around lines 49 - 63, Replace the manual-only GateResult test with (or add) an end-to-end unit test that exercises the auto-detection path: invoke the component that performs detection (call _detect_available_gates on the relevant runner/manager or call run() for a full execution) in a scenario where an unknown gate name is present (e.g., supply a fake/invalid gate in the input or plugin list), then assert the produced GateResult shows passed==True and that the corresponding GateCheck has status GateStatus.SKIPPED; target the _detect_available_gates and run methods in your test so the actual auto-detection logic is exercised rather than constructing GateResult by hand.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/core/test_context_edge_cases.py`:
- Around line 90-99: The test test_calculate_relevance_no_keywords uses magic
numbers (0.1 and 0.12) to assert the expected minimum relevance for a FileInfo
with extension ".py" and filename "main.py"; update the test to reference the
actual bonus constants (or configuration) used by
ContextLoader._calculate_relevance instead of hardcoding values: import or
access the extension bonus and filename bonus symbols from the module that
defines ContextLoader (or expose them on ContextLoader) and compute expected_min
= extension_bonus + filename_bonus so the test remains correct if those values
change.
In `@tests/core/test_gates_edge_cases.py`:
- Around line 49-63: Replace the manual-only GateResult test with (or add) an
end-to-end unit test that exercises the auto-detection path: invoke the
component that performs detection (call _detect_available_gates on the relevant
runner/manager or call run() for a full execution) in a scenario where an
unknown gate name is present (e.g., supply a fake/invalid gate in the input or
plugin list), then assert the produced GateResult shows passed==True and that
the corresponding GateCheck has status GateStatus.SKIPPED; target the
_detect_available_gates and run methods in your test so the actual
auto-detection logic is exercised rather than constructing GateResult by hand.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3936b5ea-50df-4563-aa8f-a1a855eda9c9
📒 Files selected for processing (5)
pytest.initests/core/test_context_edge_cases.pytests/core/test_gates_edge_cases.pytests/core/test_react_agent_edge_cases.pytests/core/test_tasks_edge_cases.py
Summary
Closes #114
edge_casepytest marker for targeted selection (pytest -m edge_case)Edge Cases by Component
test_react_agent_edge_cases.pytest_tasks_edge_cases.pytest_gates_edge_cases.pytest_context_edge_cases.pyDeviations from Original Plan
The original issue (#114) referenced v1 code (WorkerAgent, flash_save, Database class) that no longer exists. Tests were adapted to target the actual v2 core modules (ReactAgent/StallDetector, tasks, gates, context).
Test plan
uv run pytest -m edge_case -v— 26/26 passinguv run pytest tests/core/ -q— 1454 passing, 0 regressionsuv run ruff check— cleanSummary by CodeRabbit