check received counter in unit test

This commit is contained in:
Stefan Allius
2025-05-03 23:34:22 +02:00
parent c5f25b5728
commit 5623231aec
2 changed files with 3 additions and 1 deletions

View File

@@ -91,7 +91,6 @@ class Mqtt(metaclass=Singleton):
async for message in self.__client.messages:
await self.dispatch_msg(message)
self.received += 1
except aiomqtt.MqttError:
self.ctime = None
@@ -119,6 +118,8 @@ class Mqtt(metaclass=Singleton):
f"{traceback.format_exc()}")
async def dispatch_msg(self, message):
self.received += 1
if message.topic.matches(self.ha_status_topic):
status = message.payload.decode("UTF-8")
logger_mqtt.info('Home-Assistant Status:'

View File

@@ -140,6 +140,7 @@ async def test_ha_reconnect(config_mqtt_conn):
assert on_connect.is_set()
finally:
assert m.received == 2
await m.close()
@pytest.mark.asyncio