kopia lustrzana https://github.com/Yakifo/amqtt
check for client connect/disconnect event needed change
rodzic
31bd1638e7
commit
043b6ac881
|
@ -36,8 +36,8 @@ implements one or more of these methods:
|
|||
- `async def on_broker_pre_shutdown(self) -> None`
|
||||
- `async def on_broker_post_shutdown(self) -> None`
|
||||
|
||||
- `async def on_broker_client_connected(self, client_id:str, client_session:Session) -> None`
|
||||
- `async def on_broker_client_disconnected(self, client_id:str, client_session:Session) -> None`
|
||||
- `async def on_broker_client_connected(self, *, client_id:str, client_session:Session) -> None`
|
||||
- `async def on_broker_client_disconnected(self, *, client_id:str, client_session:Session) -> None`
|
||||
|
||||
- `async def on_broker_client_connected(self, *, client_id:str) -> None`
|
||||
- `async def on_broker_client_disconnected(self, *, client_id:str) -> None`
|
||||
|
|
|
@ -85,19 +85,13 @@ async def test_client_connect(broker, mock_plugin_manager):
|
|||
|
||||
await asyncio.sleep(0.01)
|
||||
|
||||
mock_plugin_manager.assert_has_calls(
|
||||
[
|
||||
call().fire_event(
|
||||
BrokerEvents.CLIENT_CONNECTED,
|
||||
client_id=client.session.client_id,
|
||||
),
|
||||
call().fire_event(
|
||||
BrokerEvents.CLIENT_DISCONNECTED,
|
||||
client_id=client.session.client_id,
|
||||
),
|
||||
],
|
||||
any_order=True,
|
||||
)
|
||||
broker.plugins_manager.fire_event.assert_called()
|
||||
assert broker.plugins_manager.fire_event.call_count > 2
|
||||
|
||||
# double indexing is ugly, but call_args_list returns a tuple of tuples
|
||||
events = [c[0][0] for c in broker.plugins_manager.fire_event.call_args_list]
|
||||
assert BrokerEvents.CLIENT_CONNECTED in events
|
||||
assert BrokerEvents.CLIENT_DISCONNECTED in events
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
@ -9,6 +9,7 @@ from paho.mqtt import client as mqtt_client
|
|||
from amqtt.events import BrokerEvents
|
||||
from amqtt.client import MQTTClient
|
||||
from amqtt.mqtt.constants import QOS_1, QOS_2
|
||||
from amqtt.session import Session
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
paho_logger = logging.getLogger("paho_client")
|
||||
|
@ -50,19 +51,15 @@ async def test_paho_connect(broker, mock_plugin_manager):
|
|||
|
||||
await asyncio.wait_for(test_complete.wait(), timeout=5)
|
||||
await asyncio.sleep(0.1)
|
||||
broker.plugins_manager.assert_has_calls(
|
||||
[
|
||||
call.fire_event(
|
||||
BrokerEvents.CLIENT_CONNECTED,
|
||||
client_id=client_id,
|
||||
),
|
||||
call.fire_event(
|
||||
BrokerEvents.CLIENT_DISCONNECTED,
|
||||
client_id=client_id,
|
||||
),
|
||||
],
|
||||
any_order=True,
|
||||
)
|
||||
|
||||
broker.plugins_manager.fire_event.assert_called()
|
||||
assert broker.plugins_manager.fire_event.call_count > 2
|
||||
|
||||
# double indexing is ugly, but call_args_list returns a tuple of tuples
|
||||
events = [c[0][0] for c in broker.plugins_manager.fire_event.call_args_list]
|
||||
assert BrokerEvents.CLIENT_CONNECTED in events
|
||||
assert BrokerEvents.CLIENT_DISCONNECTED in events
|
||||
|
||||
test_client.loop_stop()
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue