[tests] 85 new tests — tasks.py and gitea_client.py go from zero to covered #108
Reference in New Issue
Block a user
Delete Branch "gemini/test-coverage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Gap
tasks.pygitea_client.pyThese two modules are the orchestration brain. Every @huey.task, every cron job, every triage loop runs through them. Until now, zero safety net.
What's Covered
test_tasks_core.py — 63 tests, 12 test classes
TestExtractFirstJsonObjectTestParseJsonOutputTestNormalizeCandidateEntryTestNormalizeTrainingExamplesTestNormalizeRubricScoresTestReadJsonTestWriteJsonTestJsonlIOTestWriteTextTestPathUtilitiesTestFormattingtest_gitea_client_core.py — 22 tests, 9 test classes
TestUserFromDictTestIssueFromDictTestCommentFromDictTestPullRequestFromDictTestFindUnassignedTestFindAgentIssuesWhy These Tests Matter
A bug in
extract_first_json_object()corrupts every @huey.task that processes LLM output — which is all of them.A bug in
normalize_candidate_entry()silently corrupts the knowledge graph.A bug in
Issue.from_dict()crashes the entire triage pipeline (we found this exact bug — Gitea returnsnullfor assignees).These are the functions that corrupt training data silently when they break. No one notices until the next autolora run produces a worse model.
Full Suite
108/108 pass. Zero regressions.
Design Notes
tasks.pytests use mocked imports fororchestration,huey, andgitea_clientto isolate the pure utility functions from side effectsgitea_clienttests useimportlib.utilto load the real module bypassing the mocktmp_pathfixtures for file I/O — no filesystem pollutionCOVERAGE BEFORE =============== tasks.py 2,117 lines ZERO tests gitea_client.py 539 lines ZERO tests (in this repo) Total: 2,656 lines of orchestration with no safety net COVERAGE AFTER ============== test_tasks_core.py — 63 tests across 12 test classes: TestExtractFirstJsonObject (10) — JSON parsing from noisy LLM output Every @huey.task depends on this. Tested: clean JSON, markdown fences, prose-wrapped, nested, malformed, arrays, unicode, empty TestParseJsonOutput (4) — stdout/stderr fallback chain TestNormalizeCandidateEntry (12) — knowledge graph data cleaning Confidence clamping, status validation, deduplication, truncation TestNormalizeTrainingExamples (5) — autolora training data prep Fallback when empty, alternative field names, empty prompt/response TestNormalizeRubricScores (3) — eval score clamping TestReadJson (4) — defensive file reads Missing files, corrupt JSON, deep-copy of defaults TestWriteJson (3) — atomic writes with sorted keys TestJsonlIO (9) — JSONL read/write/append/count Missing files, blank lines, append vs overwrite TestWriteText (3) — trailing newline normalization TestPathUtilities (4) — newest/latest path resolution TestFormatting (6) — batch IDs, profile summaries, tweet prompts, checkpoint defaults test_gitea_client_core.py — 22 tests across 9 test classes: TestUserFromDict (3) — all from_dict() deserialization TestLabelFromDict (1) TestIssueFromDict (4) — null assignees/labels (THE bug) TestCommentFromDict (2) — null body handling TestPullRequestFromDict (3) — null head/base/merged TestPRFileFromDict (1) TestGiteaError (2) — error formatting TestClientHelpers (1) — _repo_path formatting TestFindUnassigned (3) — label/title/assignee filtering TestFindAgentIssues (2) — case-insensitive matching WHY THESE TESTS MATTER ====================== A bug in extract_first_json_object() corrupts every @huey.task that processes LLM output — which is all of them. A bug in normalize_candidate_entry() silently corrupts the knowledge graph. A bug in the Gitea client's from_dict() crashes the entire triage and review pipeline (we found this bug — null assignees). These are the functions that corrupt training data silently when they break. No one notices until the next autolora run produces a worse model. FULL SUITE: 108/108 pass, zero regressions. Signed-off-by: gemini <gemini@hermes.local>