hass-core/tests/components/ssdp/conftest.py
Steven Looman 73260c5b88
Move parts of ssdp to async_upnp_client ()
* Move parts of ssdp to async_upnp_client

* Fix test for environments with multiple sources

* Fix sonos tests

* More fixes/changes

* More fixes

* Use async_upnp_client==0.21.0

* Pylint/test fixes

* More changes after review

* Fix tests

* Improve testing

* Fix mypy

* Fix yamaha_musiccast tests?

* Changes after review

* Pylint

* Reduce calls to combined_headers

* Update to async_upnp_client==0.21.1

* Update to async_upnp_client==0.21.2

* use as_dict

Co-authored-by: J. Nick Koston <nick@koston.org>
2021-09-11 13:38:16 -10:00

25 lines
923 B
Python

"""Configuration for SSDP tests."""
from unittest.mock import AsyncMock, patch
from async_upnp_client.ssdp_listener import SsdpListener
import pytest
@pytest.fixture(autouse=True)
async def silent_ssdp_listener():
"""Patch SsdpListener class, preventing any actual SSDP traffic."""
with patch("homeassistant.components.ssdp.SsdpListener.async_start"), patch(
"homeassistant.components.ssdp.SsdpListener.async_stop"
), patch("homeassistant.components.ssdp.SsdpListener.async_search"):
# Fixtures are initialized before patches. When the component is started here,
# certain functions/methods might not be patched in time.
yield SsdpListener
@pytest.fixture
def mock_flow_init(hass):
"""Mock hass.config_entries.flow.async_init."""
with patch.object(
hass.config_entries.flow, "async_init", return_value=AsyncMock()
) as mock_init:
yield mock_init