feat: Phase 1+2 — project setup and core infrastructure
- requirements.txt, config.yaml, .env, Dockerfile, docker-compose.yml - app/core: config (YAML+env override), logging (JSON structured), exceptions (typed hierarchy), json_utils (Markdown fence stripping) - app/clients: LLMClient ABC + ZhipuAIClient (run_in_executor), StorageClient ABC + RustFSClient (boto3 head_object for size check) - app/main.py: FastAPI app with health endpoint and router registration - app/core/dependencies.py: lru_cache singleton factories - tests/conftest.py: mock_llm, mock_storage, test_app, client fixtures - pytest.ini: asyncio_mode=auto - 11 unit tests passing
This commit is contained in:
40
tests/test_config.py
Normal file
40
tests/test_config.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import os
|
||||
import pytest
|
||||
|
||||
|
||||
def test_yaml_defaults_load(monkeypatch):
|
||||
# Clear lru_cache so each test gets a fresh load
|
||||
from app.core import config as cfg_module
|
||||
cfg_module.get_config.cache_clear()
|
||||
|
||||
# Remove env overrides that might bleed from shell environment
|
||||
for var in ["MAX_VIDEO_SIZE_MB", "LOG_LEVEL", "STORAGE_ENDPOINT"]:
|
||||
monkeypatch.delenv(var, raising=False)
|
||||
|
||||
cfg = cfg_module.get_config()
|
||||
|
||||
assert cfg["server"]["port"] == 8000
|
||||
assert cfg["video"]["max_file_size_mb"] == 200
|
||||
assert cfg["models"]["default_text"] == "glm-4-flash"
|
||||
assert cfg["models"]["default_vision"] == "glm-4v-flash"
|
||||
assert cfg["storage"]["buckets"]["source_data"] == "source-data"
|
||||
|
||||
|
||||
def test_max_video_size_env_override(monkeypatch):
|
||||
from app.core import config as cfg_module
|
||||
cfg_module.get_config.cache_clear()
|
||||
|
||||
monkeypatch.setenv("MAX_VIDEO_SIZE_MB", "500")
|
||||
cfg = cfg_module.get_config()
|
||||
|
||||
assert cfg["video"]["max_file_size_mb"] == 500
|
||||
|
||||
|
||||
def test_log_level_env_override(monkeypatch):
|
||||
from app.core import config as cfg_module
|
||||
cfg_module.get_config.cache_clear()
|
||||
|
||||
monkeypatch.setenv("LOG_LEVEL", "DEBUG")
|
||||
cfg = cfg_module.get_config()
|
||||
|
||||
assert cfg["server"]["log_level"] == "DEBUG"
|
||||
Reference in New Issue
Block a user