Skip to content

Coverage cleanup: _constants 100%, soa 100%, __init__ 98%#250

Merged
seanthegeek merged 1 commit into
mainfrom
coverage/constants-and-soa
May 20, 2026
Merged

Coverage cleanup: _constants 100%, soa 100%, __init__ 98%#250
seanthegeek merged 1 commit into
mainfrom
coverage/constants-and-soa

Conversation

@seanthegeek
Copy link
Copy Markdown
Contributor

Summary

Last cleanup pass on the small per-file coverage gaps that earlier rounds skipped.

File Before After
_constants.py 79% 100%
soa.py 89% 100%
__init__.py 92% 98%

Tests added

  • tests/test_constants.pyTestEnvironmentOverrideBranches reloads checkdmarc._constants under a patch.dict(os.environ, ...) context and asserts that each cache-size and cache-age env var (CACHE_MAX_LEN, CACHE_MAX_AGE_SECONDS, plus the per-subsystem DNS_*, DNSSEC_*, SMTP_* overrides) lands on the corresponding constant. tearDown restores the module so test ordering is unaffected.
  • tests/test_soa.py — covers the empty-local-part RNAME branch (e.g. .example.com.), the non-integer u32 field branch, the out-of-range u32 branch, and the check_soa parse-error branch (where get_soa_record succeeds but parse_soa_string raises — the failure result still carries the original record).
  • tests/test_init.py — empty-string filter inside check_domains, MTA-STS-policy mx-pattern propagation to check_mx, BIMI-error CSV row flattening l/a tag values to bimi_l / bimi_a columns, and the TLS / STARTTLS KeyError fallback for MX hosts without those keys (e.g. when skip_tls=True).

Test plan

  • GITHUB_ACTIONS=true python -m pytest tests/ passes (439 passed, 12 skipped)
  • ruff check, ruff format --check, pyright (1.1.409) all clean
  • CI green on this PR

🤖 Generated with Claude Code

tests/test_constants.py: reload checkdmarc._constants under a patched
environment and assert each cache-size / cache-age env var override
lands on the corresponding constant. Covers CACHE_MAX_LEN,
CACHE_MAX_AGE_SECONDS, and the per-subsystem DNS_/DNSSEC_/SMTP_
overrides.

tests/test_soa.py: cover the empty-local-part RNAME branch
(``.example.com.``), the non-integer u32 field branch, the
out-of-range u32 branch, and the check_soa parse-error branch (where
get_soa_record succeeds but parse_soa_string raises, returning an
error result that still carries the original record).

tests/test_init.py: cover the empty-string filter inside
check_domains, the MTA-STS-policy-mx-patterns propagation to check_mx,
the BIMI-error CSV-row branch that flattens l/a tag values to bimi_l /
bimi_a columns, and the TLS / STARTTLS KeyError fallback for MX hosts
without those keys (e.g. when skip_tls=True).

Per-file coverage:
  _constants.py   79%  -> 100%
  soa.py          89%  -> 100%
  __init__.py     92%  -> 98%

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@seanthegeek seanthegeek merged commit 3cd556c into main May 20, 2026
1 check passed
@seanthegeek seanthegeek deleted the coverage/constants-and-soa branch May 20, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant