Files
douyi_guaji_main/tests/test_high_value_room.py
T

18 lines
553 B
Python

from __future__ import annotations
import json
def test_save_high_value_rooms_is_atomic(tmp_path, monkeypatch):
from douyin.other import douyin_high_value_room as mod
target = tmp_path / "high_value_rooms.json"
monkeypatch.setattr(mod, "HIGH_VALUE_ROOMS_PATH", target)
mod._save_high_value_rooms({"updated_ts": 1, "total": 0, "rooms": []})
data = json.loads(target.read_text(encoding="utf-8"))
assert data["updated_ts"] == 1
assert data["rooms"] == []
assert not target.with_suffix(target.suffix + ".tmp").exists()