test: bring stale weather, enrichment cache and diary import tests up to date

- Weather: the tool deliberately returns one Korean sentence about now
  (c522e1b), so the tests check the place, condition, rounded temperature and
  feels-like, and that no forecast, Fahrenheit or degree sign is left for the
  model to echo.
- Enrichment cache: the conversational fast-path skips enrichment when no
  data tool is routed, so the test routes one to reach the extractor.
- Diary import: mock PyQt6, requests and psutil only when they are not
  installed. The MagicMock left in sys.modules for an installed PyQt6 broke
  every later GUI test file in the same run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-11 16:13:52 +09:00
parent 4621e6c1fd
commit 1745fcd04c
3 changed files with 34 additions and 26 deletions

View File

@@ -5,6 +5,7 @@ Covers:
- /api/graph/import-diary streaming endpoint (requires flask)
"""
import importlib.util
import json
import sqlite3
import sys
@@ -21,8 +22,17 @@ _MOCK_MODULES = [
"requests", "requests.exceptions",
"psutil",
]
def _is_installed(name):
# Mock only what is missing: a MagicMock left in sys.modules for an
# installed PyQt6 breaks every later test file that imports the real one.
try:
return importlib.util.find_spec(name) is not None
except (ImportError, ValueError):
return False
for _mod in _MOCK_MODULES:
if _mod not in sys.modules:
if _mod not in sys.modules and not _is_installed(_mod):
sys.modules[_mod] = MagicMock()
# Ensure requests.exceptions.Timeout is a proper exception class