test: add characterization tests for core modules
33 tests covering env/io helpers, config parsers, pipeline meta I/O, worker inbox logic, and FastAPI smoke routes. No gmic/rembg subprocesses. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"""Tests for io_utils."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from app.io_utils import read_json, write_json_atomic
|
||||
|
||||
|
||||
def test_read_json_missing_returns_default(tmp_path: Path) -> None:
|
||||
assert read_json(tmp_path / "missing.json", default={}) == {}
|
||||
|
||||
|
||||
def test_read_json_corrupt_returns_default(tmp_path: Path) -> None:
|
||||
path = tmp_path / "bad.json"
|
||||
path.write_text("not json", encoding="utf-8")
|
||||
assert read_json(path, default=None) is None
|
||||
|
||||
|
||||
def test_write_json_atomic_roundtrip(tmp_path: Path) -> None:
|
||||
path = tmp_path / "data.json"
|
||||
payload = {"job_id": "photo", "variants": []}
|
||||
write_json_atomic(path, payload)
|
||||
assert json.loads(path.read_text(encoding="utf-8")) == payload
|
||||
assert not path.with_suffix(path.suffix + ".tmp").exists()
|
||||
Reference in New Issue
Block a user