async def test_sendToNode(gateway: ZIPGateway): connection = await gateway.connectToNode(6) [res, _] = await asyncio.gather( gateway.sendToNode(6, Basic.Get()), runDelayed(connection.ackReceived, Zip.ZipPacket(seqNo=1)), ) assert res == True
async def test_ipOfNode(gateway: ZIPGateway): # pylint: disable=line-too-long pkt = b"X\x01\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xc0\xa8\x00\xee\xea\xec\xfa\xf9" zipNodeAdvertisement = Message.decode(pkt) [reply, _] = await asyncio.gather( gateway.ipOfNode(6), runDelayed(gateway.commandReceived, zipNodeAdvertisement)) assert reply == ipaddress.IPv6Address("::ffff:c0a8:ee")
async def test_getMultiChannelEndPoints(gateway: ZIPGateway): gateway.send = sendNop [endpoints, _] = await asyncio.gather( gateway.getMultiChannelEndPoints(1), runDelayed( gateway.commandReceived, NetworkManagementProxy.MultiChannelEndPointReport( individualEndPoints=2, aggregatedEndPoints=0), ), ) assert endpoints == 2
async def test_getMultiChannelCapability(gateway: ZIPGateway): gateway.send = sendNop [report, _] = await asyncio.gather( gateway.getMultiChannelCapability(1, 1), runDelayed( gateway.commandReceived, NetworkManagementProxy.MultiChannelCapabilityReport(), ), ) assert isinstance(report, NetworkManagementProxy.MultiChannelCapabilityReport)
async def test_removeFailedNode(gateway: ZIPGateway): gateway.send = sendNop [status, _] = await asyncio.gather( gateway.removeFailedNode(42), runDelayed( gateway.commandReceived, NetworkManagementInclusion.FailedNodeRemoveStatus( status=NetworkManagementInclusion.FailedNodeRemoveStatus. Status.DONE), ), ) assert status == NetworkManagementInclusion.FailedNodeRemoveStatus.Status.DONE
async def test_getNodeInfo(gateway: ZIPGateway): # pylint: disable=line-too-long cachedNodeInfoReport = Message.decode( b"R\x04\x03\x1b\x9c\x9c\x00\x04\x10\x01^%'\x85\\pru\x86ZYszh#") gateway.send = sendNop [nodeInfo, _] = await asyncio.gather( gateway.getNodeInfo(1), runDelayed(gateway.commandReceived, cachedNodeInfoReport), ) assert isinstance(nodeInfo, NetworkManagementProxy.NodeInfoCachedReport) assert nodeInfo == cachedNodeInfoReport
async def test_getFailedNodeList(gateway: ZIPGateway): # pylint: disable=line-too-long failedNodeListReport = Message.decode( b"R\x0C\x02!\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" ) gateway.send = sendNop [nodeList, _] = await asyncio.gather( gateway.getFailedNodeList(), runDelayed(gateway.commandReceived, failedNodeListReport), ) assert nodeList == {1, 6}
async def test_setupUnsolicitedConnection(gateway: ZIPGateway): gateway._nodes = {1: {}} await asyncio.gather( gateway.setupUnsolicitedConnection(), runDelayed( gateway.commandReceived, ZipND.ZipNodeAdvertisement( local=False, validity=0, nodeId=1, ipv6=ipaddress.IPv6Address("2001:db8::1"), homeId=0x12345678, ), ), ) assert gateway._nodes == {1: {"ip": IPv6("2001:db8::1")}}
async def test_getNodeList(gateway: ZIPGateway): # pylint: disable=line-too-long nodeListReport = Message.decode( b"R\x02\x02\x00\x01!\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" ) async def dummySend(_msg): pass gateway.send = dummySend assert gateway.nodeId == 0 [nodeList, _] = await asyncio.gather( gateway.getNodeList(), runDelayed(gateway.commandReceived, nodeListReport)) assert nodeList == {1, 6} assert gateway._nodes == {1: {}, 6: {}} assert gateway.nodeId == 1