feat: Add helper function unit tests#75
Conversation
There was a problem hiding this comment.
Pull request overview
Adds/extends unit test coverage for several helper modules and provides a Makefile target to run the test suite.
Changes:
- Expanded
sanitizeanddescription_searchhelper tests (including private helper coverage). - Added new unit test modules for
auth,db, andcachehelpers. - Added a
make testtarget; minor import ordering adjustment inserver/models/laf.py.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_sanitize.py | Adds tests for whitespace normalization and key rejection logic. |
| tests/test_description_search.py | Adds tests for token scoring and prefilter alternate expansion. |
| tests/test_db.py | New tests for async iteration, date delta formatting, and sequence generation behavior. |
| tests/test_cache.py | New tests for request-stripping cache key generation. |
| tests/test_auth.py | New tests for token validation, token creation expiry behavior, and auth helpers. |
| server/models/laf.py | Minor import reordering. |
| Makefile | Adds test target to run pytest via uv. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def test_token_match_score_averages_best_ratios() -> None: | ||
| """Single query token: score equals best fuzzy ratio against text tokens.""" | ||
| score = token_match_score(["cat"], ["bat", "car"]) | ||
| assert 0.0 < score <= 100.0 |
There was a problem hiding this comment.
This test name/docstring claims it validates that token_match_score averages the best fuzzy ratios, but the assertion only checks the return is within (0, 100], which would pass even if the function returned a constant (e.g. always 1.0). Consider asserting against a concrete expected value (e.g., compute expected = max(fuzz.ratio('cat', t) for t in ['bat','car']) and compare with pytest.approx(expected)), and/or add a multi-token case to actually exercise the averaging behavior.
Description
Add test suite for helper functions