From 0a0e4eb53adccdd4a8e16b0af0cee1dd2bd7792d Mon Sep 17 00:00:00 2001 From: Hamid Abubakr Date: Wed, 12 Jun 2024 18:03:44 +0400 Subject: [PATCH] fix request concurrency test --- tests/application/test_requests.py | 22 +++++++++------------- tests/conftest.py | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/tests/application/test_requests.py b/tests/application/test_requests.py index 0ae3c1c..be3d952 100644 --- a/tests/application/test_requests.py +++ b/tests/application/test_requests.py @@ -291,6 +291,11 @@ async def test_request_concurrency(make_application, mocker): device = app.add_initialized_device(ieee=t.EUI64(range(8)), nwk=0xAABB) + ep = device.add_endpoint(1) + ep.status = zigpy.endpoint.Status.ZDO_INIT + ep.profile_id = 260 + ep.add_input_cluster(6) + # Keep track of how many requests we receive at once in_flight_requests = 0 did_lock = False @@ -304,7 +309,7 @@ async def callback(req): did_lock = True in_flight_requests += 1 - assert in_flight_requests <= 10 + assert in_flight_requests <= 2 await asyncio.sleep(0.1) await zboss_server.send(c.APS.DataReq.Rsp( @@ -317,17 +322,6 @@ async def callback(req): TxTime=1, DstAddrMode=req.DstAddrMode, )) - await asyncio.sleep(0.01) - await zboss_server.send( - c.APS.DataIndication.Ind( - ParamLength=21, PayloadLength=None, FrameFC=None, - SrcAddr=None, DstAddr=None, GrpAddr=None, DstEndpoint=1, - SrcEndpoint=1, ClusterId=6, ProfileId=260, - PacketCounter=None, SrcMACAddr=None, DstMACAddr=None, - LQI=None, - RSSI=None, KeySrcAndAttr=None, Payload=None, partial=True - ) - ) await asyncio.sleep(0) in_flight_requests -= 1 @@ -336,7 +330,9 @@ async def callback(req): asyncio.create_task(callback(req)) zboss_server.reply_to( - request=c.APS.DataReq.Req(partial=True), responses=[make_response] + request=c.APS.DataReq.Req( + partial=True), responses=[make_response] + ) # We create a whole bunch at once diff --git a/tests/conftest.py b/tests/conftest.py index c4dc62b..e5c567b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -543,7 +543,7 @@ def get_short_addr(self, request): NWKAddr=t.NWK(0x1234) # Example NWK address ) - @reply_to(c.APS.DataReq.Req(partial=True)) + @reply_to(c.APS.DataReq.Req(partial=True, DstEndpoint=0)) def on_zdo_request(self, req): # kwargs = deserialize_zdo_command(req.ClusterId, req.Payload) # handler_name = f"on_zdo_{zdo_t.ZDOCmd(req.ClusterId).name.lower()}"