Files
slic/tests/test_utils_get_adj.py
T
tligui_y 889a5ccb3e
Run CI Tests / test (push) Successful in 2m28s
Update tests/test_utils_get_adj.py
2025-08-29 16:27:46 +02:00

45 lines
1.4 KiB
Python

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 *
class SubAdjustable(Adjustable):
def __init__(self, *a, **kw):
super().__init__(*a, **kw)
self._val = 0
def get_current_value(self):
return self._val
def set_target_value(self, v, *args, **kwargs):
self._val = v
return v
def is_moving(self):
return False
def test_get_adj_success():
a1 = SubAdjustable("brightness", units="%", limit_low=0, limit_high=100)
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():
a2 = SubAdjustable("contrast", units="%", limit_low=0, limit_high=100)
a3 = SubAdjustable("mid_contrast", units="%", limit_low=0, limit_high=100)
result = ensure_adjs([a3, "contrast"])
assert result == (a3, a2)
def test_get_adjs_filter():
a4 = SubAdjustable("mid_brightness", units="%", limit_low=0, limit_high=100)
a5 = SubAdjustable("debug_internal", internal=True)
public = get_adjs()
assert 'mid_contrast' in set(public)
all_ = get_adjs(include_internal=True)
assert 'debug_internal' in set(all_)