-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_test_state.py
More file actions
27 lines (23 loc) · 940 Bytes
/
Copy path_test_state.py
File metadata and controls
27 lines (23 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Quick smoke test for new MonitorState fields."""
import json
import tempfile
from pathlib import Path
from gois.state import MonitorState
s = MonitorState()
assert s.whatsapp_inbound_failures == 0, f"expected 0 got {s.whatsapp_inbound_failures}"
assert s.whatsapp_inbound_last_error is None
assert s.whatsapp_inbound_last_failure_ts is None
print("state.py OK: new fields load with defaults")
# Test round-trip
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as f:
f.write(json.dumps({
"whatsapp_inbound_failures": 3,
"whatsapp_inbound_last_error": "test error",
"whatsapp_inbound_last_failure_ts": 1234567890.0,
}))
p = f.name
s2 = MonitorState.load(Path(p))
assert s2.whatsapp_inbound_failures == 3
assert s2.whatsapp_inbound_last_error == "test error"
assert s2.whatsapp_inbound_last_failure_ts == 1234567890.0
print("state.py OK: fields survive save/load round-trip")