[claude] Add unit tests for src/config.py (#1172) #1175

Merged
Rockachopa merged 1 commits from :claude/issue-1172 into main 2026-03-23 20:46:55 +00:00
Collaborator

Fixes #1172

What

Add tests/unit/test_config.py with pytestmark = pytest.mark.unit so tests are picked up by tox -e unit.

Coverage

  • normalize_ollama_url helper (6 cases including edge cases)
  • Settings defaults for all major fields (agent_name, models, URLs, flags, timeouts)
  • normalized_ollama_url property
  • Env var overrides: strings, bools, ints, floats, Literal fields
  • Pydantic type validation and ValidationError paths
  • Edge cases: empty strings, zero/negative ints, extra fields ignored
  • _compute_repo_root auto-detection
  • model_post_init gitea_token file fallback logic
  • check_ollama_model_available: OSError, not found, exact match, prefix match
  • get_effective_ollama_model fallback chain walking
  • validate_startup: test-mode skip, dev warnings, production sys.exit guards (missing secrets, CORS wildcard)
  • APP_START_TIME and module-level settings singleton

Test result

293 passed (118 new config tests + existing suite), tox -e unit green.

Fixes #1172 ## What Add `tests/unit/test_config.py` with `pytestmark = pytest.mark.unit` so tests are picked up by `tox -e unit`. ## Coverage - `normalize_ollama_url` helper (6 cases including edge cases) - `Settings` defaults for all major fields (agent_name, models, URLs, flags, timeouts) - `normalized_ollama_url` property - Env var overrides: strings, bools, ints, floats, Literal fields - Pydantic type validation and `ValidationError` paths - Edge cases: empty strings, zero/negative ints, extra fields ignored - `_compute_repo_root` auto-detection - `model_post_init` gitea_token file fallback logic - `check_ollama_model_available`: OSError, not found, exact match, prefix match - `get_effective_ollama_model` fallback chain walking - `validate_startup`: test-mode skip, dev warnings, production `sys.exit` guards (missing secrets, CORS wildcard) - `APP_START_TIME` and module-level `settings` singleton ## Test result 293 passed (118 new config tests + existing suite), `tox -e unit` green.
claude added 1 commit 2026-03-23 20:42:19 +00:00
test: add unit tests for src/config.py (issue #1172)
Some checks failed
Tests / lint (pull_request) Has been cancelled
Tests / test (pull_request) Has been cancelled
d457904598
Add tests/unit/test_config.py with pytestmark=pytest.mark.unit so the
tests are picked up by tox -e unit. Covers:

- normalize_ollama_url helper (6 cases)
- Settings defaults for all major fields
- normalized_ollama_url property
- Env var overrides for strings, bools, ints, floats, Literals
- Type validation and pydantic ValidationError paths
- Edge cases: empty strings, zero/negative ints, large values
- _compute_repo_root auto-detection
- model_post_init gitea_token file fallback
- check_ollama_model_available (OSError, found, not found, exact match, startswith)
- get_effective_ollama_model fallback chain
- validate_startup: test-mode skip, dev warnings, production sys.exit guards
- APP_START_TIME and module-level settings singleton

Refs #1172

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rockachopa merged commit 2fcd92e5d9 into main 2026-03-23 20:46:55 +00:00
Rockachopa deleted branch claude/issue-1172 2026-03-23 20:46:56 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1175