-
Notifications
You must be signed in to change notification settings - Fork 274
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
1 parent
c3845e4
commit d875291
Showing
6 changed files
with
62 additions
and
7 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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import logging | ||
|
||
import pytest | ||
from homeassistant.const import CONF_ENTITY_ID, CONF_NAME, STATE_ON | ||
from homeassistant.core import HomeAssistant | ||
|
||
from custom_components.powercalc.const import CONF_CUSTOM_FIELDS, CONF_MANUFACTURER, CONF_MODEL, DUMMY_ENTITY_ID | ||
from tests.common import get_test_config_dir, run_powercalc_setup | ||
|
||
|
||
async def test_custom_field_variables_from_yaml_config(hass: HomeAssistant, caplog: pytest.LogCaptureFixture) -> None: | ||
caplog.set_level(logging.ERROR) | ||
hass.config.config_dir = get_test_config_dir() | ||
|
||
hass.states.async_set("sensor.test", STATE_ON) | ||
await hass.async_block_till_done() | ||
|
||
await run_powercalc_setup( | ||
hass, | ||
{ | ||
CONF_ENTITY_ID: DUMMY_ENTITY_ID, | ||
CONF_NAME: "Test", | ||
CONF_MANUFACTURER: "test", | ||
CONF_MODEL: "custom-fields", | ||
CONF_CUSTOM_FIELDS: { | ||
"some_entity": "sensor.test", | ||
}, | ||
}, | ||
) | ||
|
||
assert not caplog.records | ||
|
||
assert hass.states.get("sensor.test_power").state == "20.00" |