|
@@ -9,24 +9,6 @@ import intertechno_cc1101_mqtt
|
|
|
# pylint: disable=protected-access
|
|
|
|
|
|
|
|
|
-def test__mqtt_on_message_retained(caplog):
|
|
|
- message = MQTTMessage(topic=b"intertechno-cc1101/12345678/0/set")
|
|
|
- message.payload = b"ON"
|
|
|
- message.retain = True
|
|
|
- with unittest.mock.patch("intertechno_cc1101.RemoteControl") as remote_control_mock:
|
|
|
- with caplog.at_level(logging.DEBUG):
|
|
|
- intertechno_cc1101_mqtt._mqtt_on_message("dummy", {}, message)
|
|
|
- remote_control_mock.assert_not_called()
|
|
|
- assert caplog.record_tuples == [
|
|
|
- (
|
|
|
- "intertechno_cc1101_mqtt",
|
|
|
- logging.DEBUG,
|
|
|
- "received topic=intertechno-cc1101/12345678/0/set payload=b'ON'",
|
|
|
- ),
|
|
|
- ("intertechno_cc1101_mqtt", logging.WARNING, "ignoring retained message"),
|
|
|
- ]
|
|
|
-
|
|
|
-
|
|
|
@pytest.mark.parametrize(
|
|
|
("topic", "address"),
|
|
|
(
|
|
@@ -75,9 +57,13 @@ def test__mqtt_on_message_invalid_address(caplog, topic, address_str):
|
|
|
("payload", "turn_on"),
|
|
|
((b"ON", True), (b"On", True), (b"on", True), (b"OFF", False), (b"off", False)),
|
|
|
)
|
|
|
-def test__mqtt_on_message_button_index_action(topic, button_index, payload, turn_on):
|
|
|
+@pytest.mark.parametrize("retain", [True, False])
|
|
|
+def test__mqtt_on_message_button_index_action(
|
|
|
+ topic, button_index, payload, turn_on, retain
|
|
|
+):
|
|
|
message = MQTTMessage(topic=topic)
|
|
|
message.payload = payload
|
|
|
+ message.retain = retain
|
|
|
with unittest.mock.patch("intertechno_cc1101.RemoteControl") as remote_control_mock:
|
|
|
intertechno_cc1101_mqtt._mqtt_on_message("dummy", {}, message)
|
|
|
if turn_on:
|