Skip to content

test: add standalone instrument tests and is_valid_path negative tests#98

Merged
lesnik512 merged 1 commit into
mainfrom
fix/test-4-7-gaps
Jun 1, 2026
Merged

test: add standalone instrument tests and is_valid_path negative tests#98
lesnik512 merged 1 commit into
mainfrom
fix/test-4-7-gaps

Conversation

@lesnik512

@lesnik512 lesnik512 commented Jun 1, 2026

Copy link
Copy Markdown
Member

Summary

Pure test additions; no production code changes.

  • TEST-4: Standalone test files for the four instruments previously only covered transitively via bootstrapper integration tests:
    • tests/instruments/test_cors_instrument.pyis_ready matrix (origins-only, regex-only, both, neither), not_ready_message, config defaults, check_dependencies.
    • tests/instruments/test_healthchecks_instrument.py — enabled/disabled, render_health_check_data output shape, defaults.
    • tests/instruments/test_prometheus_instrument.py — valid/invalid/empty paths, defaults.
    • tests/instruments/test_swagger_instrument.py — instantiation, defaults.
  • TEST-7: tests/test_path.py — parametrized cases for is_valid_path covering 8 valid forms (/metrics, /health/, multi-segment, special chars in the allowed set) and 9 invalid forms (empty, no leading slash, spaces, ?/#, empty segments).

38 new tests; full suite goes from 89 → 127.

Closes TEST-4 and TEST-7 from an internal audit.

Test plan

  • just test — 127/127.
  • just lint — clean.
  • Reviewer: confirm the rejected-path list in test_path.py matches the intended contract. The regex DOES accept /.. because . is in the allowed charset — pre-existing design decision; not tested as a "valid" or "invalid" case in this PR.

🤖 Generated with Claude Code

TEST-4: Add tests/instruments/test_{cors,healthchecks,prometheus,swagger}_instrument.py
covering is_ready() across valid/invalid configurations,
not_ready_message content, render_health_check_data output shape,
config defaults, and check_dependencies. These instruments were
previously only covered transitively via bootstrapper integration
tests, which made regressions noisier to diagnose.

TEST-7: Add tests/test_path.py with parametrized cases for
helpers.path.is_valid_path — both valid forms (default paths used by
the prometheus/swagger/healthchecks instruments) and invalid forms
(empty, no leading slash, spaces, special chars, empty segments).

Closes TEST-4 and TEST-7 from the audit. Pure additions; no production
code changed.
@lesnik512 lesnik512 self-assigned this Jun 1, 2026
@lesnik512 lesnik512 merged commit 1e10d7a into main Jun 1, 2026
7 checks passed
@lesnik512 lesnik512 deleted the fix/test-4-7-gaps branch June 1, 2026 07:24
@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
tests/instruments/test_cors_instrument.py 100.00% <100.00%> (ø)
tests/instruments/test_healthchecks_instrument.py 100.00% <100.00%> (ø)
tests/instruments/test_prometheus_instrument.py 100.00% <100.00%> (ø)
tests/instruments/test_swagger_instrument.py 100.00% <100.00%> (ø)
tests/test_path.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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