Clean up RFXtrx tests (#67278)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>pull/66393/head^2
parent
deda9e38e4
commit
494ae9aef6
|
@ -35,6 +35,16 @@ def com_port():
|
|||
return port
|
||||
|
||||
|
||||
async def start_options_flow(hass, entry):
|
||||
"""Start the options flow with the entry under test."""
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
return await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
|
||||
@patch("homeassistant.components.rfxtrx.rfxtrxmod.PyNetworkTransport", autospec=True)
|
||||
async def test_setup_network(transport_mock, hass):
|
||||
"""Test we can setup network."""
|
||||
|
@ -293,9 +303,8 @@ async def test_options_global(hass):
|
|||
},
|
||||
unique_id=DOMAIN,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
with patch("homeassistant.components.rfxtrx.async_setup_entry", return_value=True):
|
||||
result = await start_options_flow(hass, entry)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
@ -329,9 +338,8 @@ async def test_no_protocols(hass):
|
|||
},
|
||||
unique_id=DOMAIN,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
with patch("homeassistant.components.rfxtrx.async_setup_entry", return_value=True):
|
||||
result = await start_options_flow(hass, entry)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
@ -364,9 +372,7 @@ async def test_options_add_device(hass):
|
|||
},
|
||||
unique_id=DOMAIN,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
result = await start_options_flow(hass, entry)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
@ -467,10 +473,7 @@ async def test_options_replace_sensor_device(hass):
|
|||
},
|
||||
unique_id=DOMAIN,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await start_options_flow(hass, entry)
|
||||
|
||||
state = hass.states.get(
|
||||
"sensor.thgn122_123_thgn132_thgr122_228_238_268_f0_04_rssi_numeric"
|
||||
|
@ -633,10 +636,7 @@ async def test_options_replace_control_device(hass):
|
|||
},
|
||||
unique_id=DOMAIN,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await start_options_flow(hass, entry)
|
||||
|
||||
state = hass.states.get("binary_sensor.ac_118cdea_2")
|
||||
assert state
|
||||
|
@ -732,9 +732,7 @@ async def test_options_add_and_configure_device(hass):
|
|||
},
|
||||
unique_id=DOMAIN,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
result = await start_options_flow(hass, entry)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
@ -848,12 +846,7 @@ async def test_options_configure_rfy_cover_device(hass):
|
|||
},
|
||||
unique_id=DOMAIN,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
result = await start_options_flow(hass, entry)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
|
|
@ -131,9 +131,9 @@ async def test_connect(hass):
|
|||
entry_data = create_rfx_test_cfg(device="/dev/ttyUSBfake")
|
||||
mock_entry = MockConfigEntry(domain="rfxtrx", unique_id=DOMAIN, data=entry_data)
|
||||
|
||||
with patch.object(rfxtrxmod, "Connect") as connect:
|
||||
mock_entry.add_to_hass(hass)
|
||||
mock_entry.add_to_hass(hass)
|
||||
|
||||
with patch.object(rfxtrxmod, "Connect") as connect:
|
||||
await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -145,9 +145,9 @@ async def test_connect_with_protocols(hass):
|
|||
entry_data = create_rfx_test_cfg(device="/dev/ttyUSBfake", protocols=SOME_PROTOCOLS)
|
||||
mock_entry = MockConfigEntry(domain="rfxtrx", unique_id=DOMAIN, data=entry_data)
|
||||
|
||||
with patch.object(rfxtrxmod, "Connect") as connect:
|
||||
mock_entry.add_to_hass(hass)
|
||||
mock_entry.add_to_hass(hass)
|
||||
|
||||
with patch.object(rfxtrxmod, "Connect") as connect:
|
||||
await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
|
Loading…
Reference in New Issue