Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give mqtt test more time to process subscriptions #103006

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions tests/components/mqtt/test_discovery.py
Expand Up @@ -1523,18 +1523,20 @@ async def async_step_mqtt(self, discovery_info: MqttServiceInfo) -> FlowResult:
return self.async_abort(reason="already_configured")

with patch.dict(config_entries.HANDLERS, {"comp": TestFlow}):
await asyncio.sleep(0.1)
await asyncio.sleep(0)
assert ("comp/discovery/#", 0) in help_all_subscribe_calls(mqtt_client_mock)
assert not mqtt_client_mock.unsubscribe.called

async_fire_mqtt_message(hass, "comp/discovery/bla/config", "")
await asyncio.sleep(0.1)
await asyncio.sleep(0)
await hass.async_block_till_done()
await hass.async_block_till_done()
mqtt_client_mock.unsubscribe.assert_called_once_with(["comp/discovery/#"])
mqtt_client_mock.unsubscribe.reset_mock()

async_fire_mqtt_message(hass, "comp/discovery/bla/config", "")
await asyncio.sleep(0.1)
await asyncio.sleep(0)
await hass.async_block_till_done()
await hass.async_block_till_done()
assert not mqtt_client_mock.unsubscribe.called

Expand Down