[loop-cycle-3] fix: isolate unit tests from local .env and real Gitea API #1206

Merged
Timmy merged 1 commits from fix/test-env-isolation into main 2026-03-23 22:15:38 +00:00
Owner

Problem

5 unit tests failing on main due to environment bleed:

  • test_config.py (4 failures): _make_settings() patched os.environ but Pydantic's BaseSettings still read the .env file, picking up local overrides (OLLAMA_MODEL=qwen3:30b, GROK_ENABLED=true, GITEA_URL=http://143.198.27.163:3000)
  • test_vassal_agent_health.py (1 failure): test_nudge_stuck_agent_no_token hit the real Gitea API because config.settings had a real token from .env

Fix

  • _make_settings(): temporarily set Settings.model_config['env_file'] = None to prevent .env file reading during tests, restored in finally block
  • test_nudge_stuck_agent_no_token: mock config.settings with gitea_enabled=False and empty gitea_token

Verification

343 passed, 0 failed (was 5 failed)

Fixes test failures on main.

## Problem 5 unit tests failing on main due to environment bleed: - `test_config.py` (4 failures): `_make_settings()` patched `os.environ` but Pydantic's BaseSettings still read the `.env` file, picking up local overrides (`OLLAMA_MODEL=qwen3:30b`, `GROK_ENABLED=true`, `GITEA_URL=http://143.198.27.163:3000`) - `test_vassal_agent_health.py` (1 failure): `test_nudge_stuck_agent_no_token` hit the real Gitea API because `config.settings` had a real token from `.env` ## Fix - `_make_settings()`: temporarily set `Settings.model_config['env_file'] = None` to prevent `.env` file reading during tests, restored in `finally` block - `test_nudge_stuck_agent_no_token`: mock `config.settings` with `gitea_enabled=False` and empty `gitea_token` ## Verification 343 passed, 0 failed (was 5 failed) Fixes test failures on main.
Timmy added 1 commit 2026-03-23 22:15:36 +00:00
fix: isolate tests from local .env and real Gitea API
Some checks failed
Tests / lint (pull_request) Failing after 15s
Tests / test (pull_request) Has been skipped
182d186bda
Timmy merged commit b197cf409e into main 2026-03-23 22:15:38 +00:00
Timmy deleted branch fix/test-env-isolation 2026-03-23 22:15:38 +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#1206