Update input component tests to async (#18290)

pull/18296/head
Adam Mills 2018-11-07 03:56:32 -05:00 committed by Paulus Schoutsen
parent ce069be16e
commit 65be458ce0
5 changed files with 473 additions and 549 deletions

View File

@ -1,65 +1,22 @@
"""The tests for the input_boolean component."""
# pylint: disable=protected-access
import asyncio
import unittest
import logging
from homeassistant.core import CoreState, State, Context
from homeassistant.setup import setup_component, async_setup_component
from homeassistant.setup import async_setup_component
from homeassistant.components.input_boolean import (
is_on, CONF_INITIAL, DOMAIN)
from homeassistant.const import (
STATE_ON, STATE_OFF, ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME, ATTR_ICON,
SERVICE_TOGGLE, SERVICE_TURN_OFF, SERVICE_TURN_ON)
from homeassistant.loader import bind_hass
from tests.common import (
get_test_home_assistant, mock_component, mock_restore_cache)
from tests.common import mock_component, mock_restore_cache
_LOGGER = logging.getLogger(__name__)
@bind_hass
def toggle(hass, entity_id):
"""Set input_boolean to False.
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: entity_id})
@bind_hass
def turn_on(hass, entity_id):
"""Set input_boolean to True.
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id})
@bind_hass
def turn_off(hass, entity_id):
"""Set input_boolean to False.
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id})
class TestInputBoolean(unittest.TestCase):
"""Test the input boolean module."""
# pylint: disable=invalid-name
def setUp(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
def test_config(self):
async def test_config(hass):
"""Test config."""
invalid_configs = [
None,
@ -69,42 +26,47 @@ class TestInputBoolean(unittest.TestCase):
]
for cfg in invalid_configs:
assert not setup_component(self.hass, DOMAIN, {DOMAIN: cfg})
assert not await async_setup_component(hass, DOMAIN, {DOMAIN: cfg})
def test_methods(self):
async def test_methods(hass):
"""Test is_on, turn_on, turn_off methods."""
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_1': None,
}})
entity_id = 'input_boolean.test_1'
assert not is_on(self.hass, entity_id)
assert not is_on(hass, entity_id)
turn_on(self.hass, entity_id)
await hass.services.async_call(
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id})
self.hass.block_till_done()
await hass.async_block_till_done()
assert is_on(self.hass, entity_id)
assert is_on(hass, entity_id)
turn_off(self.hass, entity_id)
await hass.services.async_call(
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id})
self.hass.block_till_done()
await hass.async_block_till_done()
assert not is_on(self.hass, entity_id)
assert not is_on(hass, entity_id)
toggle(self.hass, entity_id)
await hass.services.async_call(
DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: entity_id})
self.hass.block_till_done()
await hass.async_block_till_done()
assert is_on(self.hass, entity_id)
assert is_on(hass, entity_id)
def test_config_options(self):
async def test_config_options(hass):
"""Test configuration options."""
count_start = len(self.hass.states.entity_ids())
count_start = len(hass.states.async_entity_ids())
_LOGGER.debug('ENTITIES @ start: %s', self.hass.states.entity_ids())
_LOGGER.debug('ENTITIES @ start: %s', hass.states.async_entity_ids())
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_1': None,
'test_2': {
'name': 'Hello World',
@ -113,12 +75,12 @@ class TestInputBoolean(unittest.TestCase):
},
}})
_LOGGER.debug('ENTITIES: %s', self.hass.states.entity_ids())
_LOGGER.debug('ENTITIES: %s', hass.states.async_entity_ids())
assert count_start + 2 == len(self.hass.states.entity_ids())
assert count_start + 2 == len(hass.states.async_entity_ids())
state_1 = self.hass.states.get('input_boolean.test_1')
state_2 = self.hass.states.get('input_boolean.test_2')
state_1 = hass.states.get('input_boolean.test_1')
state_2 = hass.states.get('input_boolean.test_2')
assert state_1 is not None
assert state_2 is not None

View File

@ -1,15 +1,14 @@
"""Tests for the Input slider component."""
# pylint: disable=protected-access
import asyncio
import unittest
import datetime
from homeassistant.core import CoreState, State, Context
from homeassistant.setup import setup_component, async_setup_component
from homeassistant.setup import async_setup_component
from homeassistant.components.input_datetime import (
DOMAIN, ATTR_ENTITY_ID, ATTR_DATE, ATTR_TIME, SERVICE_SET_DATETIME)
from tests.common import get_test_home_assistant, mock_restore_cache
from tests.common import mock_restore_cache
async def async_set_datetime(hass, entity_id, dt_value):
@ -21,20 +20,7 @@ async def async_set_datetime(hass, entity_id, dt_value):
}, blocking=True)
class TestInputDatetime(unittest.TestCase):
"""Test the input datetime component."""
# pylint: disable=invalid-name
def setUp(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
def test_invalid_configs(self):
async def test_invalid_configs(hass):
"""Test config."""
invalid_configs = [
None,
@ -46,7 +32,7 @@ class TestInputDatetime(unittest.TestCase):
}},
]
for cfg in invalid_configs:
assert not setup_component(self.hass, DOMAIN, {DOMAIN: cfg})
assert not await async_setup_component(hass, DOMAIN, {DOMAIN: cfg})
@asyncio.coroutine

View File

@ -1,7 +1,6 @@
"""The tests for the Input number component."""
# pylint: disable=protected-access
import asyncio
import unittest
from homeassistant.core import CoreState, State, Context
from homeassistant.components.input_number import (
@ -9,9 +8,9 @@ from homeassistant.components.input_number import (
SERVICE_SET_VALUE)
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.loader import bind_hass
from homeassistant.setup import setup_component, async_setup_component
from homeassistant.setup import async_setup_component
from tests.common import get_test_home_assistant, mock_restore_cache
from tests.common import mock_restore_cache
@bind_hass
@ -20,10 +19,11 @@ def set_value(hass, entity_id, value):
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(DOMAIN, SERVICE_SET_VALUE, {
hass.async_create_task(hass.services.async_call(
DOMAIN, SERVICE_SET_VALUE, {
ATTR_ENTITY_ID: entity_id,
ATTR_VALUE: value,
})
}))
@bind_hass
@ -32,9 +32,10 @@ def increment(hass, entity_id):
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(DOMAIN, SERVICE_INCREMENT, {
hass.async_create_task(hass.services.async_call(
DOMAIN, SERVICE_INCREMENT, {
ATTR_ENTITY_ID: entity_id
})
}))
@bind_hass
@ -43,25 +44,13 @@ def decrement(hass, entity_id):
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(DOMAIN, SERVICE_DECREMENT, {
hass.async_create_task(hass.services.async_call(
DOMAIN, SERVICE_DECREMENT, {
ATTR_ENTITY_ID: entity_id
})
}))
class TestInputNumber(unittest.TestCase):
"""Test the input number component."""
# pylint: disable=invalid-name
def setUp(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
def test_config(self):
async def test_config(hass):
"""Test config."""
invalid_configs = [
None,
@ -73,11 +62,12 @@ class TestInputNumber(unittest.TestCase):
}},
]
for cfg in invalid_configs:
assert not setup_component(self.hass, DOMAIN, {DOMAIN: cfg})
assert not await async_setup_component(hass, DOMAIN, {DOMAIN: cfg})
def test_set_value(self):
async def test_set_value(hass):
"""Test set_value method."""
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_1': {
'initial': 50,
'min': 0,
@ -86,30 +76,31 @@ class TestInputNumber(unittest.TestCase):
}})
entity_id = 'input_number.test_1'
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 50 == float(state.state)
set_value(self.hass, entity_id, '30.4')
self.hass.block_till_done()
set_value(hass, entity_id, '30.4')
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 30.4 == float(state.state)
set_value(self.hass, entity_id, '70')
self.hass.block_till_done()
set_value(hass, entity_id, '70')
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 70 == float(state.state)
set_value(self.hass, entity_id, '110')
self.hass.block_till_done()
set_value(hass, entity_id, '110')
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 70 == float(state.state)
def test_increment(self):
async def test_increment(hass):
"""Test increment method."""
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_2': {
'initial': 50,
'min': 0,
@ -118,24 +109,25 @@ class TestInputNumber(unittest.TestCase):
}})
entity_id = 'input_number.test_2'
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 50 == float(state.state)
increment(self.hass, entity_id)
self.hass.block_till_done()
increment(hass, entity_id)
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 51 == float(state.state)
increment(self.hass, entity_id)
self.hass.block_till_done()
increment(hass, entity_id)
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 51 == float(state.state)
def test_decrement(self):
async def test_decrement(hass):
"""Test decrement method."""
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_3': {
'initial': 50,
'min': 49,
@ -144,24 +136,25 @@ class TestInputNumber(unittest.TestCase):
}})
entity_id = 'input_number.test_3'
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 50 == float(state.state)
decrement(self.hass, entity_id)
self.hass.block_till_done()
decrement(hass, entity_id)
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 49 == float(state.state)
decrement(self.hass, entity_id)
self.hass.block_till_done()
decrement(hass, entity_id)
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 49 == float(state.state)
def test_mode(self):
async def test_mode(hass):
"""Test mode settings."""
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_default_slider': {
'min': 0,
'max': 100,
@ -178,15 +171,15 @@ class TestInputNumber(unittest.TestCase):
},
}})
state = self.hass.states.get('input_number.test_default_slider')
state = hass.states.get('input_number.test_default_slider')
assert state
assert 'slider' == state.attributes['mode']
state = self.hass.states.get('input_number.test_explicit_box')
state = hass.states.get('input_number.test_explicit_box')
assert state
assert 'box' == state.attributes['mode']
state = self.hass.states.get('input_number.test_explicit_slider')
state = hass.states.get('input_number.test_explicit_slider')
assert state
assert 'slider' == state.attributes['mode']

View File

@ -1,7 +1,6 @@
"""The tests for the Input select component."""
# pylint: disable=protected-access
import asyncio
import unittest
from homeassistant.loader import bind_hass
from homeassistant.components.input_select import (
@ -10,9 +9,9 @@ from homeassistant.components.input_select import (
from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME, ATTR_ICON)
from homeassistant.core import State, Context
from homeassistant.setup import setup_component, async_setup_component
from homeassistant.setup import async_setup_component
from tests.common import get_test_home_assistant, mock_restore_cache
from tests.common import mock_restore_cache
@bind_hass
@ -21,10 +20,11 @@ def select_option(hass, entity_id, option):
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(DOMAIN, SERVICE_SELECT_OPTION, {
hass.async_create_task(hass.services.async_call(
DOMAIN, SERVICE_SELECT_OPTION, {
ATTR_ENTITY_ID: entity_id,
ATTR_OPTION: option,
})
}))
@bind_hass
@ -33,9 +33,10 @@ def select_next(hass, entity_id):
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(DOMAIN, SERVICE_SELECT_NEXT, {
hass.async_create_task(hass.services.async_call(
DOMAIN, SERVICE_SELECT_NEXT, {
ATTR_ENTITY_ID: entity_id,
})
}))
@bind_hass
@ -44,25 +45,13 @@ def select_previous(hass, entity_id):
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(DOMAIN, SERVICE_SELECT_PREVIOUS, {
hass.async_create_task(hass.services.async_call(
DOMAIN, SERVICE_SELECT_PREVIOUS, {
ATTR_ENTITY_ID: entity_id,
})
}))
class TestInputSelect(unittest.TestCase):
"""Test the input select component."""
# pylint: disable=invalid-name
def setUp(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
def test_config(self):
async def test_config(hass):
"""Test config."""
invalid_configs = [
None,
@ -76,11 +65,12 @@ class TestInputSelect(unittest.TestCase):
]
for cfg in invalid_configs:
assert not setup_component(self.hass, DOMAIN, {DOMAIN: cfg})
assert not await async_setup_component(hass, DOMAIN, {DOMAIN: cfg})
def test_select_option(self):
async def test_select_option(hass):
"""Test select_option methods."""
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_1': {
'options': [
'some option',
@ -90,24 +80,25 @@ class TestInputSelect(unittest.TestCase):
}})
entity_id = 'input_select.test_1'
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'some option' == state.state
select_option(self.hass, entity_id, 'another option')
self.hass.block_till_done()
select_option(hass, entity_id, 'another option')
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'another option' == state.state
select_option(self.hass, entity_id, 'non existing option')
self.hass.block_till_done()
select_option(hass, entity_id, 'non existing option')
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'another option' == state.state
def test_select_next(self):
async def test_select_next(hass):
"""Test select_next methods."""
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_1': {
'options': [
'first option',
@ -119,24 +110,25 @@ class TestInputSelect(unittest.TestCase):
}})
entity_id = 'input_select.test_1'
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'middle option' == state.state
select_next(self.hass, entity_id)
self.hass.block_till_done()
select_next(hass, entity_id)
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'last option' == state.state
select_next(self.hass, entity_id)
self.hass.block_till_done()
select_next(hass, entity_id)
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'first option' == state.state
def test_select_previous(self):
async def test_select_previous(hass):
"""Test select_previous methods."""
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_1': {
'options': [
'first option',
@ -148,24 +140,25 @@ class TestInputSelect(unittest.TestCase):
}})
entity_id = 'input_select.test_1'
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'middle option' == state.state
select_previous(self.hass, entity_id)
self.hass.block_till_done()
select_previous(hass, entity_id)
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'first option' == state.state
select_previous(self.hass, entity_id)
self.hass.block_till_done()
select_previous(hass, entity_id)
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'last option' == state.state
def test_config_options(self):
async def test_config_options(hass):
"""Test configuration options."""
count_start = len(self.hass.states.entity_ids())
count_start = len(hass.states.async_entity_ids())
test_2_options = [
'Good Option',
@ -173,7 +166,7 @@ class TestInputSelect(unittest.TestCase):
'Best Option',
]
assert setup_component(self.hass, DOMAIN, {
assert await async_setup_component(hass, DOMAIN, {
DOMAIN: {
'test_1': {
'options': [
@ -190,10 +183,10 @@ class TestInputSelect(unittest.TestCase):
}
})
assert count_start + 2 == len(self.hass.states.entity_ids())
assert count_start + 2 == len(hass.states.async_entity_ids())
state_1 = self.hass.states.get('input_select.test_1')
state_2 = self.hass.states.get('input_select.test_2')
state_1 = hass.states.get('input_select.test_1')
state_2 = hass.states.get('input_select.test_2')
assert state_1 is not None
assert state_2 is not None
@ -210,9 +203,10 @@ class TestInputSelect(unittest.TestCase):
state_2.attributes.get(ATTR_FRIENDLY_NAME)
assert 'mdi:work' == state_2.attributes.get(ATTR_ICON)
def test_set_options_service(self):
async def test_set_options_service(hass):
"""Test set_options service."""
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_1': {
'options': [
'first option',
@ -224,24 +218,24 @@ class TestInputSelect(unittest.TestCase):
}})
entity_id = 'input_select.test_1'
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'middle option' == state.state
data = {ATTR_OPTIONS: ["test1", "test2"], "entity_id": entity_id}
self.hass.services.call(DOMAIN, SERVICE_SET_OPTIONS, data)
self.hass.block_till_done()
await hass.services.async_call(DOMAIN, SERVICE_SET_OPTIONS, data)
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'test1' == state.state
select_option(self.hass, entity_id, 'first option')
self.hass.block_till_done()
state = self.hass.states.get(entity_id)
select_option(hass, entity_id, 'first option')
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 'test1' == state.state
select_option(self.hass, entity_id, 'test2')
self.hass.block_till_done()
state = self.hass.states.get(entity_id)
select_option(hass, entity_id, 'test2')
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 'test2' == state.state

View File

@ -1,16 +1,15 @@
"""The tests for the Input text component."""
# pylint: disable=protected-access
import asyncio
import unittest
from homeassistant.components.input_text import (
ATTR_VALUE, DOMAIN, SERVICE_SET_VALUE)
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import CoreState, State, Context
from homeassistant.loader import bind_hass
from homeassistant.setup import setup_component, async_setup_component
from homeassistant.setup import async_setup_component
from tests.common import get_test_home_assistant, mock_restore_cache
from tests.common import mock_restore_cache
@bind_hass
@ -19,26 +18,14 @@ def set_value(hass, entity_id, value):
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(DOMAIN, SERVICE_SET_VALUE, {
hass.async_create_task(hass.services.async_call(
DOMAIN, SERVICE_SET_VALUE, {
ATTR_ENTITY_ID: entity_id,
ATTR_VALUE: value,
})
}))
class TestInputText(unittest.TestCase):
"""Test the input slider component."""
# pylint: disable=invalid-name
def setUp(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
def test_config(self):
async def test_config(hass):
"""Test config."""
invalid_configs = [
None,
@ -50,11 +37,12 @@ class TestInputText(unittest.TestCase):
}},
]
for cfg in invalid_configs:
assert not setup_component(self.hass, DOMAIN, {DOMAIN: cfg})
assert not await async_setup_component(hass, DOMAIN, {DOMAIN: cfg})
def test_set_value(self):
async def test_set_value(hass):
"""Test set_value method."""
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_1': {
'initial': 'test',
'min': 3,
@ -63,24 +51,25 @@ class TestInputText(unittest.TestCase):
}})
entity_id = 'input_text.test_1'
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'test' == str(state.state)
set_value(self.hass, entity_id, 'testing')
self.hass.block_till_done()
set_value(hass, entity_id, 'testing')
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'testing' == str(state.state)
set_value(self.hass, entity_id, 'testing too long')
self.hass.block_till_done()
set_value(hass, entity_id, 'testing too long')
await hass.async_block_till_done()
state = self.hass.states.get(entity_id)
state = hass.states.get(entity_id)
assert 'testing' == str(state.state)
def test_mode(self):
async def test_mode(hass):
"""Test mode settings."""
assert setup_component(self.hass, DOMAIN, {DOMAIN: {
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {
'test_default_text': {
'initial': 'test',
'min': 3,
@ -100,15 +89,15 @@ class TestInputText(unittest.TestCase):
},
}})
state = self.hass.states.get('input_text.test_default_text')
state = hass.states.get('input_text.test_default_text')
assert state
assert 'text' == state.attributes['mode']
state = self.hass.states.get('input_text.test_explicit_text')
state = hass.states.get('input_text.test_explicit_text')
assert state
assert 'text' == state.attributes['mode']
state = self.hass.states.get('input_text.test_explicit_password')
state = hass.states.get('input_text.test_explicit_password')
assert state
assert 'password' == state.attributes['mode']