Add tests/test_utils_get_adj.py
Run CI Tests / test (push) Successful in 51s

This commit is contained in:
2025-07-31 20:50:59 +02:00
parent fd268195cb
commit 0cc02861ea
+37
View File
@@ -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}