marking test broker sys plugin as xfail

pull/216/head
Andrew Mirsky 2025-06-14 15:10:40 -04:00
rodzic aace4d65f7
commit 5abeabc36d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: A98E67635CDF2C39
1 zmienionych plików z 48 dodań i 46 usunięć

Wyświetl plik

@ -13,49 +13,51 @@ from amqtt.mqtt.constants import QOS_0
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# test broker sys # test broker sys
# @pytest.mark.asyncio @pytest.mark.asyncio
# async def test_broker_sys_plugin() -> None: @pytest.mark.xfail(
# reason="see https://github.com/Yakifo/amqtt/issues/215",
# class MockEntryPoints: strict=True,
# )
# def select(self, group) -> list[EntryPoint]: async def test_broker_sys_plugin() -> None:
# match group:
# case 'tests.mock_plugins': class MockEntryPoints:
# return [
# EntryPoint(name='BrokerSysPlugin', group='tests.mock_plugins', value='amqtt.plugins.sys.broker:BrokerSysPlugin'), def select(self, group) -> list[EntryPoint]:
# ] match group:
# case _: case 'tests.mock_plugins':
# return list() return [
# EntryPoint(name='BrokerSysPlugin', group='tests.mock_plugins', value='amqtt.plugins.sys.broker:BrokerSysPlugin'),
# ]
# with patch("amqtt.plugins.manager.entry_points", side_effect=MockEntryPoints) as mocked_mqtt_publish: case _:
# return list()
# config = {
# "listeners": { with patch("amqtt.plugins.manager.entry_points", side_effect=MockEntryPoints) as mocked_mqtt_publish:
# "default": {"type": "tcp", "bind": "127.0.0.1:1883", "max_connections": 10},
# }, config = {
# 'sys_interval': 1 "listeners": {
# } "default": {"type": "tcp", "bind": "127.0.0.1:1883", "max_connections": 10},
# },
# broker = Broker(plugin_namespace='tests.mock_plugins', config=config) 'sys_interval': 1
# await broker.start() }
# client = MQTTClient()
# await client.connect("mqtt://127.0.0.1:1883/") broker = Broker(plugin_namespace='tests.mock_plugins', config=config)
# await client.subscribe([("$SYS/broker/uptime", QOS_0),]) await broker.start()
# await client.publish('test/topic', b'my test message') client = MQTTClient()
# await asyncio.sleep(2) await client.connect("mqtt://127.0.0.1:1883/")
# sys_msg_count = 0 await client.subscribe([("$SYS/broker/uptime", QOS_0),])
# try: await client.publish('test/topic', b'my test message')
# while True: await asyncio.sleep(2)
# message = await client.deliver_message(timeout_duration=0.5) sys_msg_count = 0
# if '$SYS' in message.topic: try:
# sys_msg_count += 1 while True:
# except asyncio.TimeoutError: message = await client.deliver_message(timeout_duration=0.5)
# pass if '$SYS' in message.topic:
# sys_msg_count += 1
# logger.warning(f">>> sys message: {message.topic} - {message.data}") except asyncio.TimeoutError:
# await client.disconnect() pass
# await broker.shutdown()
# logger.warning(f">>> sys message: {message.topic} - {message.data}")
# await client.disconnect()
# assert sys_msg_count > 1 await broker.shutdown()
assert sys_msg_count > 1