win32 test fixes

This commit is contained in:
J. Nick Koston 2024-08-29 11:07:55 -10:00
parent b67b238eb3
commit bbc9390f91
No known key found for this signature in database
4 changed files with 22 additions and 18 deletions

View File

@ -1,15 +1,16 @@
from __future__ import annotations
import asyncio
import logging
import socket
from contextlib import suppress
from datetime import timedelta
from functools import partial
import logging
import socket
from typing import Callable, cast
from unittest.mock import AsyncMock, MagicMock, call, create_autospec, patch
import pytest
from google.protobuf import message
import pytest
from aioesphomeapi import APIClient
from aioesphomeapi._frame_helper import APIPlaintextFrameHelper
@ -59,7 +60,7 @@ KEEP_ALIVE_TIMEOUT_RATIO = 4.5
async def test_connect(
plaintext_connect_task_no_login: tuple[
APIConnection, asyncio.Transport, APIPlaintextFrameHelper, asyncio.Task
]
],
) -> None:
"""Test that a plaintext connection works."""
conn, transport, protocol, connect_task = plaintext_connect_task_no_login
@ -268,7 +269,11 @@ async def test_start_connection_cannot_increase_recv_buffer(
mock_socket.fileno.return_value = 1
mock_socket.getpeername.return_value = ("10.0.0.512", 323)
mock_socket.setsockopt = _setsockopt
with suppress(AttributeError):
mock_socket.sendmsg.side_effect = OSError("Socket error")
mock_socket.send.side_effect = OSError("Socket error")
mock_socket.sendto.side_effect = OSError("Socket error")
aiohappyeyeballs_start_connection.return_value = mock_socket
with patch.object(

View File

@ -1,15 +1,15 @@
from __future__ import annotations
import asyncio
import socket
from ipaddress import IPv6Address, ip_address
import socket
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from zeroconf.asyncio import AsyncServiceInfo, AsyncZeroconf
import aioesphomeapi.host_resolver as hr
from aioesphomeapi.core import APIConnectionError, ResolveAPIError
import aioesphomeapi.host_resolver as hr
from aioesphomeapi.zeroconf import ZeroconfManager

View File

@ -5,12 +5,15 @@ from datetime import timedelta
from functools import partial
from unittest.mock import MagicMock, patch
import pytest
from google.protobuf import message
import pytest
from aioesphomeapi._frame_helper.plain_text import APIPlaintextFrameHelper
from aioesphomeapi.api_pb2 import SubscribeLogsResponse # type: ignore
from aioesphomeapi.api_pb2 import DisconnectRequest, DisconnectResponse
from aioesphomeapi.api_pb2 import (
DisconnectRequest,
DisconnectResponse,
SubscribeLogsResponse, # type: ignore
)
from aioesphomeapi.client import APIClient
from aioesphomeapi.connection import APIConnection
from aioesphomeapi.core import APIConnectionError

View File

@ -2,8 +2,8 @@ from __future__ import annotations
from dataclasses import dataclass, field
import pytest
from google.protobuf import message
import pytest
from aioesphomeapi.api_pb2 import (
AlarmControlPanelStateResponse,
@ -65,14 +65,10 @@ from aioesphomeapi.model import (
APIVersion,
BinarySensorInfo,
BinarySensorState,
)
from aioesphomeapi.model import (
BluetoothGATTCharacteristic as BluetoothGATTCharacteristicModel,
)
from aioesphomeapi.model import BluetoothGATTDescriptor as BluetoothGATTDescriptorModel
from aioesphomeapi.model import BluetoothGATTService as BluetoothGATTServiceModel
from aioesphomeapi.model import BluetoothGATTServices as BluetoothGATTServicesModel
from aioesphomeapi.model import (
BluetoothGATTDescriptor as BluetoothGATTDescriptorModel,
BluetoothGATTService as BluetoothGATTServiceModel,
BluetoothGATTServices as BluetoothGATTServicesModel,
BluetoothProxyFeature,
ButtonInfo,
CameraInfo,