mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Make network fixture scoped to session to speed up tests (#105353)
This commit is contained in:
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.models import Credentials
|
||||||
from homeassistant.auth.providers import homeassistant, legacy_api_password
|
from homeassistant.auth.providers import homeassistant, legacy_api_password
|
||||||
from homeassistant.components.device_tracker.legacy import Device
|
from homeassistant.components.device_tracker.legacy import Device
|
||||||
from homeassistant.components.network.models import Adapter, IPv4ConfiguredAddress
|
|
||||||
from homeassistant.components.websocket_api.auth import (
|
from homeassistant.components.websocket_api.auth import (
|
||||||
TYPE_AUTH,
|
TYPE_AUTH,
|
||||||
TYPE_AUTH_OK,
|
TYPE_AUTH_OK,
|
||||||
@ -1096,21 +1095,18 @@ async def mqtt_mock_entry(
|
|||||||
yield _setup_mqtt_entry
|
yield _setup_mqtt_entry
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True, scope="session")
|
||||||
def mock_network() -> Generator[None, None, None]:
|
def mock_network() -> Generator[None, None, None]:
|
||||||
"""Mock network."""
|
"""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(
|
with patch(
|
||||||
"homeassistant.components.network.network.async_load_adapters",
|
"homeassistant.components.network.util.ifaddr.get_adapters",
|
||||||
return_value=[mock_adapter],
|
return_value=[
|
||||||
|
Mock(
|
||||||
|
nice_name="eth0",
|
||||||
|
ips=[Mock(is_IPv6=False, ip="10.10.10.10", network_prefix=24)],
|
||||||
|
index=0,
|
||||||
|
)
|
||||||
|
],
|
||||||
):
|
):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user