Mock out network.util.async_get_source_ip in tests (#56339)

pull/56376/head
Erik Montnemery 2021-09-18 09:40:58 +02:00 committed by GitHub
parent 0830100df1
commit be0819b456
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 3 deletions

View File

@ -29,6 +29,6 @@ def recorder_url_mock():
yield yield
async def test_setup(hass, mock_zeroconf): async def test_setup(hass, mock_zeroconf, mock_get_source_ip):
"""Test setup.""" """Test setup."""
assert await async_setup_component(hass, "default_config", {"foo": "bar"}) assert await async_setup_component(hass, "default_config", {"foo": "bar"})

View File

@ -14,7 +14,7 @@ from homeassistant.setup import async_setup_component
from tests.components.logbook.test_init import MockLazyEventPartialState from tests.components.logbook.test_init import MockLazyEventPartialState
async def test_humanify_homekit_changed_event(hass, hk_driver): async def test_humanify_homekit_changed_event(hass, hk_driver, mock_get_source_ip):
"""Test humanifying HomeKit changed event.""" """Test humanifying HomeKit changed event."""
hass.config.components.add("recorder") hass.config.components.add("recorder")
with patch("homeassistant.components.homekit.HomeKit"): with patch("homeassistant.components.homekit.HomeKit"):

View File

@ -238,7 +238,7 @@ def test_density_to_air_quality():
assert density_to_air_quality(300) == 5 assert density_to_air_quality(300) == 5
async def test_show_setup_msg(hass, hk_driver): async def test_show_setup_msg(hass, hk_driver, mock_get_source_ip):
"""Test show setup message as persistence notification.""" """Test show setup message as persistence notification."""
pincode = b"123-45-678" pincode = b"123-45-678"

View File

@ -202,3 +202,9 @@ def alarm_event_fixture(soco):
} }
return SonosMockEvent(soco, soco.alarmClock, variables) return SonosMockEvent(soco, soco.alarmClock, variables)
@pytest.fixture(autouse=True)
def mock_get_source_ip(mock_get_source_ip):
"""Mock network util's async_get_source_ip in all sonos tests."""
return mock_get_source_ip