diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-17 09:53:24 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-17 09:53:24 +0200 |
| commit | 85bdcf48d91fedf32d09c64707c1e206e4347e54 (patch) | |
| tree | a2179a4807b6155f3f88bf21e4378fdfb21004e0 /tests/test_config.py | |
| parent | 73840b30b9943e9b7de03e6172dbe7a51582ff94 (diff) | |
| download | hyprsunset-qt-85bdcf48d91fedf32d09c64707c1e206e4347e54.tar.gz hyprsunset-qt-85bdcf48d91fedf32d09c64707c1e206e4347e54.zip | |
feat: serialize profiles with day/night tagging
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_config.py')
| -rw-r--r-- | tests/test_config.py | 29 |
1 files changed, 28 insertions, 1 deletions
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 |
