check received counter in unit test
This commit is contained in:
@@ -91,7 +91,6 @@ class Mqtt(metaclass=Singleton):
|
|||||||
|
|
||||||
async for message in self.__client.messages:
|
async for message in self.__client.messages:
|
||||||
await self.dispatch_msg(message)
|
await self.dispatch_msg(message)
|
||||||
self.received += 1
|
|
||||||
|
|
||||||
except aiomqtt.MqttError:
|
except aiomqtt.MqttError:
|
||||||
self.ctime = None
|
self.ctime = None
|
||||||
@@ -119,6 +118,8 @@ class Mqtt(metaclass=Singleton):
|
|||||||
f"{traceback.format_exc()}")
|
f"{traceback.format_exc()}")
|
||||||
|
|
||||||
async def dispatch_msg(self, message):
|
async def dispatch_msg(self, message):
|
||||||
|
self.received += 1
|
||||||
|
|
||||||
if message.topic.matches(self.ha_status_topic):
|
if message.topic.matches(self.ha_status_topic):
|
||||||
status = message.payload.decode("UTF-8")
|
status = message.payload.decode("UTF-8")
|
||||||
logger_mqtt.info('Home-Assistant Status:'
|
logger_mqtt.info('Home-Assistant Status:'
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ async def test_ha_reconnect(config_mqtt_conn):
|
|||||||
assert on_connect.is_set()
|
assert on_connect.is_set()
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
assert m.received == 2
|
||||||
await m.close()
|
await m.close()
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|||||||
Reference in New Issue
Block a user