Skip to content

Commit 11cf760

Browse files
test(wl_replay): cover all replay handler bodies (20% → 79%) — G3 batch 3c
Adds 18 unit tests covering execute_approved_action and all 5 handler bodies plus the precondition validation paths and the try/except wrapper. New test classes: - TestDispatchExceptionHandler — handler raising propagates as handler_exception (covers wrapper try/except at lines 116-126) - TestRulePreconditionValidation — create_rule with existing rule → rule_exists; delete_rule with missing rule → rule_not_found - TestCreateRuleHandler / TestDeleteRuleHandler / TestDeleteCsvHandler — happy + failure paths for the three pipeline-delegating handlers - TestSaveCsvHandler — happy path with all mocks; write_csv exception; audit-post failure still returns success - TestRevertCsvHandlerKnownBug — documents a discovered production bug (see "Known bug" note below) - TestCreateCsvHandler — invalid name, file-exists, full happy path, mapping RMW OSError handled Coverage: bin/wl_replay.py 20% → 79% (+59 percentage points). Tests: 716 → 734 (+18 added). KNOWN BUG DISCOVERED (documented in TestRevertCsvHandlerKnownBug): `_execute_replay_revert_csv` at line 226 calls `get_versions_dir()` with NO arguments, but the function signature in bin/wl_versions.py line 40 requires `csv_path: str`. This ALWAYS raises TypeError, which is caught by the broad `except Exception` at line 309 and returns {"error_type": "revert_failed"}. Lines 229-307 are effectively dead code in production. Approving a revert_csv request through the queue silently fails with a generic "missing 1 required positional argument" error string. The bug is NOT fixed in this commit — it is a behaviour change that should ship in a dedicated fix commit with an E2E test. Two tests in TestRevertCsvHandlerKnownBug pin the current (buggy) behaviour so a future fix is observable as a test break. Mock strategy: all domain-module imports (write_csv, snapshot_version, post_audit_event, create_rule_pipeline, etc.) are patched on the wl_replay module namespace because wl_replay imports them at module top. The exception is read_version_manifest/get_versions_dir which are imported INSIDE _execute_replay_revert_csv — for those we patch the source module (wl_versions), matching the same pattern used in test_versions.py G3 batch 3b. No source code (bin/*) was modified. Pure test-addition commit.
1 parent c6b6fc6 commit 11cf760

1 file changed

Lines changed: 440 additions & 1 deletion

File tree

0 commit comments

Comments
 (0)