-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.""" | ||
|
@@ -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, | ||
} |