Skip to content

Commit

Permalink
Assert loop called once per device
Browse files Browse the repository at this point in the history
  • Loading branch information
n8henrie committed Aug 29, 2023
1 parent 1cd0e80 commit 729bb38
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/test_mqttplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ def test_mqtt_auth(mock_client: MagicMock) -> None:
@patch("mqttplugin.Client", autospec=True)
def test_mqtt_nostate(mock_client: MagicMock) -> None:
"""Ensure loop_start is called whether or not no_state is specified."""
mock_instance = mock_client.return_value
with open(config_path_str) as f:
config: dict = json.load(f)

for device_conf in config["PLUGINS"]["MQTTPlugin"]["DEVICES"]:
device = MQTTPlugin(**device_conf)
mock_instance.loop_start.assert_called()
mock_instance.subscribe.assert_called()
assert device.subscribed is True
mock_instance = mock_client.return_value
_ = MQTTPlugin(**device_conf)
mock_instance.loop_start.assert_called_once()
mock_client.reset_mock()


@patch("mqttplugin.Client", autospec=True)
Expand Down

0 comments on commit 729bb38

Please sign in to comment.