|
@@ -17,10 +17,8 @@ def test___init___invalid_address(address):
|
|
|
("address", "button_index", "command", "expected_message"),
|
|
|
((12345678, 0, 0b00, 790123392), (2 ** 26 - 1, 0b1111, 0b01, 4294967263)),
|
|
|
)
|
|
|
-@pytest.mark.parametrize("output_power_setting", (0xC6, 0x84))
|
|
|
-def test__send_command(
|
|
|
- address, button_index, command, expected_message, output_power_setting
|
|
|
-):
|
|
|
+@pytest.mark.parametrize("power_setting", (0xC6, 0x84))
|
|
|
+def test__send_command(address, button_index, command, expected_message, power_setting):
|
|
|
remote_control = intertechno_cc1101.RemoteControl(address=address)
|
|
|
with unittest.mock.patch(
|
|
|
"intertechno_cc1101._encode_message", return_value=b"dummy"
|
|
@@ -30,12 +28,10 @@ def test__send_command(
|
|
|
remote_control._send_command(
|
|
|
button_index=button_index,
|
|
|
command=command,
|
|
|
- output_power_setting=output_power_setting,
|
|
|
+ power_setting=power_setting,
|
|
|
)
|
|
|
encode_message_mock.assert_called_once_with(expected_message)
|
|
|
- transmit_mock.assert_called_once_with(
|
|
|
- b"dummy", output_power_setting=output_power_setting
|
|
|
- )
|
|
|
+ transmit_mock.assert_called_once_with(b"dummy", power_setting=power_setting)
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("button_index", (-1, 2 ** 6, 8.15))
|
|
@@ -43,7 +39,7 @@ def test__send_command_invalid_button_index(button_index):
|
|
|
remote_control = intertechno_cc1101.RemoteControl(address=12345678)
|
|
|
with pytest.raises(ValueError):
|
|
|
remote_control._send_command(
|
|
|
- button_index=button_index, command=0b01, output_power_setting=0xC6
|
|
|
+ button_index=button_index, command=0b01, power_setting=0xC6
|
|
|
)
|
|
|
|
|
|
|
|
@@ -56,25 +52,23 @@ def test_turn_on(address, button_index):
|
|
|
) as send_command_mock:
|
|
|
remote_control.turn_on(button_index=button_index)
|
|
|
send_command_mock.assert_called_once_with(
|
|
|
- button_index=button_index, command=0b01, output_power_setting=0xC6
|
|
|
+ button_index=button_index, command=0b01, power_setting=0xC6
|
|
|
)
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("address", [12345678])
|
|
|
@pytest.mark.parametrize("button_index", [7])
|
|
|
-@pytest.mark.parametrize("output_power_setting", [0x60])
|
|
|
-def test_turn_on_custom_output_power(address, button_index, output_power_setting):
|
|
|
+@pytest.mark.parametrize("power_setting", [0x60])
|
|
|
+def test_turn_on_custom_power(address, button_index, power_setting):
|
|
|
remote_control = intertechno_cc1101.RemoteControl(address=address)
|
|
|
with unittest.mock.patch.object(
|
|
|
remote_control, "_send_command"
|
|
|
) as send_command_mock:
|
|
|
- remote_control.turn_on(
|
|
|
- button_index=button_index, output_power_setting=output_power_setting
|
|
|
- )
|
|
|
+ remote_control.turn_on(button_index=button_index, power_setting=power_setting)
|
|
|
send_command_mock.assert_called_once_with(
|
|
|
button_index=button_index,
|
|
|
command=0b01,
|
|
|
- output_power_setting=output_power_setting,
|
|
|
+ power_setting=power_setting,
|
|
|
)
|
|
|
|
|
|
|
|
@@ -87,23 +81,21 @@ def test_turn_off(address, button_index):
|
|
|
) as send_command_mock:
|
|
|
remote_control.turn_off(button_index=button_index)
|
|
|
send_command_mock.assert_called_once_with(
|
|
|
- button_index=button_index, command=0b00, output_power_setting=0xC6
|
|
|
+ button_index=button_index, command=0b00, power_setting=0xC6
|
|
|
)
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("address", [12345678])
|
|
|
@pytest.mark.parametrize("button_index", [7])
|
|
|
-@pytest.mark.parametrize("output_power_setting", [0x60])
|
|
|
-def test_turn_off_custom_output_power(address, button_index, output_power_setting):
|
|
|
+@pytest.mark.parametrize("power_setting", [0x60])
|
|
|
+def test_turn_off_custom_power(address, button_index, power_setting):
|
|
|
remote_control = intertechno_cc1101.RemoteControl(address=address)
|
|
|
with unittest.mock.patch.object(
|
|
|
remote_control, "_send_command"
|
|
|
) as send_command_mock:
|
|
|
- remote_control.turn_off(
|
|
|
- button_index=button_index, output_power_setting=output_power_setting
|
|
|
- )
|
|
|
+ remote_control.turn_off(button_index=button_index, power_setting=power_setting)
|
|
|
send_command_mock.assert_called_once_with(
|
|
|
button_index=button_index,
|
|
|
command=0b00,
|
|
|
- output_power_setting=output_power_setting,
|
|
|
+ power_setting=power_setting,
|
|
|
)
|