Fix two PR #1543 tests with wrong assertion targets blocking main CI#1582
Conversation
Two tests added in PR #1543 (Type-check opencontractserver.llms modules) have been failing on main, blocking pytest (and therefore codecov) on every PR. Both tests assert against the wrong target: 1. test_callable_resolves_via_from_function patches opencontractserver.llms.api.ToolAPI.from_function, but _resolve_tools calls CoreTool.from_function directly. The mock never intercepts the actual call site, so _resolve_tools returns real CoreTool instances and the assertEqual against the sentinel fails. Patch CoreTool.from_function instead. 2. test_add_document_note_tool_passes_none_when_corpus_absent does a global file scan with assertNotIn("requires the agent to be scoped to a corpus"), but that string legitimately exists for add_exact_string_annotations (a different tool that does require a corpus). Scope the assertion to just the body of add_document_note_tool by slicing the file from its def to the next async def at the same indent level.
Code ReviewOverviewThis is a targeted two-test fix that unblocks CI after #1543 introduced tests with incorrect assertion/patch targets. No production code is changed — both changes are test-only. The root cause analysis in the PR description is accurate. Fix 1 —
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
Two tests added in #1543 have been failing on main and blocking pytest (and therefore codecov) on every PR. Both tests assert against the wrong target:
test_callable_resolves_via_from_function(test_llms_typing_coverage.py) patchesopencontractserver.llms.api.ToolAPI.from_function, but_resolve_toolscallsCoreTool.from_functiondirectly. The mock never intercepts, so_resolve_toolsreturns realCoreToolinstances andassertEqual(result, [sentinel])fails. PatchCoreTool.from_functioninstead.test_add_document_note_tool_passes_none_when_corpus_absent(test_llms_typing_behavior_guards.py) does a global file scan withassertNotIn("requires the agent to be scoped to a corpus"), but that string legitimately exists foradd_exact_string_annotations(a different tool that does require a corpus). Scope the assertion to the body ofadd_document_note_toolby slicing from itsdefto the nextasync defat the same indent level.Test plan
pytest opencontractserver/tests/test_llms_typing_coverage.py::TestResolveToolsCallerForms::test_callable_resolves_via_from_functionpassespytest opencontractserver/tests/test_llms_typing_behavior_guards.py::TestAddDocumentNoteToolCorpusOptional::test_add_document_note_tool_passes_none_when_corpus_absentpasses