Skip to content

Commit 4cc8be2

Browse files
committed
test: add parameterized test for set_mode method to validate mode inputs
1 parent b560007 commit 4cc8be2

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

tests/clients/test_blinkstick.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44

55
from blinkstick.colors import ColorFormat
6-
from blinkstick.enums import BlinkStickVariant
6+
from blinkstick.enums import BlinkStickVariant, Mode
77
from blinkstick.clients.blinkstick import BlinkStick
88
from pytest_mock import MockFixture
99

@@ -310,3 +310,26 @@ def test_inverse_does_not_affect_max_rgb_value(make_blinkstick):
310310
bs.set_max_rgb_value(100)
311311
bs.set_inverse(True)
312312
assert bs.get_max_rgb_value() == 100
313+
314+
315+
@pytest.mark.parametrize(
316+
"mode, is_valid",
317+
[
318+
(1, True),
319+
(2, True),
320+
(3, True),
321+
(4, False),
322+
(-1, False),
323+
(Mode.RGB, True),
324+
(Mode.RGB_INVERSE, True),
325+
(Mode.ADDRESSABLE, True),
326+
],
327+
)
328+
def test_set_mode_raises_on_invalid_mode(make_blinkstick, mode, is_valid):
329+
"""Test that set_mode raises an exception when an invalid mode is passed."""
330+
bs = make_blinkstick()
331+
if is_valid:
332+
bs.set_mode(mode)
333+
else:
334+
with pytest.raises(ValueError):
335+
bs.set_mode("invalid_mode") # noqa

0 commit comments

Comments
 (0)