summaryrefslogtreecommitdiffstats
path: root/tests/test_config.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-17 10:51:11 +0200
committerDanilo M. <danix@danix.xyz>2026-07-17 10:51:11 +0200
commit869459e79b296f9e6900f9439b95f817ac836f1f (patch)
treef6e8bb7b0c97e0f085f79be15aec08b83052e45c /tests/test_config.py
parentebdf809e0723ba3d32794278c72e4cd844cea498 (diff)
downloadhyprsunset-qt-869459e79b296f9e6900f9439b95f817ac836f1f.tar.gz
hyprsunset-qt-869459e79b296f9e6900f9439b95f817ac836f1f.zip
feat: field validation helpers
Add validation functions for config parameters: valid_time() for HH:MM format (0-23:0-59), valid_temperature() for Kelvin range 1000-20000, and valid_gamma() for gamma range 0.0-2.0. These are used by the UI before saving config changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_config.py')
-rw-r--r--tests/test_config.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index 1847449..3a17c8e 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -66,3 +66,27 @@ def test_write_then_read(tmp_path):
def test_default_path_is_hypr_conf():
assert str(CONFIG_PATH).endswith(".config/hypr/hyprsunset.conf")
+
+
+from hyprsunset_qt.config import valid_time, valid_temperature, valid_gamma
+
+
+def test_valid_time():
+ assert valid_time("19:40")
+ assert valid_time("5:00")
+ assert not valid_time("25:00")
+ assert not valid_time("19:60")
+ assert not valid_time("abc")
+
+
+def test_valid_temperature():
+ assert valid_temperature(5500)
+ assert not valid_temperature(500)
+ assert not valid_temperature(30000)
+
+
+def test_valid_gamma():
+ assert valid_gamma(0.8)
+ assert valid_gamma(0.0)
+ assert not valid_gamma(-1.0)
+ assert not valid_gamma(2.5)