Add missing asserts to enphase_envoy config flow test (#133730)

This commit is contained in:
Arie Catsman 2024-12-21 15:20:10 +01:00 committed by GitHub
parent 9292bfc6ed
commit ef31413a59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -11,13 +11,10 @@ rules:
config-flow-test-coverage:
status: todo
comment: |
- test_form is missing an assertion for the unique id of the resulting entry
- Let's also have test_user_no_serial_number assert the unique_id (as in, it can't be set to the serial_number since we dont have one, so let's assert what it will result in)
- Let's have every test result in either CREATE_ENTRY or ABORT (like test_form_invalid_auth or test_form_cannot_connect, they can be parametrized)
- test_zeroconf_token_firmware and test_zeroconf_pre_token_firmware can also be parametrized I think
- test_zero_conf_malformed_serial_property - with pytest.raises(KeyError) as ex::
I don't believe this should be able to raise a KeyError Shouldn't we abort the flow?
test_reauth -> Let's also assert result before we start with the async_configure part
config-flow:
status: todo
comment: |

View File

@ -49,6 +49,7 @@ async def test_form(
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Envoy 1234"
assert result["result"].unique_id == "1234"
assert result["data"] == {
CONF_HOST: "1.1.1.1",
CONF_NAME: "Envoy 1234",
@ -80,6 +81,7 @@ async def test_user_no_serial_number(
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Envoy"
assert result["result"].unique_id is None
assert result["data"] == {
CONF_HOST: "1.1.1.1",
CONF_NAME: "Envoy",
@ -100,6 +102,8 @@ async def test_form_invalid_auth(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
@ -131,6 +135,8 @@ async def test_form_cannot_connect(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
@ -634,6 +640,8 @@ async def test_reauth(
"""Test we reauth auth."""
await setup_integration(hass, config_entry)
result = await config_entry.start_reauth_flow(hass)
assert result["type"] is FlowResultType.FORM
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{