From 0cc02861ea52b04695f9a15ea65b65d781fe6a23 Mon Sep 17 00:00:00 2001 From: tligui_y Date: Thu, 31 Jul 2025 20:50:59 +0200 Subject: [PATCH] Add tests/test_utils_get_adj.py --- tests/test_utils_get_adj.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/test_utils_get_adj.py diff --git a/tests/test_utils_get_adj.py b/tests/test_utils_get_adj.py new file mode 100644 index 000000000..cab0bc6b3 --- /dev/null +++ b/tests/test_utils_get_adj.py @@ -0,0 +1,37 @@ +import pytest +import sys +import os +from slic.core.adjustable import Adjustable +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +from slic.utils.get_adj import * + +@pytest.fixture +def real_adjustables(): + a1 = Adjustable("brightness", units="%", limit_low=0, limit_high=100) + a2 = Adjustable("contrast", units="%", limit_low=0, limit_high=100) + a3 = Adjustable("debug_internal", internal=True) + return a1, a2, a3 + + +def test_get_adj_success(real_adjustables): + a1, _, _ = real_adjustables + assert get_adj("brightness") is a1 + + +def test_get_adj_not_found(capfd): + with pytest.raises(ValueError, match='could not find Adjustable with name "nonexistent"') as exc_info: + get_adj("nonexistent") + + +def test_ensure_adjs_mixed(real_adjustables): + a1, a2, a3 = real_adjustables + result = ensure_adjs(["contrast", a1, "debug_internal"]) + assert result == (a2, a1, a3) + + +def test_get_adjs_filter(real_adjustables): + a1, a2, a3 = real_adjustables + public = get_adjs() + assert public == {"brightness": a1, "contrast": a2} + all_ = get_adjs(include_internal=True) + assert all_ == {"brightness": a1, "contrast": a2, "debug_internal": a3}