Skip to content

Commit

Permalink
Add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bramstroker committed Aug 9, 2023
1 parent cc5d42e commit c5f431a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/config_flow/test_daily_energy.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@

from homeassistant import data_entry_flow
from homeassistant.const import (
CONF_NAME,
CONF_UNIQUE_ID,
CONF_UNIT_OF_MEASUREMENT,
UnitOfEnergy,
UnitOfPower,
)
from homeassistant.core import HomeAssistant

from custom_components.powercalc import SensorType
from custom_components.powercalc.const import (
CONF_DAILY_FIXED_ENERGY,
CONF_ON_TIME,
CONF_SENSOR_TYPE,
CONF_UPDATE_FREQUENCY,
CONF_VALUE,
Expand Down Expand Up @@ -89,3 +92,30 @@ async def test_daily_energy_options_flow(hass: HomeAssistant) -> None:
== UnitOfPower.WATT
)
assert entry.data[CONF_DAILY_FIXED_ENERGY][CONF_VALUE] == 75


async def test_on_time_option(hass: HomeAssistant) -> None:
result = await select_sensor_type(hass, SensorType.DAILY_ENERGY)

user_input = {
CONF_NAME: "My daily energy sensor",
CONF_UNIQUE_ID: DEFAULT_UNIQUE_ID,
CONF_VALUE: 10,
CONF_UNIT_OF_MEASUREMENT: UnitOfEnergy.KILO_WATT_HOUR,
CONF_ON_TIME: {
"hours": 10,
"minutes": 20,
"seconds": 30,
},
}
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input,
)

assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["data"][CONF_DAILY_FIXED_ENERGY][CONF_ON_TIME] == {
"hours": 10,
"minutes": 20,
"seconds": 30,
}

0 comments on commit c5f431a

Please sign in to comment.