summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_config.py29
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