Skip to content

Close test coverage gaps identified in the 0.2.0 test-suite audit #45

Description

@CaptainDriftwood

Context

A coverage-backed audit of the suite (511 unit + 64 integration tests) found the following untested areas, ranked by importance.

Tier 1 — untested code guarding correctness/security

  • IcapResponse.encapsulated (response.py:236-261): the cached property is never accessed by any test — not the parse path, the None branch, caching, or IcapProtocolError propagation on a malformed header. Only EncapsulatedParts.parse is fuzzed directly.
  • Async max_response_size enforcement (async_icap.py:805/885/949): Content-Length-exceeds, chunk-exceeds, and cumulative-body-exceeds are tested sync-only (test_client_methods.py:1309-1360); mirror them for AsyncIcapClient.
  • Trailer flood without CRLF (icap.py:860 + async twin): the trailer cap's no-CRLF-flood branch is untested (existing tests only exercise the per-line cap path). Also uncovered: connection-close mid-chunk-size-line (icap.py:841), mid-trailer (icap.py:866), and mid-headers (icap.py:682).
  • Async preview/stream error paths: _send_with_preview not-connected / timeout / CancelledError / OSError / early-virus-200, and _scan_stream_chunked CancelledError + 5xx branches — all tested sync, none async.

Tier 2 — parity and API-contract holes

  • Sync __exit__ during an exception (async version is tested; sync only has a structural hasattr check).
  • Async reqmod unit tests for body / custom headers / auto-connect (sync has all; async has only basic).
  • port setter range ValueError untested on both clients; MockIcapClient.port setter lacks range validation entirely (mock/real parity break).
  • Back-compat import test for icap.pytest_plugin.mock — the re-export module is the compatibility promise of the plugin split, and no test imports it (0% coverage).
  • Minor: istag unquoted-value branch (response.py:302), CaseInsensitiveDict.__contains__ non-str key (response.py:124), EncapsulatedParts req_body/null_body/opt_body concrete assertions, 204-direct-reply-to-partial-preview flow.

Line numbers reference the improve/code-quality branch at the time of the audit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions