[kimi] test: add comprehensive tests for config.py (#648) #693

Merged
kimi merged 1 commits from kimi/issue-648 into main 2026-03-21 03:54:55 +00:00
Collaborator

Fixes #648

Summary

  • Added tests/test_config_module.py with 48 tests covering all public functions and classes in src/config.py
  • Defaults: Verifies key default values on fresh Settings() instantiation
  • Env overrides: Confirms env vars like AGENT_NAME, OLLAMA_URL, DEBUG, TIMMY_ENV override defaults
  • Type validation: Bool parsing (true/false/1/0), int parsing, Literal rejection of invalid values, extra field ignoring
  • Edge cases: Empty strings, zero values, large ints, negative ints
  • normalize_ollama_url: localhost replacement, IP preservation, multiple occurrences
  • _compute_repo_root: Auto-detection and explicit override
  • model_post_init: Gitea token from env and file fallback
  • check_ollama_model_available: Network errors, model found/not found
  • get_effective_ollama_model: Primary available, fallback chain, nothing available
  • validate_startup: Test mode skip, dev warnings, production exits on missing secrets/CORS wildcard, production passes with secrets, idempotency
  • APP_START_TIME: Type and timezone checks

Test plan

  • tox -e format clean
  • tox -e lint clean
  • tox -e unit — all 2205 tests pass
  • tox -e pre-push — full CI suite passes
Fixes #648 ## Summary - Added `tests/test_config_module.py` with 48 tests covering all public functions and classes in `src/config.py` - **Defaults**: Verifies key default values on fresh `Settings()` instantiation - **Env overrides**: Confirms env vars like `AGENT_NAME`, `OLLAMA_URL`, `DEBUG`, `TIMMY_ENV` override defaults - **Type validation**: Bool parsing (`true`/`false`/`1`/`0`), int parsing, Literal rejection of invalid values, extra field ignoring - **Edge cases**: Empty strings, zero values, large ints, negative ints - **`normalize_ollama_url`**: localhost replacement, IP preservation, multiple occurrences - **`_compute_repo_root`**: Auto-detection and explicit override - **`model_post_init`**: Gitea token from env and file fallback - **`check_ollama_model_available`**: Network errors, model found/not found - **`get_effective_ollama_model`**: Primary available, fallback chain, nothing available - **`validate_startup`**: Test mode skip, dev warnings, production exits on missing secrets/CORS wildcard, production passes with secrets, idempotency - **`APP_START_TIME`**: Type and timezone checks ## Test plan - [x] `tox -e format` clean - [x] `tox -e lint` clean - [x] `tox -e unit` — all 2205 tests pass - [x] `tox -e pre-push` — full CI suite passes
kimi added 1 commit 2026-03-21 03:54:41 +00:00
test: add comprehensive tests for config.py
Some checks failed
Tests / lint (pull_request) Has been cancelled
Tests / test (pull_request) Has been cancelled
bea86d39f3
Covers Settings defaults, env var overrides, type validation,
edge cases, normalize_ollama_url, _compute_repo_root,
model_post_init, check_ollama_model_available,
get_effective_ollama_model, validate_startup, and APP_START_TIME.

Fixes #648

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kimi merged commit 6f0863b587 into main 2026-03-21 03:54:55 +00:00
kimi deleted branch kimi/issue-648 2026-03-21 03:54:55 +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#693