Implemented the full clean rewrite for Gitea
All checks were successful
Test blackout notifier / test (push) Successful in 3m41s
Hourly blackout check / check (push) Successful in 8s

This commit is contained in:
Meghdad
2026-07-17 04:33:16 +03:30
parent d7f53ba234
commit 4218e4ac36
30 changed files with 1437 additions and 384 deletions

28
tests/test_state.py Normal file
View File

@@ -0,0 +1,28 @@
from __future__ import annotations
from pathlib import Path
import pytest
from blackout_notifier.state import StateError, StateRepository, empty_state
def test_state_round_trip_is_deterministic(tmp_path: Path) -> None:
repository = StateRepository(tmp_path / "nested" / "outages.json")
repository.save(empty_state())
first = repository.path.read_text(encoding="utf-8")
repository.save(repository.load())
assert repository.load() == empty_state()
assert repository.path.read_text(encoding="utf-8") == first
def test_corrupt_state_fails_closed(tmp_path: Path) -> None:
path = tmp_path / "outages.json"
path.write_text("not json", encoding="utf-8")
with pytest.raises(StateError, match="Cannot read state"):
StateRepository(path).load()
assert path.read_text(encoding="utf-8") == "not json"