From 85bdcf48d91fedf32d09c64707c1e206e4347e54 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 17 Jul 2026 09:53:24 +0200 Subject: feat: serialize profiles with day/night tagging Co-Authored-By: Claude Opus 4.8 --- tests/test_config.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_config.py b/tests/test_config.py index 4568160..62acd97 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,4 +1,4 @@ -from hyprsunset_qt.config import Profile, parse_config +from hyprsunset_qt.config import Profile, parse_config, serialize, day_index, night_index def test_parse_two_profiles(): @@ -23,3 +23,30 @@ profile { def test_parse_empty(): assert parse_config("") == [] + + +def test_serialize_roundtrip(): + profiles = [ + Profile(time="5:00", identity=True), + Profile(time="19:40", temperature=5500, gamma=0.8), + ] + text = serialize(profiles) + assert parse_config(text) == profiles + assert "identity = true" in text + assert "temperature = 5500" in text + assert "gamma = 0.8" in text + assert text.startswith("# Managed by hyprsunset-qt") + + +def test_day_night_index(): + profiles = [ + Profile(time="5:00", identity=True), + Profile(time="19:40", temperature=5500, gamma=0.8), + ] + assert day_index(profiles) == 0 + assert night_index(profiles) == 1 + + +def test_day_night_index_missing(): + assert day_index([Profile(time="1:00", temperature=4000)]) is None + assert night_index([Profile(time="1:00", identity=True)]) is None -- cgit v1.2.3