Skip to content

Commit

Permalink
Add options flow test
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-r committed Apr 13, 2024
1 parent 7a16cb6 commit 33b0eae
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions tests/test_config_flow.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""Tests for the config flow."""
from unittest import mock
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_NAME, CONF_PATH
import pytest
from pytest_homeassistant_custom_component.common import MockConfigEntry

from custom_components.ohme import config_flow
from custom_components.ohme.const import DOMAIN
from homeassistant.helpers import config_entry_flow

async def test_step_account(hass):
"""Test the initialization of the form in the first step of the config flow."""
Expand All @@ -26,3 +24,35 @@ async def test_step_account(hass):
}

assert expected == result

async def test_options_flow(hass):
"""Test the options flow."""
entry = MockConfigEntry(domain=config_flow.DOMAIN)
entry.add_to_hass(hass)

flow = config_flow.OhmeOptionsFlow(entry)
result = await config_entry_flow.async_init(
hass, flow, context={"source": "test"}, data={}
)

assert result["type"] == "form"
assert result["step_id"] == "init"
assert result["data_schema"] is not None

result = await config_entry_flow.async_configure(
hass,
flow,
result["step_id"],
{
"email": "[email protected]",
"password": "password123",
"never_session_specific": True,
"enable_accumulative_energy": False,
},
)

assert result["type"] == "create_entry"
assert result["data"] == {
"never_session_specific": True,
"enable_accumulative_energy": False,
}

0 comments on commit 33b0eae

Please sign in to comment.