Просмотр исходного кода

test(light): eliminate loop

Second "invalid_value" in first test parameters was not invalid. So
there is only one set of test values for each case. Anyway it would
have been cleaner to do these tests as 3 separate test parameters
even if they were all valid.
Jason Rumney 1 день назад
Родитель
Сommit
852ab79142
1 измененных файлов с 12 добавлено и 14 удалено
  1. 12 14
      tests/test_light.py

+ 12 - 14
tests/test_light.py

@@ -363,13 +363,13 @@ async def test_is_off_when_off_by_brightness():
 @pytest.mark.parametrize(
     ("rawtype", "invalid_values", "valid_value"),
     [
-        ("hex", ("ff  00", "ff 0 0"), "ff0000"),
-        ("base64", ("a",), "/wAA"),
+        ("hex", "ff  00", "ff0000"),
+        ("base64", "a", "/wAA"),
     ],
 )
 @pytest.mark.asyncio
 async def test_rgbhsv_invalid_colour_does_not_break_state_or_turn_on(
-    rawtype, invalid_values, valid_value
+    rawtype, invalid_value, valid_value
 ):
     """Ignore malformed colour data without losing the switch"""
     mock_device = AsyncMock()
@@ -393,14 +393,12 @@ async def test_rgbhsv_invalid_colour_does_not_break_state_or_turn_on(
     )
     light = TuyaLocalLight(mock_device, config)
 
-    assert light.hs_color == (0.0, 100.0)
-    for invalid_value in invalid_values:
-        dps["1"] = True
-        dps["2"] = invalid_value
-        assert light.hs_color is None
-        assert light.is_on is True
-        await light.async_turn_on(hs_color=(0, 100), brightness=255)
-        mock_device.async_set_properties.assert_not_called()
-        dps["1"] = False
-        await light.async_turn_on(hs_color=(0, 100), brightness=255)
-        mock_device.async_set_properties.assert_called_once_with({"1": True})
+    dps["1"] = True
+    dps["2"] = invalid_value
+    assert light.hs_color is None
+    assert light.is_on is True
+    await light.async_turn_on(hs_color=(0, 100), brightness=255)
+    mock_device.async_set_properties.assert_not_called()
+    dps["1"] = False
+    await light.async_turn_on(hs_color=(0, 100), brightness=255)
+    mock_device.async_set_properties.assert_called_once_with({"1": True})