Make network fixture scoped to session to speed up tests (#105353)

pull/105376/head
J. Nick Koston 2023-12-08 23:19:08 -10:00 committed by GitHub
parent 4d708f1931
commit cc85e89cf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 13 deletions

View File

@ -40,7 +40,6 @@ from homeassistant.auth.const import GROUP_ID_ADMIN, GROUP_ID_READ_ONLY
from homeassistant.auth.models import Credentials
from homeassistant.auth.providers import homeassistant, legacy_api_password
from homeassistant.components.device_tracker.legacy import Device
from homeassistant.components.network.models import Adapter, IPv4ConfiguredAddress
from homeassistant.components.websocket_api.auth import (
TYPE_AUTH,
TYPE_AUTH_OK,
@ -1096,21 +1095,18 @@ async def mqtt_mock_entry(
yield _setup_mqtt_entry
@pytest.fixture(autouse=True)
@pytest.fixture(autouse=True, scope="session")
def mock_network() -> Generator[None, None, None]:
"""Mock network."""
mock_adapter = Adapter(
name="eth0",
index=0,
enabled=True,
auto=True,
default=True,
ipv4=[IPv4ConfiguredAddress(address="10.10.10.10", network_prefix=24)],
ipv6=[],
)
with patch(
"homeassistant.components.network.network.async_load_adapters",
return_value=[mock_adapter],
"homeassistant.components.network.util.ifaddr.get_adapters",
return_value=[
Mock(
nice_name="eth0",
ips=[Mock(is_IPv6=False, ip="10.10.10.10", network_prefix=24)],
index=0,
)
],
):
yield