Mock out network.util.async_get_source_ip in tests (#55592)
This commit is contained in:
parent
363320eedb
commit
7dbe8070f7
12 changed files with 159 additions and 80 deletions
|
@ -33,7 +33,7 @@ def _mock_config_entry_with_options_populated():
|
|||
)
|
||||
|
||||
|
||||
async def test_setup_in_bridge_mode(hass):
|
||||
async def test_setup_in_bridge_mode(hass, mock_get_source_ip):
|
||||
"""Test we can setup a new instance in bridge mode."""
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -83,7 +83,7 @@ async def test_setup_in_bridge_mode(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_setup_in_bridge_mode_name_taken(hass):
|
||||
async def test_setup_in_bridge_mode_name_taken(hass, mock_get_source_ip):
|
||||
"""Test we can setup a new instance in bridge mode when the name is taken."""
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
|
||||
|
@ -141,7 +141,9 @@ async def test_setup_in_bridge_mode_name_taken(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 2
|
||||
|
||||
|
||||
async def test_setup_creates_entries_for_accessory_mode_devices(hass):
|
||||
async def test_setup_creates_entries_for_accessory_mode_devices(
|
||||
hass, mock_get_source_ip
|
||||
):
|
||||
"""Test we can setup a new instance and we create entries for accessory mode devices."""
|
||||
hass.states.async_set("camera.one", "on")
|
||||
hass.states.async_set("camera.existing", "on")
|
||||
|
@ -231,7 +233,7 @@ async def test_setup_creates_entries_for_accessory_mode_devices(hass):
|
|||
assert len(mock_setup_entry.mock_calls) == 7
|
||||
|
||||
|
||||
async def test_import(hass):
|
||||
async def test_import(hass, mock_get_source_ip):
|
||||
"""Test we can import instance."""
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
|
||||
|
@ -275,7 +277,7 @@ async def test_import(hass):
|
|||
|
||||
|
||||
@pytest.mark.parametrize("auto_start", [True, False])
|
||||
async def test_options_flow_exclude_mode_advanced(auto_start, hass):
|
||||
async def test_options_flow_exclude_mode_advanced(auto_start, hass, mock_get_source_ip):
|
||||
"""Test config flow options in exclude mode with advanced options."""
|
||||
|
||||
config_entry = _mock_config_entry_with_options_populated()
|
||||
|
@ -326,7 +328,7 @@ async def test_options_flow_exclude_mode_advanced(auto_start, hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_options_flow_exclude_mode_basic(hass):
|
||||
async def test_options_flow_exclude_mode_basic(hass, mock_get_source_ip):
|
||||
"""Test config flow options in exclude mode."""
|
||||
|
||||
config_entry = _mock_config_entry_with_options_populated()
|
||||
|
@ -368,7 +370,7 @@ async def test_options_flow_exclude_mode_basic(hass):
|
|||
|
||||
|
||||
async def test_options_flow_devices(
|
||||
mock_hap, hass, demo_cleanup, device_reg, entity_reg
|
||||
mock_hap, hass, demo_cleanup, device_reg, entity_reg, mock_get_source_ip
|
||||
):
|
||||
"""Test devices can be bridged."""
|
||||
config_entry = _mock_config_entry_with_options_populated()
|
||||
|
@ -431,7 +433,9 @@ async def test_options_flow_devices(
|
|||
}
|
||||
|
||||
|
||||
async def test_options_flow_devices_preserved_when_advanced_off(mock_hap, hass):
|
||||
async def test_options_flow_devices_preserved_when_advanced_off(
|
||||
mock_hap, hass, mock_get_source_ip
|
||||
):
|
||||
"""Test devices are preserved if they were added in advanced mode but it was turned off."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -499,7 +503,7 @@ async def test_options_flow_devices_preserved_when_advanced_off(mock_hap, hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_options_flow_include_mode_basic(hass):
|
||||
async def test_options_flow_include_mode_basic(hass, mock_get_source_ip):
|
||||
"""Test config flow options in include mode."""
|
||||
|
||||
config_entry = _mock_config_entry_with_options_populated()
|
||||
|
@ -542,7 +546,7 @@ async def test_options_flow_include_mode_basic(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_options_flow_exclude_mode_with_cameras(hass):
|
||||
async def test_options_flow_exclude_mode_with_cameras(hass, mock_get_source_ip):
|
||||
"""Test config flow options in exclude mode with cameras."""
|
||||
|
||||
config_entry = _mock_config_entry_with_options_populated()
|
||||
|
@ -645,7 +649,7 @@ async def test_options_flow_exclude_mode_with_cameras(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_options_flow_include_mode_with_cameras(hass):
|
||||
async def test_options_flow_include_mode_with_cameras(hass, mock_get_source_ip):
|
||||
"""Test config flow options in include mode with cameras."""
|
||||
|
||||
config_entry = _mock_config_entry_with_options_populated()
|
||||
|
@ -772,7 +776,7 @@ async def test_options_flow_include_mode_with_cameras(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_options_flow_blocked_when_from_yaml(hass):
|
||||
async def test_options_flow_blocked_when_from_yaml(hass, mock_get_source_ip):
|
||||
"""Test config flow options."""
|
||||
|
||||
config_entry = MockConfigEntry(
|
||||
|
@ -812,7 +816,7 @@ async def test_options_flow_blocked_when_from_yaml(hass):
|
|||
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_options_flow_include_mode_basic_accessory(hass):
|
||||
async def test_options_flow_include_mode_basic_accessory(hass, mock_get_source_ip):
|
||||
"""Test config flow options in include mode with a single accessory."""
|
||||
|
||||
config_entry = _mock_config_entry_with_options_populated()
|
||||
|
@ -867,7 +871,7 @@ async def test_options_flow_include_mode_basic_accessory(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_converting_bridge_to_accessory_mode(hass, hk_driver):
|
||||
async def test_converting_bridge_to_accessory_mode(hass, hk_driver, mock_get_source_ip):
|
||||
"""Test we can convert a bridge to accessory mode."""
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue