diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-27 19:52:28 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-27 19:52:28 +0200 |
| commit | db9a7a2dc1e35991c6410a1cef1ddad1c0b3c155 (patch) | |
| tree | 81be08fbf139b3ac6c400f953d94798f8442b01b /test_cal_notif.py | |
| parent | 1abb3002de93f9af64fa419109d2ef9114b99e76 (diff) | |
| download | cal-notif-db9a7a2dc1e35991c6410a1cef1ddad1c0b3c155.tar.gz cal-notif-db9a7a2dc1e35991c6410a1cef1ddad1c0b3c155.zip | |
Load config with defaults, read and write per-event overrides
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'test_cal_notif.py')
| -rw-r--r-- | test_cal_notif.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test_cal_notif.py b/test_cal_notif.py index f025ff4..27f60ba 100644 --- a/test_cal_notif.py +++ b/test_cal_notif.py @@ -53,6 +53,32 @@ def test_durations(): assert cn.number_it(28) == "ventotto" and cn.number_it(45) == "quarantacinque" +def test_overrides_roundtrip(): + with tempfile.TemporaryDirectory() as d: + p = Path(d) / "overrides.toml" + ov = {"a@example.org": ["1h", "10m"], 'q"uote@example.org': []} + cn.save_overrides(ov, p) + assert cn.load_overrides(p) == ov + assert cn.load_overrides(Path(d) / "missing.toml") == {} + + +def test_config(): + with tempfile.TemporaryDirectory() as d: + p = Path(d) / "config.toml" + assert cn.load_config(p)["voice"]["lang"] == "it" # no file: defaults + p.write_text('snooze = "15m"\n[voice]\nlang = "en-us"\n' + '[defaults]\nbd = { offsets = ["1d"], voice = false }\n') + c = cn.load_config(p) + assert c["snooze"] == "15m" and c["late"] == "10m" + assert c["voice"]["lang"] == "en-us" and c["voice"]["lead_silence"] == 0.3 # merged + p.write_text('[defaults]\n"*" = ["soon"]\n') + try: + cn.load_config(p) + raise AssertionError + except ValueError: + pass + + if __name__ == "__main__": for name, fn in list(globals().items()): if name.startswith("test_"): |
