aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_config.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-17 10:04:37 +0200
committerDanilo M. <danix@danix.xyz>2026-07-17 10:04:37 +0200
commit7548ce1bfd4496d7cb035706307d709801a54a30 (patch)
tree689652b8245397c41a3307523f5e25e8b70803c3 /tests/test_config.py
parent85bdcf48d91fedf32d09c64707c1e206e4347e54 (diff)
downloadhyprsunset-qt-7548ce1bfd4496d7cb035706307d709801a54a30.tar.gz
hyprsunset-qt-7548ce1bfd4496d7cb035706307d709801a54a30.zip
feat: read/write hyprsunset.conf
Add read_config() and write_config() functions for managing hyprsunset configuration files. Implements file I/O operations with automatic parent directory creation and CONFIG_PATH default to ~/.config/hypr/hyprsunset.conf. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_config.py')
-rw-r--r--tests/test_config.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index 62acd97..1847449 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -1,4 +1,5 @@
-from hyprsunset_qt.config import Profile, parse_config, serialize, day_index, night_index
+from pathlib import Path
+from hyprsunset_qt.config import Profile, parse_config, serialize, day_index, night_index, read_config, write_config, CONFIG_PATH
def test_parse_two_profiles():
@@ -50,3 +51,18 @@ def test_day_night_index():
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
+
+
+def test_read_missing_returns_empty(tmp_path):
+ assert read_config(tmp_path / "nope.conf") == []
+
+
+def test_write_then_read(tmp_path):
+ path = tmp_path / "hyprsunset.conf"
+ profiles = [Profile(time="19:40", temperature=5500, gamma=0.8)]
+ write_config(profiles, path)
+ assert read_config(path) == profiles
+
+
+def test_default_path_is_hypr_conf():
+ assert str(CONFIG_PATH).endswith(".config/hypr/hyprsunset.conf")