From 8b98b363b9e5cc160093d0b6a40570184e075080 Mon Sep 17 00:00:00 2001 From: Yeh Tso-Hsin Date: Fri, 10 Nov 2023 16:34:06 +0800 Subject: [PATCH] Fix pytype error accessing ScanningResponse fields. --- avatar/cases/le_host_test.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/avatar/cases/le_host_test.py b/avatar/cases/le_host_test.py index 8af96fa..967fa4a 100644 --- a/avatar/cases/le_host_test.py +++ b/avatar/cases/le_host_test.py @@ -35,6 +35,7 @@ from pandora.host_pb2 import Connection from pandora.host_pb2 import DataTypes from pandora.host_pb2 import OwnAddressType +from pandora.host_pb2 import ScanningResponse from typing import Any, Dict, Literal, Optional, Union @@ -200,12 +201,12 @@ async def test_connect(self, ref_address_type: OwnAddressType) -> None: ) scan = self.dut.aio.host.Scan(own_address_type=RANDOM, timeout=self.scan_timeout) - ref = await anext((x async for x in scan if x.data.manufacturer_specific_data == b'pause cafe')) + ref: ScanningResponse = await anext((x async for x in scan if x.data.manufacturer_specific_data == b'pause cafe')) scan.cancel() ref_dut_res, dut_ref_res = await asyncio.gather( anext(aiter(advertise)), - self.dut.aio.host.ConnectLE(**ref.address_asdict(), own_address_type=RANDOM, timeout=self.scan_timeout), + self.dut.aio.host.ConnectLE(public=ref.public, public_identity=ref.public_identity, random=ref.random, random_static_identity=ref.random_static_identity, own_address_type=RANDOM, timeout=self.scan_timeout), ) assert_equal(dut_ref_res.result_variant(), 'connection') dut_ref, ref_dut = dut_ref_res.connection, ref_dut_res.connection @@ -228,12 +229,12 @@ async def test_disconnect(self, ref_address_type: OwnAddressType) -> None: ) scan = self.dut.aio.host.Scan(own_address_type=RANDOM, timeout=self.scan_timeout) - ref = await anext((x async for x in scan if x.data.manufacturer_specific_data == b'pause cafe')) + ref: ScanningResponse = await anext((x async for x in scan if x.data.manufacturer_specific_data == b'pause cafe')) scan.cancel() ref_dut_res, dut_ref_res = await asyncio.gather( anext(aiter(advertise)), - self.dut.aio.host.ConnectLE(**ref.address_asdict(), own_address_type=RANDOM, timeout=self.scan_timeout), + self.dut.aio.host.ConnectLE(public=ref.public, public_identity=ref.public_identity, random=ref.random, random_static_identity=ref.random_static_identity, own_address_type=RANDOM, timeout=self.scan_timeout), ) assert_equal(dut_ref_res.result_variant(), 'connection') dut_ref, ref_dut = dut_ref_res.connection, ref_dut_res.connection