mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Migrate counter tests from coroutine to async/await (#30368)
This commit is contained in:
parent
320dc52bb3
commit
1a2a976be2
@ -1,6 +1,5 @@
|
|||||||
"""The tests for the counter component."""
|
"""The tests for the counter component."""
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.counter import (
|
from homeassistant.components.counter import (
|
||||||
@ -143,8 +142,7 @@ async def test_methods_with_config(hass):
|
|||||||
assert 15 == int(state.state)
|
assert 15 == int(state.state)
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def test_initial_state_overrules_restore_state(hass):
|
||||||
def test_initial_state_overrules_restore_state(hass):
|
|
||||||
"""Ensure states are restored on startup."""
|
"""Ensure states are restored on startup."""
|
||||||
mock_restore_cache(
|
mock_restore_cache(
|
||||||
hass, (State("counter.test1", "11"), State("counter.test2", "-22"))
|
hass, (State("counter.test1", "11"), State("counter.test2", "-22"))
|
||||||
@ -152,7 +150,7 @@ def test_initial_state_overrules_restore_state(hass):
|
|||||||
|
|
||||||
hass.state = CoreState.starting
|
hass.state = CoreState.starting
|
||||||
|
|
||||||
yield from async_setup_component(
|
await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
{
|
{
|
||||||
@ -172,8 +170,7 @@ def test_initial_state_overrules_restore_state(hass):
|
|||||||
assert int(state.state) == 10
|
assert int(state.state) == 10
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def test_restore_state_overrules_initial_state(hass):
|
||||||
def test_restore_state_overrules_initial_state(hass):
|
|
||||||
"""Ensure states are restored on startup."""
|
"""Ensure states are restored on startup."""
|
||||||
|
|
||||||
attr = {"initial": 6, "minimum": 1, "maximum": 8, "step": 2}
|
attr = {"initial": 6, "minimum": 1, "maximum": 8, "step": 2}
|
||||||
@ -189,7 +186,7 @@ def test_restore_state_overrules_initial_state(hass):
|
|||||||
|
|
||||||
hass.state = CoreState.starting
|
hass.state = CoreState.starting
|
||||||
|
|
||||||
yield from async_setup_component(
|
await async_setup_component(
|
||||||
hass, DOMAIN, {DOMAIN: {"test1": {}, "test2": {CONF_INITIAL: 10}, "test3": {}}}
|
hass, DOMAIN, {DOMAIN: {"test1": {}, "test2": {CONF_INITIAL: 10}, "test3": {}}}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -210,12 +207,11 @@ def test_restore_state_overrules_initial_state(hass):
|
|||||||
assert state.attributes.get("step") == 2
|
assert state.attributes.get("step") == 2
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def test_no_initial_state_and_no_restore_state(hass):
|
||||||
def test_no_initial_state_and_no_restore_state(hass):
|
|
||||||
"""Ensure that entity is create without initial and restore feature."""
|
"""Ensure that entity is create without initial and restore feature."""
|
||||||
hass.state = CoreState.starting
|
hass.state = CoreState.starting
|
||||||
|
|
||||||
yield from async_setup_component(hass, DOMAIN, {DOMAIN: {"test1": {CONF_STEP: 5}}})
|
await async_setup_component(hass, DOMAIN, {DOMAIN: {"test1": {CONF_STEP: 5}}})
|
||||||
|
|
||||||
state = hass.states.get("counter.test1")
|
state = hass.states.get("counter.test1")
|
||||||
assert state
|
assert state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user