Make network fixture scoped to session to speed up tests (#105353)
parent
4d708f1931
commit
cc85e89cf2
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue