Yoda assertion style removed is (#48142)

This commit is contained in:
Franck Nijhof 2021-03-20 13:55:10 +01:00 committed by GitHub
parent 365e8a74ee
commit 5a2b5fe7c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
75 changed files with 1137 additions and 1148 deletions

View file

@ -120,7 +120,7 @@ async def test_is_on(hass):
async def test_setup(hass):
"""Test setup method."""
assert await async_setup_component(hass, alert.DOMAIN, TEST_CONFIG)
assert STATE_IDLE == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_IDLE
async def test_fire(hass, mock_notifier):
@ -128,7 +128,7 @@ async def test_fire(hass, mock_notifier):
assert await async_setup_component(hass, alert.DOMAIN, TEST_CONFIG)
hass.states.async_set("sensor.test", STATE_ON)
await hass.async_block_till_done()
assert STATE_ON == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ON
async def test_silence(hass, mock_notifier):
@ -138,15 +138,15 @@ async def test_silence(hass, mock_notifier):
await hass.async_block_till_done()
async_turn_off(hass, ENTITY_ID)
await hass.async_block_till_done()
assert STATE_OFF == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_OFF
# alert should not be silenced on next fire
hass.states.async_set("sensor.test", STATE_OFF)
await hass.async_block_till_done()
assert STATE_IDLE == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_IDLE
hass.states.async_set("sensor.test", STATE_ON)
await hass.async_block_till_done()
assert STATE_ON == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ON
async def test_reset(hass, mock_notifier):
@ -156,10 +156,10 @@ async def test_reset(hass, mock_notifier):
await hass.async_block_till_done()
async_turn_off(hass, ENTITY_ID)
await hass.async_block_till_done()
assert STATE_OFF == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_OFF
async_turn_on(hass, ENTITY_ID)
await hass.async_block_till_done()
assert STATE_ON == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ON
async def test_toggle(hass, mock_notifier):
@ -167,13 +167,13 @@ async def test_toggle(hass, mock_notifier):
assert await async_setup_component(hass, alert.DOMAIN, TEST_CONFIG)
hass.states.async_set("sensor.test", STATE_ON)
await hass.async_block_till_done()
assert STATE_ON == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ON
async_toggle(hass, ENTITY_ID)
await hass.async_block_till_done()
assert STATE_OFF == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_OFF
async_toggle(hass, ENTITY_ID)
await hass.async_block_till_done()
assert STATE_ON == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ON
async def test_notification_no_done_message(hass):

View file

@ -199,7 +199,7 @@ async def test_update_existing_device(mock_write, hass):
assert test_device_1 is not None
assert test_device_2 is not None
assert "updated device 1" == test_device_1.name
assert test_device_1.name == "updated device 1"
@patch("homeassistant.components.apns.notify._write_device")
@ -239,8 +239,8 @@ async def test_update_existing_device_with_tracking_id(mock_write, hass):
assert test_device_1 is not None
assert test_device_2 is not None
assert "tracking123" == test_device_1.tracking_device_id
assert "tracking456" == test_device_2.tracking_device_id
assert test_device_1.tracking_device_id == "tracking123"
assert test_device_2.tracking_device_id == "tracking456"
@patch("homeassistant.components.apns.notify.APNsClient")
@ -267,16 +267,16 @@ async def test_send(mock_client, hass):
)
assert send.called
assert 1 == len(send.mock_calls)
assert len(send.mock_calls) == 1
target = send.mock_calls[0][1][0]
payload = send.mock_calls[0][1][1]
assert "1234" == target
assert "Hello" == payload.alert
assert 1 == payload.badge
assert "test.mp3" == payload.sound
assert "testing" == payload.category
assert target == "1234"
assert payload.alert == "Hello"
assert payload.badge == 1
assert payload.sound == "test.mp3"
assert payload.category == "testing"
@patch("homeassistant.components.apns.notify.APNsClient")
@ -337,13 +337,13 @@ async def test_send_with_state(mock_client, hass):
notify_service.send_message(message="Hello", target="home")
assert send.called
assert 1 == len(send.mock_calls)
assert len(send.mock_calls) == 1
target = send.mock_calls[0][1][0]
payload = send.mock_calls[0][1][1]
assert "5678" == target
assert "Hello" == payload.alert
assert target == "5678"
assert payload.alert == "Hello"
@patch("homeassistant.components.apns.notify.APNsClient")

View file

@ -119,7 +119,7 @@ async def test_sensor_numeric_state(hass):
state = hass.states.get("binary_sensor.test_binary")
assert [] == state.attributes.get("observations")
assert 0.2 == state.attributes.get("probability")
assert state.attributes.get("probability") == 0.2
assert state.state == "off"
@ -146,7 +146,7 @@ async def test_sensor_numeric_state(hass):
await hass.async_block_till_done()
state = hass.states.get("binary_sensor.test_binary")
assert 0.2 == state.attributes.get("probability")
assert state.attributes.get("probability") == 0.2
assert state.state == "off"
@ -186,7 +186,7 @@ async def test_sensor_state(hass):
state = hass.states.get("binary_sensor.test_binary")
assert [] == state.attributes.get("observations")
assert 0.2 == state.attributes.get("probability")
assert state.attributes.get("probability") == 0.2
assert state.state == "off"
@ -242,7 +242,7 @@ async def test_sensor_value_template(hass):
state = hass.states.get("binary_sensor.test_binary")
assert [] == state.attributes.get("observations")
assert 0.2 == state.attributes.get("probability")
assert state.attributes.get("probability") == 0.2
assert state.state == "off"
@ -339,7 +339,7 @@ async def test_multiple_observations(hass):
for key, attrs in state.attributes.items():
json.dumps(attrs)
assert [] == state.attributes.get("observations")
assert 0.2 == state.attributes.get("probability")
assert state.attributes.get("probability") == 0.2
assert state.state == "off"

View file

@ -8,17 +8,17 @@ from homeassistant.const import STATE_OFF, STATE_ON
def test_state():
"""Test binary sensor state."""
sensor = binary_sensor.BinarySensorEntity()
assert STATE_OFF == sensor.state
assert sensor.state == STATE_OFF
with mock.patch(
"homeassistant.components.binary_sensor.BinarySensorEntity.is_on",
new=False,
):
assert STATE_OFF == binary_sensor.BinarySensorEntity().state
assert binary_sensor.BinarySensorEntity().state == STATE_OFF
with mock.patch(
"homeassistant.components.binary_sensor.BinarySensorEntity.is_on",
new=True,
):
assert STATE_ON == binary_sensor.BinarySensorEntity().state
assert binary_sensor.BinarySensorEntity().state == STATE_ON
def test_deprecated_base_class(caplog):

View file

@ -219,9 +219,9 @@ class TestBlackbirdMediaPlayer(unittest.TestCase):
def test_setallzones_service_call_with_entity_id(self):
"""Test set all zone source service call with entity id."""
self.media_player.update()
assert "Zone name" == self.media_player.name
assert STATE_ON == self.media_player.state
assert "one" == self.media_player.source
assert self.media_player.name == "Zone name"
assert self.media_player.state == STATE_ON
assert self.media_player.source == "one"
# Call set all zones service
self.hass.services.call(
@ -232,16 +232,16 @@ class TestBlackbirdMediaPlayer(unittest.TestCase):
)
# Check that source was changed
assert 3 == self.blackbird.zones[3].av
assert self.blackbird.zones[3].av == 3
self.media_player.update()
assert "three" == self.media_player.source
assert self.media_player.source == "three"
def test_setallzones_service_call_without_entity_id(self):
"""Test set all zone source service call without entity id."""
self.media_player.update()
assert "Zone name" == self.media_player.name
assert STATE_ON == self.media_player.state
assert "one" == self.media_player.source
assert self.media_player.name == "Zone name"
assert self.media_player.state == STATE_ON
assert self.media_player.source == "one"
# Call set all zones service
self.hass.services.call(
@ -249,9 +249,9 @@ class TestBlackbirdMediaPlayer(unittest.TestCase):
)
# Check that source was changed
assert 3 == self.blackbird.zones[3].av
assert self.blackbird.zones[3].av == 3
self.media_player.update()
assert "three" == self.media_player.source
assert self.media_player.source == "three"
def test_update(self):
"""Test updating values from blackbird."""
@ -260,23 +260,23 @@ class TestBlackbirdMediaPlayer(unittest.TestCase):
self.media_player.update()
assert STATE_ON == self.media_player.state
assert "one" == self.media_player.source
assert self.media_player.state == STATE_ON
assert self.media_player.source == "one"
def test_name(self):
"""Test name property."""
assert "Zone name" == self.media_player.name
assert self.media_player.name == "Zone name"
def test_state(self):
"""Test state property."""
assert self.media_player.state is None
self.media_player.update()
assert STATE_ON == self.media_player.state
assert self.media_player.state == STATE_ON
self.blackbird.zones[3].power = False
self.media_player.update()
assert STATE_OFF == self.media_player.state
assert self.media_player.state == STATE_OFF
def test_supported_features(self):
"""Test supported features property."""
@ -289,54 +289,54 @@ class TestBlackbirdMediaPlayer(unittest.TestCase):
"""Test source property."""
assert self.media_player.source is None
self.media_player.update()
assert "one" == self.media_player.source
assert self.media_player.source == "one"
def test_media_title(self):
"""Test media title property."""
assert self.media_player.media_title is None
self.media_player.update()
assert "one" == self.media_player.media_title
assert self.media_player.media_title == "one"
def test_source_list(self):
"""Test source list property."""
# Note, the list is sorted!
assert ["one", "two", "three"] == self.media_player.source_list
assert self.media_player.source_list == ["one", "two", "three"]
def test_select_source(self):
"""Test source selection methods."""
self.media_player.update()
assert "one" == self.media_player.source
assert self.media_player.source == "one"
self.media_player.select_source("two")
assert 2 == self.blackbird.zones[3].av
assert self.blackbird.zones[3].av == 2
self.media_player.update()
assert "two" == self.media_player.source
assert self.media_player.source == "two"
# Trying to set unknown source.
self.media_player.select_source("no name")
assert 2 == self.blackbird.zones[3].av
assert self.blackbird.zones[3].av == 2
self.media_player.update()
assert "two" == self.media_player.source
assert self.media_player.source == "two"
def test_turn_on(self):
"""Testing turning on the zone."""
self.blackbird.zones[3].power = False
self.media_player.update()
assert STATE_OFF == self.media_player.state
assert self.media_player.state == STATE_OFF
self.media_player.turn_on()
assert self.blackbird.zones[3].power
self.media_player.update()
assert STATE_ON == self.media_player.state
assert self.media_player.state == STATE_ON
def test_turn_off(self):
"""Testing turning off the zone."""
self.blackbird.zones[3].power = True
self.media_player.update()
assert STATE_ON == self.media_player.state
assert self.media_player.state == STATE_ON
self.media_player.turn_off()
assert not self.blackbird.zones[3].power
self.media_player.update()
assert STATE_OFF == self.media_player.state
assert self.media_player.state == STATE_OFF

View file

@ -8,18 +8,18 @@ async def test_request_least_info(hass):
"""Test request config with least amount of data."""
request_id = configurator.async_request_config(hass, "Test Request", lambda _: None)
assert 1 == len(
hass.services.async_services().get(configurator.DOMAIN, [])
assert (
len(hass.services.async_services().get(configurator.DOMAIN, [])) == 1
), "No new service registered"
states = hass.states.async_all()
assert 1 == len(states), "Expected a new state registered"
assert len(states) == 1, "Expected a new state registered"
state = states[0]
assert configurator.STATE_CONFIGURE == state.state
assert request_id == state.attributes.get(configurator.ATTR_CONFIGURE_ID)
assert state.state == configurator.STATE_CONFIGURE
assert state.attributes.get(configurator.ATTR_CONFIGURE_ID) == request_id
async def test_request_all_info(hass):
@ -49,11 +49,11 @@ async def test_request_all_info(hass):
}
states = hass.states.async_all()
assert 1 == len(states)
assert len(states) == 1
state = states[0]
assert configurator.STATE_CONFIGURE == state.state
assert exp_attr == state.attributes
assert state.state == configurator.STATE_CONFIGURE
assert state.attributes == exp_attr
async def test_callback_called_on_configure(hass):
@ -70,7 +70,7 @@ async def test_callback_called_on_configure(hass):
)
await hass.async_block_till_done()
assert 1 == len(calls), "Callback not called"
assert len(calls) == 1, "Callback not called"
async def test_state_change_on_notify_errors(hass):
@ -80,9 +80,9 @@ async def test_state_change_on_notify_errors(hass):
configurator.async_notify_errors(hass, request_id, error)
states = hass.states.async_all()
assert 1 == len(states)
assert len(states) == 1
state = states[0]
assert error == state.attributes.get(configurator.ATTR_ERRORS)
assert state.attributes.get(configurator.ATTR_ERRORS) == error
async def test_notify_errors_fail_silently_on_bad_request_id(hass):
@ -94,11 +94,11 @@ async def test_request_done_works(hass):
"""Test if calling request done works."""
request_id = configurator.async_request_config(hass, "Test Request", lambda _: None)
configurator.async_request_done(hass, request_id)
assert 1 == len(hass.states.async_all())
assert len(hass.states.async_all()) == 1
hass.bus.async_fire(EVENT_TIME_CHANGED)
await hass.async_block_till_done()
assert 0 == len(hass.states.async_all())
assert len(hass.states.async_all()) == 0
async def test_request_done_fail_silently_on_bad_request_id(hass):

View file

@ -114,16 +114,16 @@ async def test_config_options(hass):
assert state_2 is not None
assert state_3 is not None
assert 0 == int(state_1.state)
assert int(state_1.state) == 0
assert ATTR_ICON not in state_1.attributes
assert ATTR_FRIENDLY_NAME not in state_1.attributes
assert 10 == int(state_2.state)
assert "Hello World" == state_2.attributes.get(ATTR_FRIENDLY_NAME)
assert "mdi:work" == state_2.attributes.get(ATTR_ICON)
assert int(state_2.state) == 10
assert state_2.attributes.get(ATTR_FRIENDLY_NAME) == "Hello World"
assert state_2.attributes.get(ATTR_ICON) == "mdi:work"
assert DEFAULT_INITIAL == state_3.attributes.get(ATTR_INITIAL)
assert DEFAULT_STEP == state_3.attributes.get(ATTR_STEP)
assert state_3.attributes.get(ATTR_INITIAL) == DEFAULT_INITIAL
assert state_3.attributes.get(ATTR_STEP) == DEFAULT_STEP
async def test_methods(hass):
@ -135,31 +135,31 @@ async def test_methods(hass):
entity_id = "counter.test_1"
state = hass.states.get(entity_id)
assert 0 == int(state.state)
assert int(state.state) == 0
async_increment(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 1 == int(state.state)
assert int(state.state) == 1
async_increment(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 2 == int(state.state)
assert int(state.state) == 2
async_decrement(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 1 == int(state.state)
assert int(state.state) == 1
async_reset(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 0 == int(state.state)
assert int(state.state) == 0
async def test_methods_with_config(hass):
@ -173,25 +173,25 @@ async def test_methods_with_config(hass):
entity_id = "counter.test"
state = hass.states.get(entity_id)
assert 10 == int(state.state)
assert int(state.state) == 10
async_increment(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 15 == int(state.state)
assert int(state.state) == 15
async_increment(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 20 == int(state.state)
assert int(state.state) == 20
async_decrement(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 15 == int(state.state)
assert int(state.state) == 15
async def test_initial_state_overrules_restore_state(hass):
@ -370,7 +370,7 @@ async def test_configure(hass, hass_admin_user):
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "10"
assert 10 == state.attributes.get("maximum")
assert state.attributes.get("maximum") == 10
# update max
await hass.services.async_call(
@ -384,7 +384,7 @@ async def test_configure(hass, hass_admin_user):
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "0"
assert 0 == state.attributes.get("maximum")
assert state.attributes.get("maximum") == 0
# disable max
await hass.services.async_call(
@ -413,7 +413,7 @@ async def test_configure(hass, hass_admin_user):
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "5"
assert 5 == state.attributes.get("minimum")
assert state.attributes.get("minimum") == 5
# disable min
await hass.services.async_call(
@ -430,7 +430,7 @@ async def test_configure(hass, hass_admin_user):
assert state.attributes.get("minimum") is None
# update step
assert 1 == state.attributes.get("step")
assert state.attributes.get("step") == 1
await hass.services.async_call(
"counter",
"configure",
@ -442,7 +442,7 @@ async def test_configure(hass, hass_admin_user):
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "5"
assert 3 == state.attributes.get("step")
assert state.attributes.get("step") == 3
# update value
await hass.services.async_call(
@ -469,7 +469,7 @@ async def test_configure(hass, hass_admin_user):
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "6"
assert 5 == state.attributes.get("initial")
assert state.attributes.get("initial") == 5
# update all
await hass.services.async_call(
@ -490,10 +490,10 @@ async def test_configure(hass, hass_admin_user):
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "5"
assert 5 == state.attributes.get("step")
assert 0 == state.attributes.get("minimum")
assert 9 == state.attributes.get("maximum")
assert 6 == state.attributes.get("initial")
assert state.attributes.get("step") == 5
assert state.attributes.get("minimum") == 0
assert state.attributes.get("maximum") == 9
assert state.attributes.get("initial") == 6
async def test_load_from_storage(hass, storage_setup):

View file

@ -37,8 +37,8 @@ async def test_datadog_setup_full(hass):
assert mock_init.call_args == mock.call(statsd_host="host", statsd_port=123)
assert hass.bus.listen.called
assert EVENT_LOGBOOK_ENTRY == hass.bus.listen.call_args_list[0][0][0]
assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[1][0][0]
assert hass.bus.listen.call_args_list[0][0][0] == EVENT_LOGBOOK_ENTRY
assert hass.bus.listen.call_args_list[1][0][0] == EVENT_STATE_CHANGED
async def test_datadog_setup_defaults(hass):

View file

@ -69,7 +69,7 @@ def test_setup_params(hass):
assert state.attributes.get(ATTR_HUMIDITY) == 67
assert state.attributes.get(ATTR_CURRENT_HUMIDITY) == 54
assert state.attributes.get(ATTR_SWING_MODE) == "Off"
assert STATE_OFF == state.attributes.get(ATTR_AUX_HEAT)
assert state.attributes.get(ATTR_AUX_HEAT) == STATE_OFF
assert state.attributes.get(ATTR_HVAC_MODES) == [
"off",
"heat",

View file

@ -251,7 +251,7 @@ async def test_update_stale(hass, mock_device_tracker_conf):
)
await hass.async_block_till_done()
assert STATE_HOME == hass.states.get("device_tracker.dev1").state
assert hass.states.get("device_tracker.dev1").state == STATE_HOME
scanner.leave_home("DEV1")
@ -262,7 +262,7 @@ async def test_update_stale(hass, mock_device_tracker_conf):
async_fire_time_changed(hass, scan_time)
await hass.async_block_till_done()
assert STATE_NOT_HOME == hass.states.get("device_tracker.dev1").state
assert hass.states.get("device_tracker.dev1").state == STATE_NOT_HOME
async def test_entity_attributes(hass, mock_device_tracker_conf):
@ -474,7 +474,7 @@ async def test_see_passive_zone_state(hass, mock_device_tracker_conf):
state = hass.states.get("device_tracker.dev1")
attrs = state.attributes
assert STATE_HOME == state.state
assert state.state == STATE_HOME
assert state.object_id == "dev1"
assert state.name == "dev1"
assert attrs.get("friendly_name") == "dev1"
@ -494,7 +494,7 @@ async def test_see_passive_zone_state(hass, mock_device_tracker_conf):
state = hass.states.get("device_tracker.dev1")
attrs = state.attributes
assert STATE_NOT_HOME == state.state
assert state.state == STATE_NOT_HOME
assert state.object_id == "dev1"
assert state.name == "dev1"
assert attrs.get("friendly_name") == "dev1"

View file

@ -117,9 +117,9 @@ async def test_fan(ecobee_fixture, thermostat):
"""Test fan property."""
assert const.STATE_ON == thermostat.fan
ecobee_fixture["equipmentStatus"] = ""
assert STATE_OFF == thermostat.fan
assert thermostat.fan == STATE_OFF
ecobee_fixture["equipmentStatus"] = "heatPump, heatPump2"
assert STATE_OFF == thermostat.fan
assert thermostat.fan == STATE_OFF
async def test_hvac_mode(ecobee_fixture, thermostat):

View file

@ -63,11 +63,11 @@ async def test_single_sensor_readings(hass, requests_mock):
assert await async_setup_component(hass, "sensor", {"sensor": ONE_SENSOR_CONFIG})
await hass.async_block_till_done()
assert "38.21" == hass.states.get("sensor.energy_consumed").state
assert "1580" == hass.states.get("sensor.energy_usage").state
assert "ok" == hass.states.get("sensor.energy_budget").state
assert "5.27" == hass.states.get("sensor.energy_cost").state
assert "1628" == hass.states.get("sensor.efergy_728386").state
assert hass.states.get("sensor.energy_consumed").state == "38.21"
assert hass.states.get("sensor.energy_usage").state == "1580"
assert hass.states.get("sensor.energy_budget").state == "ok"
assert hass.states.get("sensor.energy_cost").state == "5.27"
assert hass.states.get("sensor.efergy_728386").state == "1628"
async def test_multi_sensor_readings(hass, requests_mock):
@ -76,6 +76,6 @@ async def test_multi_sensor_readings(hass, requests_mock):
assert await async_setup_component(hass, "sensor", {"sensor": MULTI_SENSOR_CONFIG})
await hass.async_block_till_done()
assert "218" == hass.states.get("sensor.efergy_728386").state
assert "1808" == hass.states.get("sensor.efergy_0").state
assert "312" == hass.states.get("sensor.efergy_728387").state
assert hass.states.get("sensor.efergy_728386").state == "218"
assert hass.states.get("sensor.efergy_0").state == "1808"
assert hass.states.get("sensor.efergy_728387").state == "312"

View file

@ -363,7 +363,7 @@ async def test_light_without_brightness_can_be_turned_off(hass_hue, hue_client):
call = turn_off_calls[-1]
assert light.DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert call.service == SERVICE_TURN_OFF
assert "light.no_brightness" in call.data[ATTR_ENTITY_ID]
@ -401,11 +401,11 @@ async def test_light_without_brightness_can_be_turned_on(hass_hue, hue_client):
# Verify that SERVICE_TURN_ON has been called
await hass_hue.async_block_till_done()
assert 1 == len(turn_on_calls)
assert len(turn_on_calls) == 1
call = turn_on_calls[-1]
assert light.DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert call.service == SERVICE_TURN_ON
assert "light.no_brightness" in call.data[ATTR_ENTITY_ID]

View file

@ -75,7 +75,7 @@ async def test_chain(hass, values):
await hass.async_block_till_done()
state = hass.states.get("sensor.test")
assert "18.05" == state.state
assert state.state == "18.05"
async def test_chain_history(hass, values, missing=False):
@ -131,9 +131,9 @@ async def test_chain_history(hass, values, missing=False):
state = hass.states.get("sensor.test")
if missing:
assert "18.05" == state.state
assert state.state == "18.05"
else:
assert "17.05" == state.state
assert state.state == "17.05"
async def test_source_state_none(hass, values):
@ -245,7 +245,7 @@ async def test_history_time(hass):
await hass.async_block_till_done()
state = hass.states.get("sensor.test")
assert "18.0" == state.state
assert state.state == "18.0"
async def test_setup(hass):
@ -316,7 +316,7 @@ async def test_outlier(values):
filt = OutlierFilter(window_size=3, precision=2, entity=None, radius=4.0)
for state in values:
filtered = filt.filter_state(state)
assert 21 == filtered.state
assert filtered.state == 21
def test_outlier_step(values):
@ -331,7 +331,7 @@ def test_outlier_step(values):
values[-1].state = 22
for state in values:
filtered = filt.filter_state(state)
assert 22 == filtered.state
assert filtered.state == 22
def test_initial_outlier(values):
@ -340,7 +340,7 @@ def test_initial_outlier(values):
out = ha.State("sensor.test_monitored", 4000)
for state in [out] + values:
filtered = filt.filter_state(state)
assert 21 == filtered.state
assert filtered.state == 21
def test_unknown_state_outlier(values):
@ -352,7 +352,7 @@ def test_unknown_state_outlier(values):
filtered = filt.filter_state(state)
except ValueError:
assert state.state == "unknown"
assert 21 == filtered.state
assert filtered.state == 21
def test_precision_zero(values):
@ -372,7 +372,7 @@ def test_lowpass(values):
filtered = filt.filter_state(state)
except ValueError:
assert state.state == "unknown"
assert 18.05 == filtered.state
assert filtered.state == 18.05
def test_range(values):
@ -438,7 +438,7 @@ def test_time_sma(values):
)
for state in values:
filtered = filt.filter_state(state)
assert 21.5 == filtered.state
assert filtered.state == 21.5
async def test_reload(hass):

View file

@ -140,7 +140,7 @@ async def test_flux_when_switch_is_off(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -191,7 +191,7 @@ async def test_flux_before_sunrise(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -250,7 +250,7 @@ async def test_flux_before_sunrise_known_location(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -309,7 +309,7 @@ async def test_flux_after_sunrise_before_sunset(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -368,7 +368,7 @@ async def test_flux_after_sunset_before_stop(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -428,7 +428,7 @@ async def test_flux_after_stop_before_sunrise(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -487,7 +487,7 @@ async def test_flux_with_custom_start_stop_times(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -550,7 +550,7 @@ async def test_flux_before_sunrise_stop_next_day(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -616,7 +616,7 @@ async def test_flux_after_sunrise_before_sunset_stop_next_day(
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -682,7 +682,7 @@ async def test_flux_after_sunset_before_midnight_stop_next_day(
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -747,7 +747,7 @@ async def test_flux_after_sunset_after_midnight_stop_next_day(
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -812,7 +812,7 @@ async def test_flux_after_stop_before_sunrise_stop_next_day(
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -872,7 +872,7 @@ async def test_flux_with_custom_colortemps(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -934,7 +934,7 @@ async def test_flux_with_custom_brightness(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -1001,17 +1001,17 @@ async def test_flux_with_multiple_lights(hass, legacy_patchable_time):
await hass.async_block_till_done()
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
state = hass.states.get(ent2.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
state = hass.states.get(ent3.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@ -1077,7 +1077,7 @@ async def test_flux_with_mired(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("color_temp") is None
test_time = dt_util.utcnow().replace(hour=8, minute=30, second=0)
@ -1134,7 +1134,7 @@ async def test_flux_with_rgb(hass, legacy_patchable_time):
# Verify initial state of light
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.state == STATE_ON
assert state.attributes.get("color_temp") is None
test_time = dt_util.utcnow().replace(hour=8, minute=30, second=0)

View file

@ -116,13 +116,13 @@ async def test_heater_input_boolean(hass, setup_comp_1):
)
await hass.async_block_till_done()
assert STATE_OFF == hass.states.get(heater_switch).state
assert hass.states.get(heater_switch).state == STATE_OFF
_setup_sensor(hass, 18)
await hass.async_block_till_done()
await common.async_set_temperature(hass, 23)
assert STATE_ON == hass.states.get(heater_switch).state
assert hass.states.get(heater_switch).state == STATE_ON
async def test_heater_switch(hass, setup_comp_1):
@ -151,13 +151,13 @@ async def test_heater_switch(hass, setup_comp_1):
)
await hass.async_block_till_done()
assert STATE_OFF == hass.states.get(heater_switch).state
assert hass.states.get(heater_switch).state == STATE_OFF
_setup_sensor(hass, 18)
await common.async_set_temperature(hass, 23)
await hass.async_block_till_done()
assert STATE_ON == hass.states.get(heater_switch).state
assert hass.states.get(heater_switch).state == STATE_ON
async def test_unique_id(hass, setup_comp_1):
@ -234,7 +234,7 @@ async def test_setup_defaults_to_unknown(hass):
},
)
await hass.async_block_till_done()
assert HVAC_MODE_OFF == hass.states.get(ENTITY).state
assert hass.states.get(ENTITY).state == HVAC_MODE_OFF
async def test_setup_gets_current_temp_from_sensor(hass):
@ -264,27 +264,27 @@ async def test_setup_gets_current_temp_from_sensor(hass):
async def test_default_setup_params(hass, setup_comp_2):
"""Test the setup with default parameters."""
state = hass.states.get(ENTITY)
assert 7 == state.attributes.get("min_temp")
assert 35 == state.attributes.get("max_temp")
assert 7 == state.attributes.get("temperature")
assert state.attributes.get("min_temp") == 7
assert state.attributes.get("max_temp") == 35
assert state.attributes.get("temperature") == 7
async def test_get_hvac_modes(hass, setup_comp_2):
"""Test that the operation list returns the correct modes."""
state = hass.states.get(ENTITY)
modes = state.attributes.get("hvac_modes")
assert [HVAC_MODE_HEAT, HVAC_MODE_OFF] == modes
assert modes == [HVAC_MODE_HEAT, HVAC_MODE_OFF]
async def test_set_target_temp(hass, setup_comp_2):
"""Test the setting of the target temperature."""
await common.async_set_temperature(hass, 30)
state = hass.states.get(ENTITY)
assert 30.0 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 30.0
with pytest.raises(vol.Invalid):
await common.async_set_temperature(hass, None)
state = hass.states.get(ENTITY)
assert 30.0 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 30.0
async def test_set_away_mode(hass, setup_comp_2):
@ -292,7 +292,7 @@ async def test_set_away_mode(hass, setup_comp_2):
await common.async_set_temperature(hass, 23)
await common.async_set_preset_mode(hass, PRESET_AWAY)
state = hass.states.get(ENTITY)
assert 16 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 16
async def test_set_away_mode_and_restore_prev_temp(hass, setup_comp_2):
@ -303,10 +303,10 @@ async def test_set_away_mode_and_restore_prev_temp(hass, setup_comp_2):
await common.async_set_temperature(hass, 23)
await common.async_set_preset_mode(hass, PRESET_AWAY)
state = hass.states.get(ENTITY)
assert 16 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 16
await common.async_set_preset_mode(hass, PRESET_NONE)
state = hass.states.get(ENTITY)
assert 23 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 23
async def test_set_away_mode_twice_and_restore_prev_temp(hass, setup_comp_2):
@ -318,10 +318,10 @@ async def test_set_away_mode_twice_and_restore_prev_temp(hass, setup_comp_2):
await common.async_set_preset_mode(hass, PRESET_AWAY)
await common.async_set_preset_mode(hass, PRESET_AWAY)
state = hass.states.get(ENTITY)
assert 16 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 16
await common.async_set_preset_mode(hass, PRESET_NONE)
state = hass.states.get(ENTITY)
assert 23 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 23
async def test_sensor_bad_value(hass, setup_comp_2):
@ -382,11 +382,11 @@ async def test_set_target_temp_heater_on(hass, setup_comp_2):
_setup_sensor(hass, 25)
await hass.async_block_till_done()
await common.async_set_temperature(hass, 30)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_set_target_temp_heater_off(hass, setup_comp_2):
@ -395,11 +395,11 @@ async def test_set_target_temp_heater_off(hass, setup_comp_2):
_setup_sensor(hass, 30)
await hass.async_block_till_done()
await common.async_set_temperature(hass, 25)
assert 2 == len(calls)
assert len(calls) == 2
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_heater_on_within_tolerance(hass, setup_comp_2):
@ -408,7 +408,7 @@ async def test_temp_change_heater_on_within_tolerance(hass, setup_comp_2):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 29)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_heater_on_outside_tolerance(hass, setup_comp_2):
@ -417,11 +417,11 @@ async def test_temp_change_heater_on_outside_tolerance(hass, setup_comp_2):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 27)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_heater_off_within_tolerance(hass, setup_comp_2):
@ -430,7 +430,7 @@ async def test_temp_change_heater_off_within_tolerance(hass, setup_comp_2):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 33)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_heater_off_outside_tolerance(hass, setup_comp_2):
@ -439,11 +439,11 @@ async def test_temp_change_heater_off_outside_tolerance(hass, setup_comp_2):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 35)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_running_when_hvac_mode_is_off(hass, setup_comp_2):
@ -451,11 +451,11 @@ async def test_running_when_hvac_mode_is_off(hass, setup_comp_2):
calls = _setup_switch(hass, True)
await common.async_set_temperature(hass, 30)
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_no_state_change_when_hvac_mode_off(hass, setup_comp_2):
@ -465,7 +465,7 @@ async def test_no_state_change_when_hvac_mode_off(hass, setup_comp_2):
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_hvac_mode_heat(hass, setup_comp_2):
@ -479,11 +479,11 @@ async def test_hvac_mode_heat(hass, setup_comp_2):
await hass.async_block_till_done()
calls = _setup_switch(hass, False)
await common.async_set_hvac_mode(hass, HVAC_MODE_HEAT)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
def _setup_switch(hass, is_on):
@ -532,11 +532,11 @@ async def test_set_target_temp_ac_off(hass, setup_comp_3):
_setup_sensor(hass, 25)
await hass.async_block_till_done()
await common.async_set_temperature(hass, 30)
assert 2 == len(calls)
assert len(calls) == 2
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_turn_away_mode_on_cooling(hass, setup_comp_3):
@ -547,7 +547,7 @@ async def test_turn_away_mode_on_cooling(hass, setup_comp_3):
await common.async_set_temperature(hass, 19)
await common.async_set_preset_mode(hass, PRESET_AWAY)
state = hass.states.get(ENTITY)
assert 30 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 30
async def test_hvac_mode_cool(hass, setup_comp_3):
@ -561,11 +561,11 @@ async def test_hvac_mode_cool(hass, setup_comp_3):
await hass.async_block_till_done()
calls = _setup_switch(hass, False)
await common.async_set_hvac_mode(hass, HVAC_MODE_COOL)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_set_target_temp_ac_on(hass, setup_comp_3):
@ -574,11 +574,11 @@ async def test_set_target_temp_ac_on(hass, setup_comp_3):
_setup_sensor(hass, 30)
await hass.async_block_till_done()
await common.async_set_temperature(hass, 25)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_ac_off_within_tolerance(hass, setup_comp_3):
@ -587,7 +587,7 @@ async def test_temp_change_ac_off_within_tolerance(hass, setup_comp_3):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 29.8)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_set_temp_change_ac_off_outside_tolerance(hass, setup_comp_3):
@ -596,11 +596,11 @@ async def test_set_temp_change_ac_off_outside_tolerance(hass, setup_comp_3):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 27)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_ac_on_within_tolerance(hass, setup_comp_3):
@ -609,7 +609,7 @@ async def test_temp_change_ac_on_within_tolerance(hass, setup_comp_3):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 25.2)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_ac_on_outside_tolerance(hass, setup_comp_3):
@ -618,11 +618,11 @@ async def test_temp_change_ac_on_outside_tolerance(hass, setup_comp_3):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_running_when_operating_mode_is_off_2(hass, setup_comp_3):
@ -630,11 +630,11 @@ async def test_running_when_operating_mode_is_off_2(hass, setup_comp_3):
calls = _setup_switch(hass, True)
await common.async_set_temperature(hass, 30)
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_no_state_change_when_operation_mode_off_2(hass, setup_comp_3):
@ -644,7 +644,7 @@ async def test_no_state_change_when_operation_mode_off_2(hass, setup_comp_3):
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
_setup_sensor(hass, 35)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
@pytest.fixture
@ -677,7 +677,7 @@ async def test_temp_change_ac_trigger_on_not_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_ac_trigger_on_long_enough(hass, setup_comp_4):
@ -692,11 +692,11 @@ async def test_temp_change_ac_trigger_on_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_ac_trigger_off_not_long_enough(hass, setup_comp_4):
@ -705,7 +705,7 @@ async def test_temp_change_ac_trigger_off_not_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_ac_trigger_off_long_enough(hass, setup_comp_4):
@ -720,11 +720,11 @@ async def test_temp_change_ac_trigger_off_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_ac_trigger_off_not_long_enough(hass, setup_comp_4):
@ -733,13 +733,13 @@ async def test_mode_change_ac_trigger_off_not_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_ac_trigger_on_not_long_enough(hass, setup_comp_4):
@ -748,13 +748,13 @@ async def test_mode_change_ac_trigger_on_not_long_enough(hass, setup_comp_4):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_HEAT)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
@pytest.fixture
@ -787,7 +787,7 @@ async def test_temp_change_ac_trigger_on_not_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_ac_trigger_on_long_enough_2(hass, setup_comp_5):
@ -802,11 +802,11 @@ async def test_temp_change_ac_trigger_on_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_ac_trigger_off_not_long_enough_2(hass, setup_comp_5):
@ -815,7 +815,7 @@ async def test_temp_change_ac_trigger_off_not_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_ac_trigger_off_long_enough_2(hass, setup_comp_5):
@ -830,11 +830,11 @@ async def test_temp_change_ac_trigger_off_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_ac_trigger_off_not_long_enough_2(hass, setup_comp_5):
@ -843,13 +843,13 @@ async def test_mode_change_ac_trigger_off_not_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_ac_trigger_on_not_long_enough_2(hass, setup_comp_5):
@ -858,13 +858,13 @@ async def test_mode_change_ac_trigger_on_not_long_enough_2(hass, setup_comp_5):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_HEAT)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
@pytest.fixture
@ -896,7 +896,7 @@ async def test_temp_change_heater_trigger_off_not_long_enough(hass, setup_comp_6
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_heater_trigger_on_not_long_enough(hass, setup_comp_6):
@ -905,7 +905,7 @@ async def test_temp_change_heater_trigger_on_not_long_enough(hass, setup_comp_6)
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async def test_temp_change_heater_trigger_on_long_enough(hass, setup_comp_6):
@ -920,11 +920,11 @@ async def test_temp_change_heater_trigger_on_long_enough(hass, setup_comp_6):
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_heater_trigger_off_long_enough(hass, setup_comp_6):
@ -939,11 +939,11 @@ async def test_temp_change_heater_trigger_off_long_enough(hass, setup_comp_6):
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_heater_trigger_off_not_long_enough(hass, setup_comp_6):
@ -952,13 +952,13 @@ async def test_mode_change_heater_trigger_off_not_long_enough(hass, setup_comp_6
await common.async_set_temperature(hass, 25)
_setup_sensor(hass, 30)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_OFF)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
async def test_mode_change_heater_trigger_on_not_long_enough(hass, setup_comp_6):
@ -967,13 +967,13 @@ async def test_mode_change_heater_trigger_on_not_long_enough(hass, setup_comp_6)
await common.async_set_temperature(hass, 30)
_setup_sensor(hass, 25)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
await common.async_set_hvac_mode(hass, HVAC_MODE_HEAT)
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert "homeassistant" == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == "homeassistant"
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
@pytest.fixture
@ -1013,17 +1013,17 @@ async def test_temp_change_ac_trigger_on_long_enough_3(hass, setup_comp_7):
test_time = datetime.datetime.now(pytz.UTC)
async_fire_time_changed(hass, test_time)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=5))
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=10))
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_ac_trigger_off_long_enough_3(hass, setup_comp_7):
@ -1036,17 +1036,17 @@ async def test_temp_change_ac_trigger_off_long_enough_3(hass, setup_comp_7):
test_time = datetime.datetime.now(pytz.UTC)
async_fire_time_changed(hass, test_time)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=5))
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=10))
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
@pytest.fixture
@ -1084,17 +1084,17 @@ async def test_temp_change_heater_trigger_on_long_enough_2(hass, setup_comp_8):
test_time = datetime.datetime.now(pytz.UTC)
async_fire_time_changed(hass, test_time)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=5))
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=10))
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_ON == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_ON
assert call.data["entity_id"] == ENT_SWITCH
async def test_temp_change_heater_trigger_off_long_enough_2(hass, setup_comp_8):
@ -1107,17 +1107,17 @@ async def test_temp_change_heater_trigger_off_long_enough_2(hass, setup_comp_8):
test_time = datetime.datetime.now(pytz.UTC)
async_fire_time_changed(hass, test_time)
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=5))
await hass.async_block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
async_fire_time_changed(hass, test_time + datetime.timedelta(minutes=10))
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
call = calls[0]
assert HASS_DOMAIN == call.domain
assert SERVICE_TURN_OFF == call.service
assert ENT_SWITCH == call.data["entity_id"]
assert call.domain == HASS_DOMAIN
assert call.service == SERVICE_TURN_OFF
assert call.data["entity_id"] == ENT_SWITCH
@pytest.fixture
@ -1149,7 +1149,7 @@ async def test_precision(hass, setup_comp_9):
"""Test that setting precision to tenths works as intended."""
await common.async_set_temperature(hass, 23.27)
state = hass.states.get(ENTITY)
assert 23.3 == state.attributes.get("temperature")
assert state.attributes.get("temperature") == 23.3
async def test_custom_setup_params(hass):
@ -1350,14 +1350,14 @@ async def test_restore_state_uncoherence_case(hass):
await hass.async_block_till_done()
state = hass.states.get(ENTITY)
assert 20 == state.attributes[ATTR_TEMPERATURE]
assert HVAC_MODE_OFF == state.state
assert 0 == len(calls)
assert state.attributes[ATTR_TEMPERATURE] == 20
assert state.state == HVAC_MODE_OFF
assert len(calls) == 0
calls = _setup_switch(hass, False)
await hass.async_block_till_done()
state = hass.states.get(ENTITY)
assert HVAC_MODE_OFF == state.state
assert state.state == HVAC_MODE_OFF
async def _setup_climate(hass):

View file

@ -196,7 +196,7 @@ async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
assert req.status == HTTP_OK
device_name = slugify(GPS_ENTER_HOME["device"])
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_HOME == state_name
assert state_name == STATE_HOME
# Exit the Home zone
req = await geofency_client.post(url, data=GPS_EXIT_HOME)
@ -204,7 +204,7 @@ async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
assert req.status == HTTP_OK
device_name = slugify(GPS_EXIT_HOME["device"])
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_NOT_HOME == state_name
assert state_name == STATE_NOT_HOME
# Exit the Home zone with "Send Current Position" enabled
data = GPS_EXIT_HOME.copy()
@ -218,11 +218,11 @@ async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
current_latitude = hass.states.get(f"device_tracker.{device_name}").attributes[
"latitude"
]
assert NOT_HOME_LATITUDE == current_latitude
assert current_latitude == NOT_HOME_LATITUDE
current_longitude = hass.states.get(f"device_tracker.{device_name}").attributes[
"longitude"
]
assert NOT_HOME_LONGITUDE == current_longitude
assert current_longitude == NOT_HOME_LONGITUDE
dev_reg = dr.async_get(hass)
assert len(dev_reg.devices) == 1
@ -241,7 +241,7 @@ async def test_beacon_enter_and_exit_home(hass, geofency_client, webhook_id):
assert req.status == HTTP_OK
device_name = slugify(f"beacon_{BEACON_ENTER_HOME['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_HOME == state_name
assert state_name == STATE_HOME
# Exit the Home zone
req = await geofency_client.post(url, data=BEACON_EXIT_HOME)
@ -249,7 +249,7 @@ async def test_beacon_enter_and_exit_home(hass, geofency_client, webhook_id):
assert req.status == HTTP_OK
device_name = slugify(f"beacon_{BEACON_ENTER_HOME['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_NOT_HOME == state_name
assert state_name == STATE_NOT_HOME
async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
@ -262,7 +262,7 @@ async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
assert req.status == HTTP_OK
device_name = slugify(f"beacon_{BEACON_ENTER_CAR['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_NOT_HOME == state_name
assert state_name == STATE_NOT_HOME
# Exit the Car away from Home zone
req = await geofency_client.post(url, data=BEACON_EXIT_CAR)
@ -270,7 +270,7 @@ async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
assert req.status == HTTP_OK
device_name = slugify(f"beacon_{BEACON_ENTER_CAR['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_NOT_HOME == state_name
assert state_name == STATE_NOT_HOME
# Enter the Car in the Home zone
data = BEACON_ENTER_CAR.copy()
@ -281,7 +281,7 @@ async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
assert req.status == HTTP_OK
device_name = slugify(f"beacon_{data['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_HOME == state_name
assert state_name == STATE_HOME
# Exit the Car in the Home zone
req = await geofency_client.post(url, data=data)
@ -289,7 +289,7 @@ async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
assert req.status == HTTP_OK
device_name = slugify(f"beacon_{data['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_HOME == state_name
assert state_name == STATE_HOME
async def test_load_unload_entry(hass, geofency_client, webhook_id):
@ -302,7 +302,7 @@ async def test_load_unload_entry(hass, geofency_client, webhook_id):
assert req.status == HTTP_OK
device_name = slugify(GPS_ENTER_HOME["device"])
state_1 = hass.states.get(f"device_tracker.{device_name}")
assert STATE_HOME == state_1.state
assert state_1.state == STATE_HOME
assert len(hass.data[DOMAIN]["devices"]) == 1
entry = hass.config_entries.async_entries(DOMAIN)[0]
@ -318,6 +318,6 @@ async def test_load_unload_entry(hass, geofency_client, webhook_id):
assert state_2 is not None
assert state_1 is not state_2
assert STATE_HOME == state_2.state
assert state_2.state == STATE_HOME
assert state_2.attributes[ATTR_LATITUDE] == HOME_LATITUDE
assert state_2.attributes[ATTR_LONGITUDE] == HOME_LONGITUDE

View file

@ -82,7 +82,7 @@ async def test_minimal_config(hass, mock_client):
assert await async_setup_component(hass, google_pubsub.DOMAIN, config)
await hass.async_block_till_done()
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[0][0][0]
assert hass.bus.listen.call_args_list[0][0][0] == EVENT_STATE_CHANGED
assert mock_client.PublisherClient.from_service_account_json.call_count == 1
assert (
mock_client.PublisherClient.from_service_account_json.call_args[0][0] == "path"
@ -109,7 +109,7 @@ async def test_full_config(hass, mock_client):
assert await async_setup_component(hass, google_pubsub.DOMAIN, config)
await hass.async_block_till_done()
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[0][0][0]
assert hass.bus.listen.call_args_list[0][0][0] == EVENT_STATE_CHANGED
assert mock_client.PublisherClient.from_service_account_json.call_count == 1
assert (
mock_client.PublisherClient.from_service_account_json.call_args[0][0] == "path"

View file

@ -129,13 +129,13 @@ def test_state(hass, requests_mock):
fake_delay(hass, 2)
sensor.update()
if name == google_wifi.ATTR_LAST_RESTART:
assert "1969-12-31 00:00:00" == sensor.state
assert sensor.state == "1969-12-31 00:00:00"
elif name == google_wifi.ATTR_UPTIME:
assert 1 == sensor.state
assert sensor.state == 1
elif name == google_wifi.ATTR_STATUS:
assert "Online" == sensor.state
assert sensor.state == "Online"
else:
assert "initial" == sensor.state
assert sensor.state == "initial"
def test_update_when_value_is_none(hass, requests_mock):
@ -158,17 +158,17 @@ def test_update_when_value_changed(hass, requests_mock):
fake_delay(hass, 2)
sensor.update()
if name == google_wifi.ATTR_LAST_RESTART:
assert "1969-12-30 00:00:00" == sensor.state
assert sensor.state == "1969-12-30 00:00:00"
elif name == google_wifi.ATTR_UPTIME:
assert 2 == sensor.state
assert sensor.state == 2
elif name == google_wifi.ATTR_STATUS:
assert "Offline" == sensor.state
assert sensor.state == "Offline"
elif name == google_wifi.ATTR_NEW_VERSION:
assert "Latest" == sensor.state
assert sensor.state == "Latest"
elif name == google_wifi.ATTR_LOCAL_IP:
assert STATE_UNKNOWN == sensor.state
assert sensor.state == STATE_UNKNOWN
else:
assert "next" == sensor.state
assert sensor.state == "next"
def test_when_api_data_missing(hass, requests_mock):
@ -180,7 +180,7 @@ def test_when_api_data_missing(hass, requests_mock):
sensor = sensor_dict[name]["sensor"]
fake_delay(hass, 2)
sensor.update()
assert STATE_UNKNOWN == sensor.state
assert sensor.state == STATE_UNKNOWN
def test_update_when_unavailable(requests_mock):

View file

@ -117,14 +117,14 @@ async def test_enter_and_exit(hass, gpslogger_client, webhook_id):
await hass.async_block_till_done()
assert req.status == HTTP_OK
state_name = hass.states.get(f"{DEVICE_TRACKER_DOMAIN}.{data['device']}").state
assert STATE_HOME == state_name
assert state_name == STATE_HOME
# Enter Home again
req = await gpslogger_client.post(url, data=data)
await hass.async_block_till_done()
assert req.status == HTTP_OK
state_name = hass.states.get(f"{DEVICE_TRACKER_DOMAIN}.{data['device']}").state
assert STATE_HOME == state_name
assert state_name == STATE_HOME
data["longitude"] = 0
data["latitude"] = 0
@ -134,7 +134,7 @@ async def test_enter_and_exit(hass, gpslogger_client, webhook_id):
await hass.async_block_till_done()
assert req.status == HTTP_OK
state_name = hass.states.get(f"{DEVICE_TRACKER_DOMAIN}.{data['device']}").state
assert STATE_NOT_HOME == state_name
assert state_name == STATE_NOT_HOME
dev_reg = dr.async_get(hass)
assert len(dev_reg.devices) == 1
@ -213,7 +213,7 @@ async def test_load_unload_entry(hass, gpslogger_client, webhook_id):
await hass.async_block_till_done()
assert req.status == HTTP_OK
state_name = hass.states.get(f"{DEVICE_TRACKER_DOMAIN}.{data['device']}").state
assert STATE_HOME == state_name
assert state_name == STATE_HOME
assert len(hass.data[DATA_DISPATCHER][TRACKER_UPDATE]) == 1
entry = hass.config_entries.async_entries(DOMAIN)[0]

View file

@ -38,7 +38,7 @@ async def test_setup_group_with_mixed_groupable_states(hass):
await hass.async_block_till_done()
assert STATE_ON == hass.states.get(f"{group.DOMAIN}.person_and_light").state
assert hass.states.get(f"{group.DOMAIN}.person_and_light").state == STATE_ON
async def test_setup_group_with_a_non_existing_state(hass):
@ -51,7 +51,7 @@ async def test_setup_group_with_a_non_existing_state(hass):
hass, "light_and_nothing", ["light.Bowl", "non.existing"]
)
assert STATE_ON == grp.state
assert grp.state == STATE_ON
async def test_setup_group_with_non_groupable_states(hass):
@ -90,7 +90,7 @@ async def test_monitor_group(hass):
assert test_group.entity_id in hass.states.async_entity_ids()
group_state = hass.states.get(test_group.entity_id)
assert STATE_ON == group_state.state
assert group_state.state == STATE_ON
assert group_state.attributes.get(group.ATTR_AUTO)
@ -108,7 +108,7 @@ async def test_group_turns_off_if_all_off(hass):
await hass.async_block_till_done()
group_state = hass.states.get(test_group.entity_id)
assert STATE_OFF == group_state.state
assert group_state.state == STATE_OFF
async def test_group_turns_on_if_all_are_off_and_one_turns_on(hass):
@ -127,7 +127,7 @@ async def test_group_turns_on_if_all_are_off_and_one_turns_on(hass):
await hass.async_block_till_done()
group_state = hass.states.get(test_group.entity_id)
assert STATE_ON == group_state.state
assert group_state.state == STATE_ON
async def test_allgroup_stays_off_if_all_are_off_and_one_turns_on(hass):
@ -146,7 +146,7 @@ async def test_allgroup_stays_off_if_all_are_off_and_one_turns_on(hass):
await hass.async_block_till_done()
group_state = hass.states.get(test_group.entity_id)
assert STATE_OFF == group_state.state
assert group_state.state == STATE_OFF
async def test_allgroup_turn_on_if_last_turns_on(hass):
@ -165,7 +165,7 @@ async def test_allgroup_turn_on_if_last_turns_on(hass):
await hass.async_block_till_done()
group_state = hass.states.get(test_group.entity_id)
assert STATE_ON == group_state.state
assert group_state.state == STATE_ON
async def test_expand_entity_ids(hass):
@ -287,7 +287,7 @@ async def test_group_being_init_before_first_tracked_state_is_set_to_on(hass):
await hass.async_block_till_done()
group_state = hass.states.get(test_group.entity_id)
assert STATE_ON == group_state.state
assert group_state.state == STATE_ON
async def test_group_being_init_before_first_tracked_state_is_set_to_off(hass):
@ -306,7 +306,7 @@ async def test_group_being_init_before_first_tracked_state_is_set_to_off(hass):
await hass.async_block_till_done()
group_state = hass.states.get(test_group.entity_id)
assert STATE_OFF == group_state.state
assert group_state.state == STATE_OFF
async def test_groups_get_unique_names(hass):
@ -385,7 +385,7 @@ async def test_group_updated_after_device_tracker_zone_change(hass):
hass.states.async_set("device_tracker.Adam", "cool_state_not_home")
await hass.async_block_till_done()
assert STATE_NOT_HOME == hass.states.get(f"{group.DOMAIN}.peeps").state
assert hass.states.get(f"{group.DOMAIN}.peeps").state == STATE_NOT_HOME
async def test_is_on(hass):
@ -517,20 +517,20 @@ async def test_setup(hass):
await hass.async_block_till_done()
group_state = hass.states.get(f"{group.DOMAIN}.created_group")
assert STATE_ON == group_state.state
assert group_state.state == STATE_ON
assert {test_group.entity_id, "light.bowl"} == set(
group_state.attributes["entity_id"]
)
assert group_state.attributes.get(group.ATTR_AUTO) is None
assert "mdi:work" == group_state.attributes.get(ATTR_ICON)
assert 3 == group_state.attributes.get(group.ATTR_ORDER)
assert group_state.attributes.get(ATTR_ICON) == "mdi:work"
assert group_state.attributes.get(group.ATTR_ORDER) == 3
group_state = hass.states.get(f"{group.DOMAIN}.test_group")
assert STATE_UNKNOWN == group_state.state
assert {"sensor.happy", "hello.world"} == set(group_state.attributes["entity_id"])
assert group_state.state == STATE_UNKNOWN
assert set(group_state.attributes["entity_id"]) == {"sensor.happy", "hello.world"}
assert group_state.attributes.get(group.ATTR_AUTO) is None
assert group_state.attributes.get(ATTR_ICON) is None
assert 0 == group_state.attributes.get(group.ATTR_ORDER)
assert group_state.attributes.get(group.ATTR_ORDER) == 0
async def test_service_group_services(hass):

View file

@ -137,28 +137,28 @@ class TestComponentsCore(unittest.TestCase):
calls = mock_service(self.hass, "light", SERVICE_TURN_ON)
turn_on(self.hass)
self.hass.block_till_done()
assert 0 == len(calls)
assert len(calls) == 0
def test_turn_on(self):
"""Test turn_on method."""
calls = mock_service(self.hass, "light", SERVICE_TURN_ON)
turn_on(self.hass, "light.Ceiling")
self.hass.block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
def test_turn_off(self):
"""Test turn_off method."""
calls = mock_service(self.hass, "light", SERVICE_TURN_OFF)
turn_off(self.hass, "light.Bowl")
self.hass.block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
def test_toggle(self):
"""Test toggle method."""
calls = mock_service(self.hass, "light", SERVICE_TOGGLE)
toggle(self.hass, "light.Bowl")
self.hass.block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
@patch("homeassistant.config.os.path.isfile", Mock(return_value=True))
def test_reload_core_conf(self):

View file

@ -506,7 +506,7 @@ async def test_if_fires_on_entity_change_with_for(hass, calls):
await hass.async_block_till_done()
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=10))
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
async def test_if_fires_on_entity_change_with_for_without_to(hass, calls):

View file

@ -181,7 +181,7 @@ class TestHoneywell(unittest.TestCase):
mock.call(mock_evo.return_value, "bar", False, 20.0),
]
)
assert 2 == add_entities.call_count
assert add_entities.call_count == 2
@mock.patch("evohomeclient.EvohomeClient")
@mock.patch("homeassistant.components.honeywell.climate.HoneywellUSThermostat")
@ -269,15 +269,15 @@ class TestHoneywellRound(unittest.TestCase):
def test_attributes(self):
"""Test the attributes."""
assert "House" == self.round1.name
assert TEMP_CELSIUS == self.round1.temperature_unit
assert 20 == self.round1.current_temperature
assert 21 == self.round1.target_temperature
assert self.round1.name == "House"
assert self.round1.temperature_unit == TEMP_CELSIUS
assert self.round1.current_temperature == 20
assert self.round1.target_temperature == 21
assert not self.round1.is_away_mode_on
assert "Hot Water" == self.round2.name
assert TEMP_CELSIUS == self.round2.temperature_unit
assert 21 == self.round2.current_temperature
assert self.round2.name == "Hot Water"
assert self.round2.temperature_unit == TEMP_CELSIUS
assert self.round2.current_temperature == 21
assert self.round2.target_temperature is None
assert not self.round2.is_away_mode_on
@ -304,12 +304,12 @@ class TestHoneywellRound(unittest.TestCase):
def test_set_hvac_mode(self) -> None:
"""Test setting the system operation."""
self.round1.set_hvac_mode("cool")
assert "cool" == self.round1.current_operation
assert "cool" == self.device.system_mode
assert self.round1.current_operation == "cool"
assert self.device.system_mode == "cool"
self.round1.set_hvac_mode("heat")
assert "heat" == self.round1.current_operation
assert "heat" == self.device.system_mode
assert self.round1.current_operation == "heat"
assert self.device.system_mode == "heat"
class TestHoneywellUS(unittest.TestCase):
@ -342,40 +342,40 @@ class TestHoneywellUS(unittest.TestCase):
def test_properties(self):
"""Test the properties."""
assert self.honeywell.is_fan_on
assert "test" == self.honeywell.name
assert 72 == self.honeywell.current_temperature
assert self.honeywell.name == "test"
assert self.honeywell.current_temperature == 72
def test_unit_of_measurement(self):
"""Test the unit of measurement."""
assert TEMP_FAHRENHEIT == self.honeywell.temperature_unit
assert self.honeywell.temperature_unit == TEMP_FAHRENHEIT
self.device.temperature_unit = "C"
assert TEMP_CELSIUS == self.honeywell.temperature_unit
assert self.honeywell.temperature_unit == TEMP_CELSIUS
def test_target_temp(self):
"""Test the target temperature."""
assert 65 == self.honeywell.target_temperature
assert self.honeywell.target_temperature == 65
self.device.system_mode = "cool"
assert 78 == self.honeywell.target_temperature
assert self.honeywell.target_temperature == 78
def test_set_temp(self):
"""Test setting the temperature."""
self.honeywell.set_temperature(temperature=70)
assert 70 == self.device.setpoint_heat
assert 70 == self.honeywell.target_temperature
assert self.device.setpoint_heat == 70
assert self.honeywell.target_temperature == 70
self.device.system_mode = "cool"
assert 78 == self.honeywell.target_temperature
assert self.honeywell.target_temperature == 78
self.honeywell.set_temperature(temperature=74)
assert 74 == self.device.setpoint_cool
assert 74 == self.honeywell.target_temperature
assert self.device.setpoint_cool == 74
assert self.honeywell.target_temperature == 74
def test_set_hvac_mode(self) -> None:
"""Test setting the operation mode."""
self.honeywell.set_hvac_mode("cool")
assert "cool" == self.device.system_mode
assert self.device.system_mode == "cool"
self.honeywell.set_hvac_mode("heat")
assert "heat" == self.device.system_mode
assert self.device.system_mode == "heat"
def test_set_temp_fail(self):
"""Test if setting the temperature fails."""
@ -395,7 +395,7 @@ class TestHoneywellUS(unittest.TestCase):
assert expected == self.honeywell.extra_state_attributes
expected["fan"] = "idle"
self.device.fan_running = False
assert expected == self.honeywell.extra_state_attributes
assert self.honeywell.extra_state_attributes == expected
def test_with_no_fan(self):
"""Test if there is on fan."""
@ -407,7 +407,7 @@ class TestHoneywellUS(unittest.TestCase):
ATTR_FAN_MODES: somecomfort.FAN_MODES,
ATTR_HVAC_MODES: somecomfort.SYSTEM_MODES,
}
assert expected == self.honeywell.extra_state_attributes
assert self.honeywell.extra_state_attributes == expected
def test_heat_away_mode(self):
"""Test setting the heat away mode."""

View file

@ -47,10 +47,10 @@ async def test_allowed_sender(hass):
sensor.entity_id = "sensor.emailtest"
sensor.async_schedule_update_ha_state(True)
await hass.async_block_till_done()
assert "Test" == sensor.state
assert "Test Message" == sensor.extra_state_attributes["body"]
assert "sender@test.com" == sensor.extra_state_attributes["from"]
assert "Test" == sensor.extra_state_attributes["subject"]
assert sensor.state == "Test"
assert sensor.extra_state_attributes["body"] == "Test Message"
assert sensor.extra_state_attributes["from"] == "sender@test.com"
assert sensor.extra_state_attributes["subject"] == "Test"
assert (
datetime.datetime(2016, 1, 1, 12, 44, 57)
== sensor.extra_state_attributes["date"]
@ -83,8 +83,8 @@ async def test_multi_part_with_text(hass):
sensor.entity_id = "sensor.emailtest"
sensor.async_schedule_update_ha_state(True)
await hass.async_block_till_done()
assert "Link" == sensor.state
assert "Test Message" == sensor.extra_state_attributes["body"]
assert sensor.state == "Link"
assert sensor.extra_state_attributes["body"] == "Test Message"
async def test_multi_part_only_html(hass):
@ -110,10 +110,10 @@ async def test_multi_part_only_html(hass):
sensor.entity_id = "sensor.emailtest"
sensor.async_schedule_update_ha_state(True)
await hass.async_block_till_done()
assert "Link" == sensor.state
assert sensor.state == "Link"
assert (
"<html><head></head><body>Test Message</body></html>"
== sensor.extra_state_attributes["body"]
sensor.extra_state_attributes["body"]
== "<html><head></head><body>Test Message</body></html>"
)
@ -140,8 +140,8 @@ async def test_multi_part_only_other_text(hass):
sensor.entity_id = "sensor.emailtest"
sensor.async_schedule_update_ha_state(True)
await hass.async_block_till_done()
assert "Link" == sensor.state
assert "Test Message" == sensor.extra_state_attributes["body"]
assert sensor.state == "Link"
assert sensor.extra_state_attributes["body"] == "Test Message"
async def test_multiple_emails(hass):
@ -180,10 +180,10 @@ async def test_multiple_emails(hass):
sensor.async_schedule_update_ha_state(True)
await hass.async_block_till_done()
assert "Test" == states[0].state
assert "Test 2" == states[1].state
assert states[0].state == "Test"
assert states[1].state == "Test 2"
assert "Test Message 2" == sensor.extra_state_attributes["body"]
assert sensor.extra_state_attributes["body"] == "Test Message 2"
async def test_sender_not_allowed(hass):
@ -227,4 +227,4 @@ async def test_template(hass):
sensor.entity_id = "sensor.emailtest"
sensor.async_schedule_update_ha_state(True)
await hass.async_block_till_done()
assert "Test from sender@test.com with message Test Message" == sensor.state
assert sensor.state == "Test from sender@test.com with message Test Message"

View file

@ -127,7 +127,7 @@ async def test_setup_config_full(hass, mock_client, config_ext, get_write_api):
assert await async_setup_component(hass, influxdb.DOMAIN, config)
await hass.async_block_till_done()
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[0][0][0]
assert hass.bus.listen.call_args_list[0][0][0] == EVENT_STATE_CHANGED
assert get_write_api(mock_client).call_count == 1
@ -260,7 +260,7 @@ async def test_setup_config_ssl(
await hass.async_block_till_done()
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[0][0][0]
assert hass.bus.listen.call_args_list[0][0][0] == EVENT_STATE_CHANGED
assert expected_client_args.items() <= mock_client.call_args.kwargs.items()
@ -280,7 +280,7 @@ async def test_setup_minimal_config(hass, mock_client, config_ext, get_write_api
assert await async_setup_component(hass, influxdb.DOMAIN, config)
await hass.async_block_till_done()
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[0][0][0]
assert hass.bus.listen.call_args_list[0][0][0] == EVENT_STATE_CHANGED
assert get_write_api(mock_client).call_count == 1

View file

@ -109,13 +109,13 @@ async def test_config_options(hass):
assert state_1 is not None
assert state_2 is not None
assert STATE_OFF == state_1.state
assert state_1.state == STATE_OFF
assert ATTR_ICON not in state_1.attributes
assert ATTR_FRIENDLY_NAME not in state_1.attributes
assert STATE_ON == state_2.state
assert "Hello World" == state_2.attributes.get(ATTR_FRIENDLY_NAME)
assert "mdi:work" == state_2.attributes.get(ATTR_ICON)
assert state_2.state == STATE_ON
assert state_2.attributes.get(ATTR_FRIENDLY_NAME) == "Hello World"
assert state_2.attributes.get(ATTR_ICON) == "mdi:work"
async def test_restore_state(hass):
@ -218,7 +218,7 @@ async def test_reload(hass, hass_admin_user):
assert state_1 is not None
assert state_2 is not None
assert state_3 is None
assert STATE_ON == state_2.state
assert state_2.state == STATE_ON
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_1") is not None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_2") is not None
@ -259,9 +259,9 @@ async def test_reload(hass, hass_admin_user):
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_2") is not None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_3") is not None
assert STATE_ON == state_2.state # reload is not supposed to change entity state
assert "Hello World reloaded" == state_2.attributes.get(ATTR_FRIENDLY_NAME)
assert "mdi:work_reloaded" == state_2.attributes.get(ATTR_ICON)
assert state_2.state == STATE_ON # reload is not supposed to change entity state
assert state_2.attributes.get(ATTR_FRIENDLY_NAME) == "Hello World reloaded"
assert state_2.attributes.get(ATTR_ICON) == "mdi:work_reloaded"
async def test_load_from_storage(hass, storage_setup):

View file

@ -116,17 +116,17 @@ async def test_set_value(hass, caplog):
entity_id = "input_number.test_1"
state = hass.states.get(entity_id)
assert 50 == float(state.state)
assert float(state.state) == 50
await set_value(hass, entity_id, "30.4")
state = hass.states.get(entity_id)
assert 30.4 == float(state.state)
assert float(state.state) == 30.4
await set_value(hass, entity_id, "70")
state = hass.states.get(entity_id)
assert 70 == float(state.state)
assert float(state.state) == 70
with pytest.raises(vol.Invalid) as excinfo:
await set_value(hass, entity_id, "110")
@ -136,7 +136,7 @@ async def test_set_value(hass, caplog):
)
state = hass.states.get(entity_id)
assert 70 == float(state.state)
assert float(state.state) == 70
async def test_increment(hass):
@ -147,19 +147,19 @@ async def test_increment(hass):
entity_id = "input_number.test_2"
state = hass.states.get(entity_id)
assert 50 == float(state.state)
assert float(state.state) == 50
await increment(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 51 == float(state.state)
assert float(state.state) == 51
await increment(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 51 == float(state.state)
assert float(state.state) == 51
async def test_decrement(hass):
@ -170,19 +170,19 @@ async def test_decrement(hass):
entity_id = "input_number.test_3"
state = hass.states.get(entity_id)
assert 50 == float(state.state)
assert float(state.state) == 50
await decrement(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 49 == float(state.state)
assert float(state.state) == 49
await decrement(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert 49 == float(state.state)
assert float(state.state) == 49
async def test_mode(hass):
@ -201,15 +201,15 @@ async def test_mode(hass):
state = hass.states.get("input_number.test_default_slider")
assert state
assert "slider" == state.attributes["mode"]
assert state.attributes["mode"] == "slider"
state = hass.states.get("input_number.test_explicit_box")
assert state
assert "box" == state.attributes["mode"]
assert state.attributes["mode"] == "box"
state = hass.states.get("input_number.test_explicit_slider")
assert state
assert "slider" == state.attributes["mode"]
assert state.attributes["mode"] == "slider"
async def test_restore_state(hass):
@ -322,8 +322,8 @@ async def test_reload(hass, hass_admin_user, hass_read_only_user):
assert state_1 is not None
assert state_2 is None
assert state_3 is not None
assert 50 == float(state_1.state)
assert 10 == float(state_3.state)
assert float(state_1.state) == 50
assert float(state_3.state) == 10
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_1") is not None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_2") is None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_3") is not None
@ -362,8 +362,8 @@ async def test_reload(hass, hass_admin_user, hass_read_only_user):
assert state_1 is not None
assert state_2 is not None
assert state_3 is None
assert 50 == float(state_1.state)
assert 20 == float(state_2.state)
assert float(state_1.state) == 50
assert float(state_2.state) == 20
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_1") is not None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_2") is not None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_3") is None

View file

@ -156,19 +156,19 @@ async def test_select_option(hass):
entity_id = "input_select.test_1"
state = hass.states.get(entity_id)
assert "some option" == state.state
assert state.state == "some option"
select_option(hass, entity_id, "another option")
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert "another option" == state.state
assert state.state == "another option"
select_option(hass, entity_id, "non existing option")
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert "another option" == state.state
assert state.state == "another option"
async def test_select_next(hass):
@ -188,19 +188,19 @@ async def test_select_next(hass):
entity_id = "input_select.test_1"
state = hass.states.get(entity_id)
assert "middle option" == state.state
assert state.state == "middle option"
select_next(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert "last option" == state.state
assert state.state == "last option"
select_next(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert "first option" == state.state
assert state.state == "first option"
async def test_select_previous(hass):
@ -220,19 +220,19 @@ async def test_select_previous(hass):
entity_id = "input_select.test_1"
state = hass.states.get(entity_id)
assert "middle option" == state.state
assert state.state == "middle option"
select_previous(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert "first option" == state.state
assert state.state == "first option"
select_previous(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert "last option" == state.state
assert state.state == "last option"
async def test_select_first_last(hass):
@ -252,19 +252,19 @@ async def test_select_first_last(hass):
entity_id = "input_select.test_1"
state = hass.states.get(entity_id)
assert "middle option" == state.state
assert state.state == "middle option"
select_first(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert "first option" == state.state
assert state.state == "first option"
select_last(hass, entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert "last option" == state.state
assert state.state == "last option"
async def test_config_options(hass):
@ -297,14 +297,14 @@ async def test_config_options(hass):
assert state_1 is not None
assert state_2 is not None
assert "1" == state_1.state
assert ["1", "2"] == state_1.attributes.get(ATTR_OPTIONS)
assert state_1.state == "1"
assert state_1.attributes.get(ATTR_OPTIONS) == ["1", "2"]
assert ATTR_ICON not in state_1.attributes
assert "Better Option" == state_2.state
assert test_2_options == state_2.attributes.get(ATTR_OPTIONS)
assert "Hello World" == state_2.attributes.get(ATTR_FRIENDLY_NAME)
assert "mdi:work" == state_2.attributes.get(ATTR_ICON)
assert state_2.state == "Better Option"
assert state_2.attributes.get(ATTR_OPTIONS) == test_2_options
assert state_2.attributes.get(ATTR_FRIENDLY_NAME) == "Hello World"
assert state_2.attributes.get(ATTR_ICON) == "mdi:work"
async def test_set_options_service(hass):
@ -324,24 +324,24 @@ async def test_set_options_service(hass):
entity_id = "input_select.test_1"
state = hass.states.get(entity_id)
assert "middle option" == state.state
assert state.state == "middle option"
data = {ATTR_OPTIONS: ["test1", "test2"], "entity_id": entity_id}
await hass.services.async_call(DOMAIN, SERVICE_SET_OPTIONS, data)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert "test1" == state.state
assert state.state == "test1"
select_option(hass, entity_id, "first option")
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert "test1" == state.state
assert state.state == "test1"
select_option(hass, entity_id, "test2")
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert "test2" == state.state
assert state.state == "test2"
async def test_restore_state(hass):
@ -453,8 +453,8 @@ async def test_reload(hass, hass_admin_user, hass_read_only_user):
assert state_1 is not None
assert state_2 is not None
assert state_3 is None
assert "middle option" == state_1.state
assert "an option" == state_2.state
assert state_1.state == "middle option"
assert state_2.state == "an option"
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_1") is not None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_2") is not None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_3") is None
@ -499,8 +499,8 @@ async def test_reload(hass, hass_admin_user, hass_read_only_user):
assert state_1 is None
assert state_2 is not None
assert state_3 is not None
assert "an option" == state_2.state
assert "newer option" == state_3.state
assert state_2.state == "an option"
assert state_3.state == "newer option"
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_1") is None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_2") is not None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_3") is not None

View file

@ -15,7 +15,7 @@ async def test_setup_config_full(hass):
hass.bus.listen = MagicMock()
assert await async_setup_component(hass, logentries.DOMAIN, config)
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[0][0][0]
assert hass.bus.listen.call_args_list[0][0][0] == EVENT_STATE_CHANGED
async def test_setup_config_defaults(hass):
@ -24,7 +24,7 @@ async def test_setup_config_defaults(hass):
hass.bus.listen = MagicMock()
assert await async_setup_component(hass, logentries.DOMAIN, config)
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[0][0][0]
assert hass.bus.listen.call_args_list[0][0][0] == EVENT_STATE_CHANGED
@pytest.fixture

View file

@ -23,7 +23,8 @@ async def test_get_platforms_from_mailbox(mock_http_client):
req = await mock_http_client.get(url)
assert req.status == 200
result = await req.json()
assert len(result) == 1 and "DemoMailbox" == result[0].get("name", None)
assert len(result) == 1
assert result[0].get("name") == "DemoMailbox"
async def test_get_messages_from_mailbox(mock_http_client):

View file

@ -51,11 +51,11 @@ async def test_arm_home_no_pending(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, CODE)
assert STATE_ALARM_ARMED_HOME == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_HOME
async def test_arm_home_no_pending_when_code_not_req(hass):
@ -78,11 +78,11 @@ async def test_arm_home_no_pending_when_code_not_req(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, 0)
assert STATE_ALARM_ARMED_HOME == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_HOME
async def test_arm_home_with_pending(hass):
@ -104,11 +104,11 @@ async def test_arm_home_with_pending(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, CODE, entity_id)
assert STATE_ALARM_ARMING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMING
state = hass.states.get(entity_id)
assert state.attributes["next_state"] == STATE_ALARM_ARMED_HOME
@ -144,11 +144,11 @@ async def test_arm_home_with_invalid_code(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, CODE + "2")
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_arm_away_no_pending(hass):
@ -170,11 +170,11 @@ async def test_arm_away_no_pending(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE, entity_id)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
async def test_arm_away_no_pending_when_code_not_req(hass):
@ -197,11 +197,11 @@ async def test_arm_away_no_pending_when_code_not_req(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, 0, entity_id)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
async def test_arm_home_with_template_code(hass):
@ -223,12 +223,12 @@ async def test_arm_home_with_template_code(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, "abc")
state = hass.states.get(entity_id)
assert STATE_ALARM_ARMED_HOME == state.state
assert state.state == STATE_ALARM_ARMED_HOME
async def test_arm_away_with_pending(hass):
@ -250,11 +250,11 @@ async def test_arm_away_with_pending(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
assert STATE_ALARM_ARMING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMING
state = hass.states.get(entity_id)
assert state.attributes["next_state"] == STATE_ALARM_ARMED_AWAY
@ -290,11 +290,11 @@ async def test_arm_away_with_invalid_code(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE + "2")
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_arm_night_no_pending(hass):
@ -316,11 +316,11 @@ async def test_arm_night_no_pending(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_night(hass, CODE)
assert STATE_ALARM_ARMED_NIGHT == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_NIGHT
async def test_arm_night_no_pending_when_code_not_req(hass):
@ -343,11 +343,11 @@ async def test_arm_night_no_pending_when_code_not_req(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_night(hass, 0)
assert STATE_ALARM_ARMED_NIGHT == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_NIGHT
async def test_arm_night_with_pending(hass):
@ -369,11 +369,11 @@ async def test_arm_night_with_pending(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_night(hass, CODE, entity_id)
assert STATE_ALARM_ARMING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMING
state = hass.states.get(entity_id)
assert state.attributes["next_state"] == STATE_ALARM_ARMED_NIGHT
@ -392,7 +392,7 @@ async def test_arm_night_with_pending(hass):
# Do not go to the pending state when updating to the same state
await common.async_alarm_arm_night(hass, CODE, entity_id)
assert STATE_ALARM_ARMED_NIGHT == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_NIGHT
async def test_arm_night_with_invalid_code(hass):
@ -414,11 +414,11 @@ async def test_arm_night_with_invalid_code(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_night(hass, CODE + "2")
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_no_pending(hass):
@ -439,11 +439,11 @@ async def test_trigger_no_pending(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass, entity_id=entity_id)
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
future = dt_util.utcnow() + timedelta(seconds=60)
with patch(
@ -453,7 +453,7 @@ async def test_trigger_no_pending(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
async def test_trigger_with_delay(hass):
@ -476,17 +476,17 @@ async def test_trigger_with_delay(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
state = hass.states.get(entity_id)
assert STATE_ALARM_PENDING == state.state
assert STATE_ALARM_TRIGGERED == state.attributes["next_state"]
assert state.state == STATE_ALARM_PENDING
assert state.attributes["next_state"] == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
@ -497,7 +497,7 @@ async def test_trigger_with_delay(hass):
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_TRIGGERED == state.state
assert state.state == STATE_ALARM_TRIGGERED
async def test_trigger_zero_trigger_time(hass):
@ -519,11 +519,11 @@ async def test_trigger_zero_trigger_time(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass)
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_zero_trigger_time_with_pending(hass):
@ -545,11 +545,11 @@ async def test_trigger_zero_trigger_time_with_pending(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass)
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_with_pending(hass):
@ -571,11 +571,11 @@ async def test_trigger_with_pending(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass)
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
state = hass.states.get(entity_id)
assert state.attributes["next_state"] == STATE_ALARM_TRIGGERED
@ -624,17 +624,17 @@ async def test_trigger_with_unused_specific_delay(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
state = hass.states.get(entity_id)
assert STATE_ALARM_PENDING == state.state
assert STATE_ALARM_TRIGGERED == state.attributes["next_state"]
assert state.state == STATE_ALARM_PENDING
assert state.attributes["next_state"] == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -669,17 +669,17 @@ async def test_trigger_with_specific_delay(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
state = hass.states.get(entity_id)
assert STATE_ALARM_PENDING == state.state
assert STATE_ALARM_TRIGGERED == state.attributes["next_state"]
assert state.state == STATE_ALARM_PENDING
assert state.attributes["next_state"] == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
@ -713,11 +713,11 @@ async def test_trigger_with_pending_and_delay(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
@ -770,11 +770,11 @@ async def test_trigger_with_pending_and_specific_delay(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
@ -826,7 +826,7 @@ async def test_armed_home_with_specific_pending(hass):
await common.async_alarm_arm_home(hass)
assert STATE_ALARM_ARMING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMING
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
@ -836,7 +836,7 @@ async def test_armed_home_with_specific_pending(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_HOME == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_HOME
async def test_armed_away_with_specific_pending(hass):
@ -859,7 +859,7 @@ async def test_armed_away_with_specific_pending(hass):
await common.async_alarm_arm_away(hass)
assert STATE_ALARM_ARMING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMING
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
@ -869,7 +869,7 @@ async def test_armed_away_with_specific_pending(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
async def test_armed_night_with_specific_pending(hass):
@ -892,7 +892,7 @@ async def test_armed_night_with_specific_pending(hass):
await common.async_alarm_arm_night(hass)
assert STATE_ALARM_ARMING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMING
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
@ -902,7 +902,7 @@ async def test_armed_night_with_specific_pending(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_NIGHT == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_NIGHT
async def test_trigger_with_specific_pending(hass):
@ -927,7 +927,7 @@ async def test_trigger_with_specific_pending(hass):
await common.async_alarm_trigger(hass)
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
@ -937,7 +937,7 @@ async def test_trigger_with_specific_pending(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -947,7 +947,7 @@ async def test_trigger_with_specific_pending(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_with_disarm_after_trigger(hass):
@ -969,11 +969,11 @@ async def test_trigger_with_disarm_after_trigger(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass, entity_id=entity_id)
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -983,7 +983,7 @@ async def test_trigger_with_disarm_after_trigger(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_with_zero_specific_trigger_time(hass):
@ -1006,11 +1006,11 @@ async def test_trigger_with_zero_specific_trigger_time(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass, entity_id=entity_id)
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_with_unused_zero_specific_trigger_time(hass):
@ -1033,11 +1033,11 @@ async def test_trigger_with_unused_zero_specific_trigger_time(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass, entity_id=entity_id)
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -1047,7 +1047,7 @@ async def test_trigger_with_unused_zero_specific_trigger_time(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_with_specific_trigger_time(hass):
@ -1069,11 +1069,11 @@ async def test_trigger_with_specific_trigger_time(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass, entity_id=entity_id)
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -1083,7 +1083,7 @@ async def test_trigger_with_specific_trigger_time(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_with_no_disarm_after_trigger(hass):
@ -1106,15 +1106,15 @@ async def test_trigger_with_no_disarm_after_trigger(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE, entity_id)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -1124,7 +1124,7 @@ async def test_trigger_with_no_disarm_after_trigger(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass):
@ -1147,15 +1147,15 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE, entity_id)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -1165,11 +1165,11 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -1179,7 +1179,7 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
async def test_disarm_while_pending_trigger(hass):
@ -1200,15 +1200,15 @@ async def test_disarm_while_pending_trigger(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass)
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
await common.async_alarm_disarm(hass, entity_id=entity_id)
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -1218,7 +1218,7 @@ async def test_disarm_while_pending_trigger(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_disarm_during_trigger_with_invalid_code(hass):
@ -1240,15 +1240,15 @@ async def test_disarm_during_trigger_with_invalid_code(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass)
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
await common.async_alarm_disarm(hass, entity_id=entity_id)
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -1258,7 +1258,7 @@ async def test_disarm_during_trigger_with_invalid_code(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
async def test_disarm_with_template_code(hass):
@ -1280,22 +1280,22 @@ async def test_disarm_with_template_code(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, "def")
state = hass.states.get(entity_id)
assert STATE_ALARM_ARMED_HOME == state.state
assert state.state == STATE_ALARM_ARMED_HOME
await common.async_alarm_disarm(hass, "def")
state = hass.states.get(entity_id)
assert STATE_ALARM_ARMED_HOME == state.state
assert state.state == STATE_ALARM_ARMED_HOME
await common.async_alarm_disarm(hass, "abc")
state = hass.states.get(entity_id)
assert STATE_ALARM_DISARMED == state.state
assert state.state == STATE_ALARM_DISARMED
async def test_arm_custom_bypass_no_pending(hass):
@ -1317,11 +1317,11 @@ async def test_arm_custom_bypass_no_pending(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_custom_bypass(hass, CODE)
assert STATE_ALARM_ARMED_CUSTOM_BYPASS == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_CUSTOM_BYPASS
async def test_arm_custom_bypass_no_pending_when_code_not_req(hass):
@ -1344,11 +1344,11 @@ async def test_arm_custom_bypass_no_pending_when_code_not_req(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_custom_bypass(hass, 0)
assert STATE_ALARM_ARMED_CUSTOM_BYPASS == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_CUSTOM_BYPASS
async def test_arm_custom_bypass_with_pending(hass):
@ -1370,11 +1370,11 @@ async def test_arm_custom_bypass_with_pending(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_custom_bypass(hass, CODE, entity_id)
assert STATE_ALARM_ARMING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMING
state = hass.states.get(entity_id)
assert state.attributes["next_state"] == STATE_ALARM_ARMED_CUSTOM_BYPASS
@ -1410,11 +1410,11 @@ async def test_arm_custom_bypass_with_invalid_code(hass):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_custom_bypass(hass, CODE + "2")
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_armed_custom_bypass_with_specific_pending(hass):
@ -1437,7 +1437,7 @@ async def test_armed_custom_bypass_with_specific_pending(hass):
await common.async_alarm_arm_custom_bypass(hass)
assert STATE_ALARM_ARMING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMING
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
@ -1447,7 +1447,7 @@ async def test_armed_custom_bypass_with_specific_pending(hass):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_CUSTOM_BYPASS == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_CUSTOM_BYPASS
async def test_arm_away_after_disabled_disarmed(hass, legacy_patchable_time):
@ -1472,21 +1472,21 @@ async def test_arm_away_after_disabled_disarmed(hass, legacy_patchable_time):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
state = hass.states.get(entity_id)
assert STATE_ALARM_ARMING == state.state
assert STATE_ALARM_DISARMED == state.attributes["previous_state"]
assert STATE_ALARM_ARMED_AWAY == state.attributes["next_state"]
assert state.state == STATE_ALARM_ARMING
assert state.attributes["previous_state"] == STATE_ALARM_DISARMED
assert state.attributes["next_state"] == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
state = hass.states.get(entity_id)
assert STATE_ALARM_ARMING == state.state
assert STATE_ALARM_DISARMED == state.attributes["previous_state"]
assert STATE_ALARM_ARMED_AWAY == state.attributes["next_state"]
assert state.state == STATE_ALARM_ARMING
assert state.attributes["previous_state"] == STATE_ALARM_DISARMED
assert state.attributes["next_state"] == STATE_ALARM_ARMED_AWAY
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
@ -1497,14 +1497,14 @@ async def test_arm_away_after_disabled_disarmed(hass, legacy_patchable_time):
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_ARMED_AWAY == state.state
assert state.state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
state = hass.states.get(entity_id)
assert STATE_ALARM_PENDING == state.state
assert STATE_ALARM_ARMED_AWAY == state.attributes["previous_state"]
assert STATE_ALARM_TRIGGERED == state.attributes["next_state"]
assert state.state == STATE_ALARM_PENDING
assert state.attributes["previous_state"] == STATE_ALARM_ARMED_AWAY
assert state.attributes["next_state"] == STATE_ALARM_TRIGGERED
future += timedelta(seconds=1)
with patch(
@ -1515,7 +1515,7 @@ async def test_arm_away_after_disabled_disarmed(hass, legacy_patchable_time):
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_TRIGGERED == state.state
assert state.state == STATE_ALARM_TRIGGERED
async def test_restore_armed_state(hass):

View file

@ -76,12 +76,12 @@ async def test_arm_home_no_pending(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, CODE)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_HOME == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_HOME
async def test_arm_home_no_pending_when_code_not_req(hass, mqtt_mock):
@ -106,12 +106,12 @@ async def test_arm_home_no_pending_when_code_not_req(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, 0)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_HOME == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_HOME
async def test_arm_home_with_pending(hass, mqtt_mock):
@ -135,12 +135,12 @@ async def test_arm_home_with_pending(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, CODE, entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
state = hass.states.get(entity_id)
assert state.attributes["post_pending_state"] == STATE_ALARM_ARMED_HOME
@ -153,7 +153,7 @@ async def test_arm_home_with_pending(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_HOME == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_HOME
async def test_arm_home_with_invalid_code(hass, mqtt_mock):
@ -177,12 +177,12 @@ async def test_arm_home_with_invalid_code(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, f"{CODE}2")
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_arm_away_no_pending(hass, mqtt_mock):
@ -206,12 +206,12 @@ async def test_arm_away_no_pending(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE, entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
async def test_arm_away_no_pending_when_code_not_req(hass, mqtt_mock):
@ -236,12 +236,12 @@ async def test_arm_away_no_pending_when_code_not_req(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, 0, entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
async def test_arm_home_with_template_code(hass, mqtt_mock):
@ -265,13 +265,13 @@ async def test_arm_home_with_template_code(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, "abc")
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_ARMED_HOME == state.state
assert state.state == STATE_ALARM_ARMED_HOME
async def test_arm_away_with_pending(hass, mqtt_mock):
@ -295,12 +295,12 @@ async def test_arm_away_with_pending(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
state = hass.states.get(entity_id)
assert state.attributes["post_pending_state"] == STATE_ALARM_ARMED_AWAY
@ -313,7 +313,7 @@ async def test_arm_away_with_pending(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
async def test_arm_away_with_invalid_code(hass, mqtt_mock):
@ -337,12 +337,12 @@ async def test_arm_away_with_invalid_code(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, f"{CODE}2")
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_arm_night_no_pending(hass, mqtt_mock):
@ -366,12 +366,12 @@ async def test_arm_night_no_pending(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_night(hass, CODE, entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_NIGHT == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_NIGHT
async def test_arm_night_no_pending_when_code_not_req(hass, mqtt_mock):
@ -396,12 +396,12 @@ async def test_arm_night_no_pending_when_code_not_req(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_night(hass, 0, entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_NIGHT == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_NIGHT
async def test_arm_night_with_pending(hass, mqtt_mock):
@ -425,12 +425,12 @@ async def test_arm_night_with_pending(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_night(hass, CODE)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
state = hass.states.get(entity_id)
assert state.attributes["post_pending_state"] == STATE_ALARM_ARMED_NIGHT
@ -443,13 +443,13 @@ async def test_arm_night_with_pending(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_NIGHT == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_NIGHT
# Do not go to the pending state when updating to the same state
await common.async_alarm_arm_night(hass, CODE, entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_NIGHT == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_NIGHT
async def test_arm_night_with_invalid_code(hass, mqtt_mock):
@ -473,12 +473,12 @@ async def test_arm_night_with_invalid_code(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_night(hass, f"{CODE}2")
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_no_pending(hass, mqtt_mock):
@ -501,12 +501,12 @@ async def test_trigger_no_pending(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
future = dt_util.utcnow() + timedelta(seconds=60)
with patch(
@ -516,7 +516,7 @@ async def test_trigger_no_pending(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
async def test_trigger_with_delay(hass, mqtt_mock):
@ -541,19 +541,19 @@ async def test_trigger_with_delay(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_PENDING == state.state
assert STATE_ALARM_TRIGGERED == state.attributes["post_pending_state"]
assert state.state == STATE_ALARM_PENDING
assert state.attributes["post_pending_state"] == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
@ -564,7 +564,7 @@ async def test_trigger_with_delay(hass, mqtt_mock):
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_TRIGGERED == state.state
assert state.state == STATE_ALARM_TRIGGERED
async def test_trigger_zero_trigger_time(hass, mqtt_mock):
@ -588,12 +588,12 @@ async def test_trigger_zero_trigger_time(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_zero_trigger_time_with_pending(hass, mqtt_mock):
@ -617,12 +617,12 @@ async def test_trigger_zero_trigger_time_with_pending(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_with_pending(hass, mqtt_mock):
@ -646,12 +646,12 @@ async def test_trigger_with_pending(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
state = hass.states.get(entity_id)
assert state.attributes["post_pending_state"] == STATE_ALARM_TRIGGERED
@ -664,7 +664,7 @@ async def test_trigger_with_pending(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -674,7 +674,7 @@ async def test_trigger_with_pending(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_with_disarm_after_trigger(hass, mqtt_mock):
@ -698,12 +698,12 @@ async def test_trigger_with_disarm_after_trigger(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -713,7 +713,7 @@ async def test_trigger_with_disarm_after_trigger(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_with_zero_specific_trigger_time(hass, mqtt_mock):
@ -738,12 +738,12 @@ async def test_trigger_with_zero_specific_trigger_time(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_with_unused_zero_specific_trigger_time(hass, mqtt_mock):
@ -768,12 +768,12 @@ async def test_trigger_with_unused_zero_specific_trigger_time(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -783,7 +783,7 @@ async def test_trigger_with_unused_zero_specific_trigger_time(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_trigger_with_specific_trigger_time(hass, mqtt_mock):
@ -807,12 +807,12 @@ async def test_trigger_with_specific_trigger_time(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -822,7 +822,7 @@ async def test_trigger_with_specific_trigger_time(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass, mqtt_mock):
@ -846,17 +846,17 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass, mqtt_mock
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE, entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -866,12 +866,12 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass, mqtt_mock
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -881,7 +881,7 @@ async def test_back_to_back_trigger_with_no_disarm_after_trigger(hass, mqtt_mock
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
async def test_disarm_while_pending_trigger(hass, mqtt_mock):
@ -904,17 +904,17 @@ async def test_disarm_while_pending_trigger(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
await common.async_alarm_disarm(hass, entity_id=entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -924,7 +924,7 @@ async def test_disarm_while_pending_trigger(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_disarm_during_trigger_with_invalid_code(hass, mqtt_mock):
@ -948,17 +948,17 @@ async def test_disarm_during_trigger_with_invalid_code(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
await common.async_alarm_disarm(hass, entity_id=entity_id)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -968,7 +968,7 @@ async def test_disarm_during_trigger_with_invalid_code(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
async def test_trigger_with_unused_specific_delay(hass, mqtt_mock):
@ -994,19 +994,19 @@ async def test_trigger_with_unused_specific_delay(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_PENDING == state.state
assert STATE_ALARM_TRIGGERED == state.attributes["post_pending_state"]
assert state.state == STATE_ALARM_PENDING
assert state.attributes["post_pending_state"] == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -1043,19 +1043,19 @@ async def test_trigger_with_specific_delay(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_PENDING == state.state
assert STATE_ALARM_TRIGGERED == state.attributes["post_pending_state"]
assert state.state == STATE_ALARM_PENDING
assert state.attributes["post_pending_state"] == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
@ -1092,12 +1092,12 @@ async def test_trigger_with_pending_and_delay(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
@ -1154,12 +1154,12 @@ async def test_trigger_with_pending_and_specific_delay(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
@ -1215,7 +1215,7 @@ async def test_armed_home_with_specific_pending(hass, mqtt_mock):
await common.async_alarm_arm_home(hass)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
@ -1225,7 +1225,7 @@ async def test_armed_home_with_specific_pending(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_HOME == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_HOME
async def test_armed_away_with_specific_pending(hass, mqtt_mock):
@ -1251,7 +1251,7 @@ async def test_armed_away_with_specific_pending(hass, mqtt_mock):
await common.async_alarm_arm_away(hass)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
@ -1261,7 +1261,7 @@ async def test_armed_away_with_specific_pending(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
async def test_armed_night_with_specific_pending(hass, mqtt_mock):
@ -1287,7 +1287,7 @@ async def test_armed_night_with_specific_pending(hass, mqtt_mock):
await common.async_alarm_arm_night(hass)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
@ -1297,7 +1297,7 @@ async def test_armed_night_with_specific_pending(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_NIGHT == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_NIGHT
async def test_trigger_with_specific_pending(hass, mqtt_mock):
@ -1325,7 +1325,7 @@ async def test_trigger_with_specific_pending(hass, mqtt_mock):
await common.async_alarm_trigger(hass)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
future = dt_util.utcnow() + timedelta(seconds=2)
with patch(
@ -1335,7 +1335,7 @@ async def test_trigger_with_specific_pending(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_TRIGGERED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_TRIGGERED
future = dt_util.utcnow() + timedelta(seconds=5)
with patch(
@ -1345,7 +1345,7 @@ async def test_trigger_with_specific_pending(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_arm_away_after_disabled_disarmed(hass, legacy_patchable_time, mqtt_mock):
@ -1372,23 +1372,23 @@ async def test_arm_away_after_disabled_disarmed(hass, legacy_patchable_time, mqt
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_away(hass, CODE)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_PENDING == state.state
assert STATE_ALARM_DISARMED == state.attributes["pre_pending_state"]
assert STATE_ALARM_ARMED_AWAY == state.attributes["post_pending_state"]
assert state.state == STATE_ALARM_PENDING
assert state.attributes["pre_pending_state"] == STATE_ALARM_DISARMED
assert state.attributes["post_pending_state"] == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_PENDING == state.state
assert STATE_ALARM_DISARMED == state.attributes["pre_pending_state"]
assert STATE_ALARM_ARMED_AWAY == state.attributes["post_pending_state"]
assert state.state == STATE_ALARM_PENDING
assert state.attributes["pre_pending_state"] == STATE_ALARM_DISARMED
assert state.attributes["post_pending_state"] == STATE_ALARM_ARMED_AWAY
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
@ -1399,15 +1399,15 @@ async def test_arm_away_after_disabled_disarmed(hass, legacy_patchable_time, mqt
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_ARMED_AWAY == state.state
assert state.state == STATE_ALARM_ARMED_AWAY
await common.async_alarm_trigger(hass, entity_id=entity_id)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_PENDING == state.state
assert STATE_ALARM_ARMED_AWAY == state.attributes["pre_pending_state"]
assert STATE_ALARM_TRIGGERED == state.attributes["post_pending_state"]
assert state.state == STATE_ALARM_PENDING
assert state.attributes["pre_pending_state"] == STATE_ALARM_ARMED_AWAY
assert state.attributes["post_pending_state"] == STATE_ALARM_TRIGGERED
future += timedelta(seconds=1)
with patch(
@ -1418,7 +1418,7 @@ async def test_arm_away_after_disabled_disarmed(hass, legacy_patchable_time, mqt
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_TRIGGERED == state.state
assert state.state == STATE_ALARM_TRIGGERED
async def test_disarm_with_template_code(hass, mqtt_mock):
@ -1442,25 +1442,25 @@ async def test_disarm_with_template_code(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_arm_home(hass, "def")
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_ARMED_HOME == state.state
assert state.state == STATE_ALARM_ARMED_HOME
await common.async_alarm_disarm(hass, "def")
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_ARMED_HOME == state.state
assert state.state == STATE_ALARM_ARMED_HOME
await common.async_alarm_disarm(hass, "abc")
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert STATE_ALARM_DISARMED == state.state
assert state.state == STATE_ALARM_DISARMED
async def test_arm_home_via_command_topic(hass, mqtt_mock):
@ -1483,12 +1483,12 @@ async def test_arm_home_via_command_topic(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
# Fire the arm command via MQTT; ensure state changes to pending
async_fire_mqtt_message(hass, "alarm/command", "ARM_HOME")
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
# Fast-forward a little bit
future = dt_util.utcnow() + timedelta(seconds=1)
@ -1499,7 +1499,7 @@ async def test_arm_home_via_command_topic(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_HOME == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_HOME
async def test_arm_away_via_command_topic(hass, mqtt_mock):
@ -1522,12 +1522,12 @@ async def test_arm_away_via_command_topic(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
# Fire the arm command via MQTT; ensure state changes to pending
async_fire_mqtt_message(hass, "alarm/command", "ARM_AWAY")
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
# Fast-forward a little bit
future = dt_util.utcnow() + timedelta(seconds=1)
@ -1538,7 +1538,7 @@ async def test_arm_away_via_command_topic(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
async def test_arm_night_via_command_topic(hass, mqtt_mock):
@ -1561,12 +1561,12 @@ async def test_arm_night_via_command_topic(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
# Fire the arm command via MQTT; ensure state changes to pending
async_fire_mqtt_message(hass, "alarm/command", "ARM_NIGHT")
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
# Fast-forward a little bit
future = dt_util.utcnow() + timedelta(seconds=1)
@ -1577,7 +1577,7 @@ async def test_arm_night_via_command_topic(hass, mqtt_mock):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_NIGHT == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_NIGHT
async def test_disarm_pending_via_command_topic(hass, mqtt_mock):
@ -1600,18 +1600,18 @@ async def test_disarm_pending_via_command_topic(hass, mqtt_mock):
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
await common.async_alarm_trigger(hass)
await hass.async_block_till_done()
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_PENDING
# Now that we're pending, receive a command to disarm
async_fire_mqtt_message(hass, "alarm/command", "DISARM")
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
assert hass.states.get(entity_id).state == STATE_ALARM_DISARMED
async def test_state_changes_are_published_to_mqtt(hass, mqtt_mock):

View file

@ -94,7 +94,7 @@ async def test_current_fan_mode(hass):
device = (await api.async_fetch_devices())[_SERIAL]
thermostat = MelissaClimate(api, _SERIAL, device)
await thermostat.async_update()
assert SPEED_LOW == thermostat.fan_mode
assert thermostat.fan_mode == SPEED_LOW
thermostat._cur_settings = None
assert thermostat.fan_mode is None
@ -185,7 +185,7 @@ async def test_state(hass):
device = (await api.async_fetch_devices())[_SERIAL]
thermostat = MelissaClimate(api, _SERIAL, device)
await thermostat.async_update()
assert HVAC_MODE_HEAT == thermostat.state
assert thermostat.state == HVAC_MODE_HEAT
thermostat._cur_settings = None
assert thermostat.state is None
@ -197,7 +197,7 @@ async def test_temperature_unit(hass):
api = melissa_mock()
device = (await api.async_fetch_devices())[_SERIAL]
thermostat = MelissaClimate(api, _SERIAL, device)
assert TEMP_CELSIUS == thermostat.temperature_unit
assert thermostat.temperature_unit == TEMP_CELSIUS
async def test_min_temp(hass):
@ -225,7 +225,7 @@ async def test_supported_features(hass):
device = (await api.async_fetch_devices())[_SERIAL]
thermostat = MelissaClimate(api, _SERIAL, device)
features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE
assert features == thermostat.supported_features
assert thermostat.supported_features == features
async def test_set_temperature(hass):
@ -249,7 +249,7 @@ async def test_fan_mode(hass):
await hass.async_block_till_done()
await thermostat.async_set_fan_mode(SPEED_HIGH)
await hass.async_block_till_done()
assert SPEED_HIGH == thermostat.fan_mode
assert thermostat.fan_mode == SPEED_HIGH
async def test_set_operation_mode(hass):
@ -262,7 +262,7 @@ async def test_set_operation_mode(hass):
await hass.async_block_till_done()
await thermostat.async_set_hvac_mode(HVAC_MODE_COOL)
await hass.async_block_till_done()
assert HVAC_MODE_COOL == thermostat.hvac_mode
assert thermostat.hvac_mode == HVAC_MODE_COOL
async def test_send(hass):
@ -275,7 +275,7 @@ async def test_send(hass):
await hass.async_block_till_done()
await thermostat.async_send({"fan": api.FAN_MEDIUM})
await hass.async_block_till_done()
assert SPEED_MEDIUM == thermostat.fan_mode
assert thermostat.fan_mode == SPEED_MEDIUM
api.async_send.return_value = AsyncMock(return_value=False)
thermostat._cur_settings = None
await thermostat.async_send({"fan": api.FAN_LOW})
@ -294,8 +294,8 @@ async def test_update(hass):
device = (await api.async_fetch_devices())[_SERIAL]
thermostat = MelissaClimate(api, _SERIAL, device)
await thermostat.async_update()
assert SPEED_LOW == thermostat.fan_mode
assert HVAC_MODE_HEAT == thermostat.state
assert thermostat.fan_mode == SPEED_LOW
assert thermostat.state == HVAC_MODE_HEAT
api.async_status = AsyncMock(side_effect=KeyError("boom"))
await thermostat.async_update()
mocked_warning.assert_called_once_with(
@ -309,10 +309,10 @@ async def test_melissa_op_to_hass(hass):
api = melissa_mock()
device = (await api.async_fetch_devices())[_SERIAL]
thermostat = MelissaClimate(api, _SERIAL, device)
assert HVAC_MODE_FAN_ONLY == thermostat.melissa_op_to_hass(1)
assert HVAC_MODE_HEAT == thermostat.melissa_op_to_hass(2)
assert HVAC_MODE_COOL == thermostat.melissa_op_to_hass(3)
assert HVAC_MODE_DRY == thermostat.melissa_op_to_hass(4)
assert thermostat.melissa_op_to_hass(1) == HVAC_MODE_FAN_ONLY
assert thermostat.melissa_op_to_hass(2) == HVAC_MODE_HEAT
assert thermostat.melissa_op_to_hass(3) == HVAC_MODE_COOL
assert thermostat.melissa_op_to_hass(4) == HVAC_MODE_DRY
assert thermostat.melissa_op_to_hass(5) is None
@ -322,10 +322,10 @@ async def test_melissa_fan_to_hass(hass):
api = melissa_mock()
device = (await api.async_fetch_devices())[_SERIAL]
thermostat = MelissaClimate(api, _SERIAL, device)
assert "auto" == thermostat.melissa_fan_to_hass(0)
assert SPEED_LOW == thermostat.melissa_fan_to_hass(1)
assert SPEED_MEDIUM == thermostat.melissa_fan_to_hass(2)
assert SPEED_HIGH == thermostat.melissa_fan_to_hass(3)
assert thermostat.melissa_fan_to_hass(0) == "auto"
assert thermostat.melissa_fan_to_hass(1) == SPEED_LOW
assert thermostat.melissa_fan_to_hass(2) == SPEED_MEDIUM
assert thermostat.melissa_fan_to_hass(3) == SPEED_HIGH
assert thermostat.melissa_fan_to_hass(4) is None

View file

@ -125,9 +125,9 @@ async def test_data_will_be_saved(mock_device_tracker_conf, hass, meraki_client)
state_name = hass.states.get(
"{}.{}".format("device_tracker", "00_26_ab_b8_a9_a4")
).state
assert "home" == state_name
assert state_name == "home"
state_name = hass.states.get(
"{}.{}".format("device_tracker", "00_26_ab_b8_a9_a5")
).state
assert "home" == state_name
assert state_name == "home"

View file

@ -132,7 +132,7 @@ async def test_name(port, sensor):
async def test_uom_temp(port, sensor):
"""Test the UOM temperature."""
port.tag = "temperature"
assert TEMP_CELSIUS == sensor.unit_of_measurement
assert sensor.unit_of_measurement == TEMP_CELSIUS
async def test_uom_power(port, sensor):

View file

@ -50,10 +50,10 @@ async def test_min_sensor(hass):
assert str(float(MIN_VALUE)) == state.state
assert entity_ids[2] == state.attributes.get("min_entity_id")
assert MAX_VALUE == state.attributes.get("max_value")
assert state.attributes.get("max_value") == MAX_VALUE
assert entity_ids[1] == state.attributes.get("max_entity_id")
assert MEAN == state.attributes.get("mean")
assert MEDIAN == state.attributes.get("median")
assert state.attributes.get("mean") == MEAN
assert state.attributes.get("median") == MEDIAN
async def test_max_sensor(hass):
@ -80,10 +80,10 @@ async def test_max_sensor(hass):
assert str(float(MAX_VALUE)) == state.state
assert entity_ids[2] == state.attributes.get("min_entity_id")
assert MIN_VALUE == state.attributes.get("min_value")
assert state.attributes.get("min_value") == MIN_VALUE
assert entity_ids[1] == state.attributes.get("max_entity_id")
assert MEAN == state.attributes.get("mean")
assert MEDIAN == state.attributes.get("median")
assert state.attributes.get("mean") == MEAN
assert state.attributes.get("median") == MEDIAN
async def test_mean_sensor(hass):
@ -109,11 +109,11 @@ async def test_mean_sensor(hass):
state = hass.states.get("sensor.test_mean")
assert str(float(MEAN)) == state.state
assert MIN_VALUE == state.attributes.get("min_value")
assert state.attributes.get("min_value") == MIN_VALUE
assert entity_ids[2] == state.attributes.get("min_entity_id")
assert MAX_VALUE == state.attributes.get("max_value")
assert state.attributes.get("max_value") == MAX_VALUE
assert entity_ids[1] == state.attributes.get("max_entity_id")
assert MEDIAN == state.attributes.get("median")
assert state.attributes.get("median") == MEDIAN
async def test_mean_1_digit_sensor(hass):
@ -140,11 +140,11 @@ async def test_mean_1_digit_sensor(hass):
state = hass.states.get("sensor.test_mean")
assert str(float(MEAN_1_DIGIT)) == state.state
assert MIN_VALUE == state.attributes.get("min_value")
assert state.attributes.get("min_value") == MIN_VALUE
assert entity_ids[2] == state.attributes.get("min_entity_id")
assert MAX_VALUE == state.attributes.get("max_value")
assert state.attributes.get("max_value") == MAX_VALUE
assert entity_ids[1] == state.attributes.get("max_entity_id")
assert MEDIAN == state.attributes.get("median")
assert state.attributes.get("median") == MEDIAN
async def test_mean_4_digit_sensor(hass):
@ -171,11 +171,11 @@ async def test_mean_4_digit_sensor(hass):
state = hass.states.get("sensor.test_mean")
assert str(float(MEAN_4_DIGITS)) == state.state
assert MIN_VALUE == state.attributes.get("min_value")
assert state.attributes.get("min_value") == MIN_VALUE
assert entity_ids[2] == state.attributes.get("min_entity_id")
assert MAX_VALUE == state.attributes.get("max_value")
assert state.attributes.get("max_value") == MAX_VALUE
assert entity_ids[1] == state.attributes.get("max_entity_id")
assert MEDIAN == state.attributes.get("median")
assert state.attributes.get("median") == MEDIAN
async def test_median_sensor(hass):
@ -201,11 +201,11 @@ async def test_median_sensor(hass):
state = hass.states.get("sensor.test_median")
assert str(float(MEDIAN)) == state.state
assert MIN_VALUE == state.attributes.get("min_value")
assert state.attributes.get("min_value") == MIN_VALUE
assert entity_ids[2] == state.attributes.get("min_entity_id")
assert MAX_VALUE == state.attributes.get("max_value")
assert state.attributes.get("max_value") == MAX_VALUE
assert entity_ids[1] == state.attributes.get("max_entity_id")
assert MEAN == state.attributes.get("mean")
assert state.attributes.get("mean") == MEAN
async def test_not_enough_sensor_value(hass):
@ -228,7 +228,7 @@ async def test_not_enough_sensor_value(hass):
await hass.async_block_till_done()
state = hass.states.get("sensor.test_max")
assert STATE_UNKNOWN == state.state
assert state.state == STATE_UNKNOWN
assert state.attributes.get("min_entity_id") is None
assert state.attributes.get("min_value") is None
assert state.attributes.get("max_entity_id") is None
@ -259,7 +259,7 @@ async def test_not_enough_sensor_value(hass):
await hass.async_block_till_done()
state = hass.states.get("sensor.test_max")
assert STATE_UNKNOWN == state.state
assert state.state == STATE_UNKNOWN
assert state.attributes.get("min_entity_id") is None
assert state.attributes.get("min_value") is None
assert state.attributes.get("max_entity_id") is None
@ -299,7 +299,7 @@ async def test_different_unit_of_measurement(hass):
state = hass.states.get("sensor.test")
assert STATE_UNKNOWN == state.state
assert state.state == STATE_UNKNOWN
assert state.attributes.get("unit_of_measurement") == "ERR"
hass.states.async_set(
@ -309,7 +309,7 @@ async def test_different_unit_of_measurement(hass):
state = hass.states.get("sensor.test")
assert STATE_UNKNOWN == state.state
assert state.state == STATE_UNKNOWN
assert state.attributes.get("unit_of_measurement") == "ERR"
@ -336,10 +336,10 @@ async def test_last_sensor(hass):
assert str(float(value)) == state.state
assert entity_id == state.attributes.get("last_entity_id")
assert MIN_VALUE == state.attributes.get("min_value")
assert MAX_VALUE == state.attributes.get("max_value")
assert MEAN == state.attributes.get("mean")
assert MEDIAN == state.attributes.get("median")
assert state.attributes.get("min_value") == MIN_VALUE
assert state.attributes.get("max_value") == MAX_VALUE
assert state.attributes.get("mean") == MEAN
assert state.attributes.get("median") == MEDIAN
async def test_reload(hass):

View file

@ -141,16 +141,16 @@ async def test_minio_listen(hass, caplog, minio_client_event):
while not events:
await asyncio.sleep(0)
assert 1 == len(events)
assert len(events) == 1
event = events[0]
assert DOMAIN == event.event_type
assert "s3:ObjectCreated:Put" == event.data["event_name"]
assert "5jJkTAo.jpg" == event.data["file_name"]
assert "test" == event.data["bucket"]
assert "5jJkTAo.jpg" == event.data["key"]
assert "http://url" == event.data["presigned_url"]
assert 0 == len(event.data["metadata"])
assert event.event_type == DOMAIN
assert event.data["event_name"] == "s3:ObjectCreated:Put"
assert event.data["file_name"] == "5jJkTAo.jpg"
assert event.data["bucket"] == "test"
assert event.data["key"] == "5jJkTAo.jpg"
assert event.data["presigned_url"] == "http://url"
assert len(event.data["metadata"]) == 0
async def test_queue_listener():
@ -183,7 +183,7 @@ async def test_queue_listener():
"metadata": {},
}
assert DOMAIN == call_domain
assert call_domain == DOMAIN
assert json.dumps(expected_event, sort_keys=True) == json.dumps(
call_event, sort_keys=True
)

View file

@ -39,7 +39,7 @@ async def test_setup_adds_proper_devices(hass):
async def test_name(switch_mock):
"""Test the name."""
assert "fake_switch" == switch_mock.name
assert switch_mock.name == "fake_switch"
async def test_turn_on(switch_mock):

View file

@ -47,7 +47,7 @@ async def test_setup(hass):
await hass.async_block_till_done()
moldind = hass.states.get("sensor.mold_indicator")
assert moldind
assert PERCENTAGE == moldind.attributes.get("unit_of_measurement")
assert moldind.attributes.get("unit_of_measurement") == PERCENTAGE
async def test_invalidcalib(hass):

View file

@ -333,7 +333,7 @@ async def test_optimistic_state_change(hass, mqtt_mock):
mqtt_mock.async_publish.assert_called_once_with("command-topic", "CLOSE", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("cover.test")
assert STATE_CLOSED == state.state
assert state.state == STATE_CLOSED
await hass.services.async_call(
cover.DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: "cover.test"}, blocking=True
@ -342,7 +342,7 @@ async def test_optimistic_state_change(hass, mqtt_mock):
mqtt_mock.async_publish.assert_called_once_with("command-topic", "OPEN", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("cover.test")
assert STATE_OPEN == state.state
assert state.state == STATE_OPEN
await hass.services.async_call(
cover.DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: "cover.test"}, blocking=True
@ -393,7 +393,7 @@ async def test_optimistic_state_change_with_position(hass, mqtt_mock):
mqtt_mock.async_publish.assert_called_once_with("command-topic", "CLOSE", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("cover.test")
assert STATE_CLOSED == state.state
assert state.state == STATE_CLOSED
assert state.attributes.get(ATTR_CURRENT_POSITION) == 0
await hass.services.async_call(
@ -403,7 +403,7 @@ async def test_optimistic_state_change_with_position(hass, mqtt_mock):
mqtt_mock.async_publish.assert_called_once_with("command-topic", "OPEN", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get("cover.test")
assert STATE_OPEN == state.state
assert state.state == STATE_OPEN
assert state.attributes.get(ATTR_CURRENT_POSITION) == 100
await hass.services.async_call(

View file

@ -46,7 +46,7 @@ async def test_if_fires_on_topic_match(hass, calls):
async_fire_mqtt_message(hass, "test-topic", '{ "hello": "world" }')
await hass.async_block_till_done()
assert len(calls) == 1
assert 'mqtt - test-topic - { "hello": "world" } - world' == calls[0].data["some"]
assert calls[0].data["some"] == 'mqtt - test-topic - { "hello": "world" } - world'
await hass.services.async_call(
automation.DOMAIN,

View file

@ -138,7 +138,7 @@ async def test_receiving_remote_event_fires_hass_event(hass, mqtt_mock):
async_fire_mqtt_message(hass, sub_topic, payload)
await hass.async_block_till_done()
assert 1 == len(calls)
assert len(calls) == 1
async def test_ignored_event_doesnt_send_over_stream(hass, mqtt_mock):

View file

@ -99,5 +99,5 @@ async def test_sensor_values(hass):
assert await async_setup_component(hass, sensor.DOMAIN, {"sensor": VALID_CONFIG})
await hass.async_block_till_done()
assert "140.0" == hass.states.get("sensor.my_fake_station_e10").state
assert "150.0" == hass.states.get("sensor.my_fake_station_p95").state
assert hass.states.get("sensor.my_fake_station_e10").state == "140.0"
assert hass.states.get("sensor.my_fake_station_p95").state == "150.0"

View file

@ -143,7 +143,7 @@ def test_nx584_zone_sensor_normal():
"""Test for the NX584 zone sensor."""
zone = {"number": 1, "name": "foo", "state": True}
sensor = nx584.NX584ZoneSensor(zone, "motion")
assert "foo" == sensor.name
assert sensor.name == "foo"
assert not sensor.should_poll
assert sensor.is_on
assert sensor.extra_state_attributes["zone_number"] == 1
@ -204,7 +204,7 @@ def test_nx584_watcher_run_with_zone_events():
assert fake_process.call_args == mock.call(fake_events[0])
run()
assert 3 == client.get_events.call_count
assert client.get_events.call_count == 3
@mock.patch("time.sleep")
@ -224,5 +224,5 @@ def test_nx584_watcher_run_retries_failures(mock_sleep):
mock_inner.side_effect = fake_run
with pytest.raises(StopMe):
watcher.run()
assert 3 == mock_inner.call_count
assert mock_inner.call_count == 3
mock_sleep.assert_has_calls([mock.call(10), mock.call(10)])

View file

@ -88,7 +88,7 @@ async def test_initial_states(hass):
)
await hass.async_block_till_done()
state = hass.states.get(f"plant.{plant_name}")
assert 5 == state.attributes[plant.READING_MOISTURE]
assert state.attributes[plant.READING_MOISTURE] == 5
async def test_update_states(hass):
@ -103,8 +103,8 @@ async def test_update_states(hass):
hass.states.async_set(MOISTURE_ENTITY, 5, {ATTR_UNIT_OF_MEASUREMENT: CONDUCTIVITY})
await hass.async_block_till_done()
state = hass.states.get(f"plant.{plant_name}")
assert STATE_PROBLEM == state.state
assert 5 == state.attributes[plant.READING_MOISTURE]
assert state.state == STATE_PROBLEM
assert state.attributes[plant.READING_MOISTURE] == 5
async def test_unavailable_state(hass):
@ -177,9 +177,9 @@ async def test_load_from_db(hass):
await hass.async_block_till_done()
state = hass.states.get(f"plant.{plant_name}")
assert STATE_UNKNOWN == state.state
assert state.state == STATE_UNKNOWN
max_brightness = state.attributes.get(plant.ATTR_MAX_BRIGHTNESS_HISTORY)
assert 30 == max_brightness
assert max_brightness == 30
async def test_brightness_history(hass):
@ -191,17 +191,17 @@ async def test_brightness_history(hass):
hass.states.async_set(BRIGHTNESS_ENTITY, 100, {ATTR_UNIT_OF_MEASUREMENT: LIGHT_LUX})
await hass.async_block_till_done()
state = hass.states.get(f"plant.{plant_name}")
assert STATE_PROBLEM == state.state
assert state.state == STATE_PROBLEM
hass.states.async_set(BRIGHTNESS_ENTITY, 600, {ATTR_UNIT_OF_MEASUREMENT: LIGHT_LUX})
await hass.async_block_till_done()
state = hass.states.get(f"plant.{plant_name}")
assert STATE_OK == state.state
assert state.state == STATE_OK
hass.states.async_set(BRIGHTNESS_ENTITY, 100, {ATTR_UNIT_OF_MEASUREMENT: LIGHT_LUX})
await hass.async_block_till_done()
state = hass.states.get(f"plant.{plant_name}")
assert STATE_OK == state.state
assert state.state == STATE_OK
def test_daily_history_no_data(hass):
@ -217,7 +217,7 @@ def test_daily_history_one_day(hass):
for i in range(len(values)):
dh.add_measurement(values[i])
max_value = max(values[0 : i + 1])
assert 1 == len(dh._days)
assert len(dh._days) == 1
assert dh.max == max_value

View file

@ -224,7 +224,7 @@ async def test_minimal_config(hass, mock_client):
assert await async_setup_component(hass, prometheus.DOMAIN, config)
await hass.async_block_till_done()
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[0][0][0]
assert hass.bus.listen.call_args_list[0][0][0] == EVENT_STATE_CHANGED
@pytest.mark.usefixtures("mock_bus")
@ -251,7 +251,7 @@ async def test_full_config(hass, mock_client):
assert await async_setup_component(hass, prometheus.DOMAIN, config)
await hass.async_block_till_done()
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[0][0][0]
assert hass.bus.listen.call_args_list[0][0][0] == EVENT_STATE_CHANGED
def make_event(entity_id):

View file

@ -211,11 +211,11 @@ async def test_diskspace_no_paths(hass):
entity = hass.states.get("sensor.radarr_disk_space")
assert entity is not None
assert "263.10" == entity.state
assert "mdi:harddisk" == entity.attributes["icon"]
assert DATA_GIGABYTES == entity.attributes["unit_of_measurement"]
assert "Radarr Disk Space" == entity.attributes["friendly_name"]
assert "263.10/465.42GB (56.53%)" == entity.attributes["/data"]
assert entity.state == "263.10"
assert entity.attributes["icon"] == "mdi:harddisk"
assert entity.attributes["unit_of_measurement"] == DATA_GIGABYTES
assert entity.attributes["friendly_name"] == "Radarr Disk Space"
assert entity.attributes["/data"] == "263.10/465.42GB (56.53%)"
async def test_diskspace_paths(hass):
@ -240,11 +240,11 @@ async def test_diskspace_paths(hass):
entity = hass.states.get("sensor.radarr_disk_space")
assert entity is not None
assert "263.10" == entity.state
assert "mdi:harddisk" == entity.attributes["icon"]
assert DATA_GIGABYTES == entity.attributes["unit_of_measurement"]
assert "Radarr Disk Space" == entity.attributes["friendly_name"]
assert "263.10/465.42GB (56.53%)" == entity.attributes["/data"]
assert entity.state == "263.10"
assert entity.attributes["icon"] == "mdi:harddisk"
assert entity.attributes["unit_of_measurement"] == DATA_GIGABYTES
assert entity.attributes["friendly_name"] == "Radarr Disk Space"
assert entity.attributes["/data"] == "263.10/465.42GB (56.53%)"
async def test_commands(hass):
@ -269,11 +269,11 @@ async def test_commands(hass):
entity = hass.states.get("sensor.radarr_commands")
assert entity is not None
assert 1 == int(entity.state)
assert "mdi:code-braces" == entity.attributes["icon"]
assert "Commands" == entity.attributes["unit_of_measurement"]
assert "Radarr Commands" == entity.attributes["friendly_name"]
assert "pending" == entity.attributes["RescanMovie"]
assert int(entity.state) == 1
assert entity.attributes["icon"] == "mdi:code-braces"
assert entity.attributes["unit_of_measurement"] == "Commands"
assert entity.attributes["friendly_name"] == "Radarr Commands"
assert entity.attributes["RescanMovie"] == "pending"
async def test_movies(hass):
@ -298,11 +298,11 @@ async def test_movies(hass):
entity = hass.states.get("sensor.radarr_movies")
assert entity is not None
assert 1 == int(entity.state)
assert "mdi:television" == entity.attributes["icon"]
assert "Movies" == entity.attributes["unit_of_measurement"]
assert "Radarr Movies" == entity.attributes["friendly_name"]
assert "false" == entity.attributes["Assassin's Creed (2016)"]
assert int(entity.state) == 1
assert entity.attributes["icon"] == "mdi:television"
assert entity.attributes["unit_of_measurement"] == "Movies"
assert entity.attributes["friendly_name"] == "Radarr Movies"
assert entity.attributes["Assassin's Creed (2016)"] == "false"
async def test_upcoming_multiple_days(hass):
@ -327,11 +327,11 @@ async def test_upcoming_multiple_days(hass):
entity = hass.states.get("sensor.radarr_upcoming")
assert entity is not None
assert 1 == int(entity.state)
assert "mdi:television" == entity.attributes["icon"]
assert "Movies" == entity.attributes["unit_of_measurement"]
assert "Radarr Upcoming" == entity.attributes["friendly_name"]
assert "2017-01-27T00:00:00Z" == entity.attributes["Resident Evil (2017)"]
assert int(entity.state) == 1
assert entity.attributes["icon"] == "mdi:television"
assert entity.attributes["unit_of_measurement"] == "Movies"
assert entity.attributes["friendly_name"] == "Radarr Upcoming"
assert entity.attributes["Resident Evil (2017)"] == "2017-01-27T00:00:00Z"
@pytest.mark.skip
@ -357,11 +357,11 @@ async def test_upcoming_today(hass):
assert await async_setup_component(hass, "sensor", config)
await hass.async_block_till_done()
entity = hass.states.get("sensor.radarr_upcoming")
assert 1 == int(entity.state)
assert "mdi:television" == entity.attributes["icon"]
assert "Movies" == entity.attributes["unit_of_measurement"]
assert "Radarr Upcoming" == entity.attributes["friendly_name"]
assert "2017-01-27T00:00:00Z" == entity.attributes["Resident Evil (2017)"]
assert int(entity.state) == 1
assert entity.attributes["icon"] == "mdi:television"
assert entity.attributes["unit_of_measurement"] == "Movies"
assert entity.attributes["friendly_name"] == "Radarr Upcoming"
assert entity.attributes["Resident Evil (2017)"] == "2017-01-27T00:00:00Z"
async def test_system_status(hass):
@ -384,10 +384,10 @@ async def test_system_status(hass):
await hass.async_block_till_done()
entity = hass.states.get("sensor.radarr_status")
assert entity is not None
assert "0.2.0.210" == entity.state
assert "mdi:information" == entity.attributes["icon"]
assert "Radarr Status" == entity.attributes["friendly_name"]
assert "4.8.13.1" == entity.attributes["osVersion"]
assert entity.state == "0.2.0.210"
assert entity.attributes["icon"] == "mdi:information"
assert entity.attributes["friendly_name"] == "Radarr Status"
assert entity.attributes["osVersion"] == "4.8.13.1"
async def test_ssl(hass):
@ -411,11 +411,11 @@ async def test_ssl(hass):
await hass.async_block_till_done()
entity = hass.states.get("sensor.radarr_upcoming")
assert entity is not None
assert 1 == int(entity.state)
assert "mdi:television" == entity.attributes["icon"]
assert "Movies" == entity.attributes["unit_of_measurement"]
assert "Radarr Upcoming" == entity.attributes["friendly_name"]
assert "2017-01-27T00:00:00Z" == entity.attributes["Resident Evil (2017)"]
assert int(entity.state) == 1
assert entity.attributes["icon"] == "mdi:television"
assert entity.attributes["unit_of_measurement"] == "Movies"
assert entity.attributes["friendly_name"] == "Radarr Upcoming"
assert entity.attributes["Resident Evil (2017)"] == "2017-01-27T00:00:00Z"
async def test_exception_handling(hass):
@ -438,4 +438,4 @@ async def test_exception_handling(hass):
await hass.async_block_till_done()
entity = hass.states.get("sensor.radarr_upcoming")
assert entity is not None
assert "unavailable" == entity.state
assert entity.state == "unavailable"

View file

@ -48,7 +48,7 @@ async def test_turn_on(hass):
assert len(turn_on_calls) == 1
call = turn_on_calls[-1]
assert DOMAIN == call.domain
assert call.domain == DOMAIN
async def test_turn_off(hass):

View file

@ -179,7 +179,7 @@ def _setup_test_switch(hass):
def test_name(hass):
"""Test the name."""
switch, body_on, body_off = _setup_test_switch(hass)
assert NAME == switch.name
assert switch.name == NAME
def test_is_on_before_update(hass):

View file

@ -60,8 +60,8 @@ async def test_config_yaml_alias_anchor(hass, entities):
assert light.is_on(hass, light_1.entity_id)
assert light.is_on(hass, light_2.entity_id)
assert 100 == light_1.last_call("turn_on")[1].get("brightness")
assert 100 == light_2.last_call("turn_on")[1].get("brightness")
assert light_1.last_call("turn_on")[1].get("brightness") == 100
assert light_2.last_call("turn_on")[1].get("brightness") == 100
async def test_config_yaml_bool(hass, entities):
@ -88,7 +88,7 @@ async def test_config_yaml_bool(hass, entities):
assert light.is_on(hass, light_1.entity_id)
assert light.is_on(hass, light_2.entity_id)
assert 100 == light_2.last_call("turn_on")[1].get("brightness")
assert light_2.last_call("turn_on")[1].get("brightness") == 100
async def test_activate_scene(hass, entities):

View file

@ -173,7 +173,7 @@ async def test_turn_on_off_toggle(hass, toggle):
assert not script.is_on(hass, ENTITY_ID)
assert was_on
assert 1 == event_mock.call_count
assert event_mock.call_count == 1
invalid_configs = [
@ -190,7 +190,7 @@ async def test_setup_with_invalid_configs(hass, value):
hass, "script", {"script": value}
), f"Script loaded with wrong config {value}"
assert 0 == len(hass.states.async_entity_ids("script"))
assert len(hass.states.async_entity_ids("script")) == 0
@pytest.mark.parametrize("running", ["no", "same", "different"])
@ -587,7 +587,7 @@ async def test_concurrent_script(hass, concurrently):
await asyncio.wait_for(service_called.wait(), 1)
service_called.clear()
assert "script2a" == service_values[-1]
assert service_values[-1] == "script2a"
assert script.is_on(hass, "script.script1")
assert script.is_on(hass, "script.script2")
@ -596,13 +596,13 @@ async def test_concurrent_script(hass, concurrently):
await asyncio.wait_for(service_called.wait(), 1)
service_called.clear()
assert "script2b" == service_values[-1]
assert service_values[-1] == "script2b"
hass.states.async_set("input_boolean.test1", "on")
await asyncio.wait_for(service_called.wait(), 1)
service_called.clear()
assert "script1" == service_values[-1]
assert service_values[-1] == "script1"
assert concurrently == script.is_on(hass, "script.script2")
if concurrently:
@ -610,7 +610,7 @@ async def test_concurrent_script(hass, concurrently):
await asyncio.wait_for(service_called.wait(), 1)
service_called.clear()
assert "script2b" == service_values[-1]
assert service_values[-1] == "script2b"
await hass.async_block_till_done()

View file

@ -79,7 +79,7 @@ async def test_template_render_no_template(mock_call, hass):
cmd = mock_call.mock_calls[0][1][0]
assert mock_call.call_count == 1
assert "ls /bin" == cmd
assert cmd == "ls /bin"
@patch(

View file

@ -18,15 +18,15 @@ async def test_sensor_setup(hass, requests_mock):
device_mock = MagicMock()
sleepiq.setup_platform(hass, CONFIG, device_mock, MagicMock())
devices = device_mock.call_args[0][0]
assert 2 == len(devices)
assert len(devices) == 2
left_side = devices[1]
assert "SleepNumber ILE Test1 Is In Bed" == left_side.name
assert "on" == left_side.state
assert left_side.name == "SleepNumber ILE Test1 Is In Bed"
assert left_side.state == "on"
right_side = devices[0]
assert "SleepNumber ILE Test2 Is In Bed" == right_side.name
assert "off" == right_side.state
assert right_side.name == "SleepNumber ILE Test2 Is In Bed"
assert right_side.state == "off"
async def test_setup_single(hass, requests_mock):
@ -38,8 +38,8 @@ async def test_setup_single(hass, requests_mock):
device_mock = MagicMock()
sleepiq.setup_platform(hass, CONFIG, device_mock, MagicMock())
devices = device_mock.call_args[0][0]
assert 1 == len(devices)
assert len(devices) == 1
right_side = devices[0]
assert "SleepNumber ILE Test1 Is In Bed" == right_side.name
assert "on" == right_side.state
assert right_side.name == "SleepNumber ILE Test1 Is In Bed"
assert right_side.state == "on"

View file

@ -18,15 +18,15 @@ async def test_setup(hass, requests_mock):
device_mock = MagicMock()
sleepiq.setup_platform(hass, CONFIG, device_mock, MagicMock())
devices = device_mock.call_args[0][0]
assert 2 == len(devices)
assert len(devices) == 2
left_side = devices[1]
assert "SleepNumber ILE Test1 SleepNumber" == left_side.name
assert 40 == left_side.state
assert left_side.name == "SleepNumber ILE Test1 SleepNumber"
assert left_side.state == 40
right_side = devices[0]
assert "SleepNumber ILE Test2 SleepNumber" == right_side.name
assert 80 == right_side.state
assert right_side.name == "SleepNumber ILE Test2 SleepNumber"
assert right_side.state == 80
async def test_setup_sigle(hass, requests_mock):
@ -38,8 +38,8 @@ async def test_setup_sigle(hass, requests_mock):
device_mock = MagicMock()
sleepiq.setup_platform(hass, CONFIG, device_mock, MagicMock())
devices = device_mock.call_args[0][0]
assert 1 == len(devices)
assert len(devices) == 1
right_side = devices[0]
assert "SleepNumber ILE Test1 SleepNumber" == right_side.name
assert 40 == right_side.state
assert right_side.name == "SleepNumber ILE Test1 SleepNumber"
assert right_side.state == 40

View file

@ -115,7 +115,7 @@ class TestStatisticsSensor(unittest.TestCase):
assert self.mean == state.attributes.get("mean")
assert self.count == state.attributes.get("count")
assert self.total == state.attributes.get("total")
assert TEMP_CELSIUS == state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_CELSIUS
assert self.change == state.attributes.get("change")
assert self.average_change == state.attributes.get("average_change")
@ -146,8 +146,8 @@ class TestStatisticsSensor(unittest.TestCase):
state = self.hass.states.get("sensor.test")
assert 3.8 == state.attributes.get("min_value")
assert 14 == state.attributes.get("max_value")
assert state.attributes.get("min_value") == 3.8
assert state.attributes.get("max_value") == 14
def test_sampling_size_1(self):
"""Test validity of stats requiring only one sample."""
@ -182,12 +182,12 @@ class TestStatisticsSensor(unittest.TestCase):
assert self.values[-1] == state.attributes.get("mean")
assert self.values[-1] == state.attributes.get("median")
assert self.values[-1] == state.attributes.get("total")
assert 0 == state.attributes.get("change")
assert 0 == state.attributes.get("average_change")
assert state.attributes.get("change") == 0
assert state.attributes.get("average_change") == 0
# require at least two data points
assert STATE_UNKNOWN == state.attributes.get("variance")
assert STATE_UNKNOWN == state.attributes.get("standard_deviation")
assert state.attributes.get("variance") == STATE_UNKNOWN
assert state.attributes.get("standard_deviation") == STATE_UNKNOWN
def test_max_age(self):
"""Test value deprecation."""
@ -231,8 +231,8 @@ class TestStatisticsSensor(unittest.TestCase):
state = self.hass.states.get("sensor.test")
assert 6 == state.attributes.get("min_value")
assert 14 == state.attributes.get("max_value")
assert state.attributes.get("min_value") == 6
assert state.attributes.get("max_value") == 14
def test_max_age_without_sensor_change(self):
"""Test value deprecation."""
@ -276,8 +276,8 @@ class TestStatisticsSensor(unittest.TestCase):
state = self.hass.states.get("sensor.test")
assert 3.8 == state.attributes.get("min_value")
assert 15.2 == state.attributes.get("max_value")
assert state.attributes.get("min_value") == 3.8
assert state.attributes.get("max_value") == 15.2
# wait for 3 minutes (max_age).
mock_data["return_time"] += timedelta(minutes=3)

View file

@ -39,7 +39,7 @@ async def test_statsd_setup_full(hass):
assert mock_init.call_args == mock.call(host="host", port=123, prefix="foo")
assert hass.bus.listen.called
assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[0][0][0]
assert hass.bus.listen.call_args_list[0][0][0] == EVENT_STATE_CHANGED
async def test_statsd_setup_defaults(hass):

View file

@ -395,7 +395,7 @@ async def test_if_fires_on_change_with_template_advanced(hass, calls):
await hass.async_block_till_done()
assert len(calls) == 1
assert calls[0].context.parent_id == context.id
assert "template - test.entity - hello - world - None" == calls[0].data["some"]
assert calls[0].data["some"] == "template - test.entity - hello - world - None"
async def test_if_fires_on_no_change_with_template_advanced(hass, calls):
@ -657,7 +657,7 @@ async def test_if_fires_on_change_with_for_advanced(hass, calls):
await hass.async_block_till_done()
assert len(calls) == 1
assert calls[0].context.parent_id == context.id
assert "template - test.entity - hello - world - 0:00:05" == calls[0].data["some"]
assert calls[0].data["some"] == "template - test.entity - hello - world - 0:00:05"
async def test_if_fires_on_change_with_for_0(hass, calls):

View file

@ -24,12 +24,12 @@ async def test_sensor_upper(hass):
state = hass.states.get("binary_sensor.threshold")
assert "sensor.test_monitored" == state.attributes.get("entity_id")
assert 16 == state.attributes.get("sensor_value")
assert "above" == state.attributes.get("position")
assert float(config["binary_sensor"]["upper"]) == state.attributes.get("upper")
assert 0.0 == state.attributes.get("hysteresis")
assert "upper" == state.attributes.get("type")
assert state.attributes.get("entity_id") == "sensor.test_monitored"
assert state.attributes.get("sensor_value") == 16
assert state.attributes.get("position") == "above"
assert state.attributes.get("upper") == float(config["binary_sensor"]["upper"])
assert state.attributes.get("hysteresis") == 0.0
assert state.attributes.get("type") == "upper"
assert state.state == "on"
@ -66,10 +66,10 @@ async def test_sensor_lower(hass):
state = hass.states.get("binary_sensor.threshold")
assert "above" == state.attributes.get("position")
assert float(config["binary_sensor"]["lower"]) == state.attributes.get("lower")
assert 0.0 == state.attributes.get("hysteresis")
assert "lower" == state.attributes.get("type")
assert state.attributes.get("position") == "above"
assert state.attributes.get("lower") == float(config["binary_sensor"]["lower"])
assert state.attributes.get("hysteresis") == 0.0
assert state.attributes.get("type") == "lower"
assert state.state == "off"
@ -100,10 +100,10 @@ async def test_sensor_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "above" == state.attributes.get("position")
assert float(config["binary_sensor"]["upper"]) == state.attributes.get("upper")
assert 2.5 == state.attributes.get("hysteresis")
assert "upper" == state.attributes.get("type")
assert state.attributes.get("position") == "above"
assert state.attributes.get("upper") == float(config["binary_sensor"]["upper"])
assert state.attributes.get("hysteresis") == 2.5
assert state.attributes.get("type") == "upper"
assert state.state == "on"
@ -158,12 +158,12 @@ async def test_sensor_in_range_no_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert state.attributes.get("entity_id") == "sensor.test_monitored"
assert 16 == state.attributes.get("sensor_value")
assert "in_range" == state.attributes.get("position")
assert float(config["binary_sensor"]["lower"]) == state.attributes.get("lower")
assert float(config["binary_sensor"]["upper"]) == state.attributes.get("upper")
assert 0.0 == state.attributes.get("hysteresis")
assert "range" == state.attributes.get("type")
assert state.attributes.get("sensor_value") == 16
assert state.attributes.get("position") == "in_range"
assert state.attributes.get("lower") == float(config["binary_sensor"]["lower"])
assert state.attributes.get("upper") == float(config["binary_sensor"]["upper"])
assert state.attributes.get("hysteresis") == 0.0
assert state.attributes.get("type") == "range"
assert state.state == "on"
@ -172,7 +172,7 @@ async def test_sensor_in_range_no_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "below" == state.attributes.get("position")
assert state.attributes.get("position") == "below"
assert state.state == "off"
hass.states.async_set("sensor.test_monitored", 21)
@ -180,7 +180,7 @@ async def test_sensor_in_range_no_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "above" == state.attributes.get("position")
assert state.attributes.get("position") == "above"
assert state.state == "off"
@ -206,15 +206,15 @@ async def test_sensor_in_range_with_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "sensor.test_monitored" == state.attributes.get("entity_id")
assert 16 == state.attributes.get("sensor_value")
assert "in_range" == state.attributes.get("position")
assert float(config["binary_sensor"]["lower"]) == state.attributes.get("lower")
assert float(config["binary_sensor"]["upper"]) == state.attributes.get("upper")
assert float(config["binary_sensor"]["hysteresis"]) == state.attributes.get(
"hysteresis"
assert state.attributes.get("entity_id") == "sensor.test_monitored"
assert state.attributes.get("sensor_value") == 16
assert state.attributes.get("position") == "in_range"
assert state.attributes.get("lower") == float(config["binary_sensor"]["lower"])
assert state.attributes.get("upper") == float(config["binary_sensor"]["upper"])
assert state.attributes.get("hysteresis") == float(
config["binary_sensor"]["hysteresis"]
)
assert "range" == state.attributes.get("type")
assert state.attributes.get("type") == "range"
assert state.state == "on"
@ -223,7 +223,7 @@ async def test_sensor_in_range_with_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "in_range" == state.attributes.get("position")
assert state.attributes.get("position") == "in_range"
assert state.state == "on"
hass.states.async_set("sensor.test_monitored", 7)
@ -231,7 +231,7 @@ async def test_sensor_in_range_with_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "below" == state.attributes.get("position")
assert state.attributes.get("position") == "below"
assert state.state == "off"
hass.states.async_set("sensor.test_monitored", 12)
@ -239,7 +239,7 @@ async def test_sensor_in_range_with_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "below" == state.attributes.get("position")
assert state.attributes.get("position") == "below"
assert state.state == "off"
hass.states.async_set("sensor.test_monitored", 13)
@ -247,7 +247,7 @@ async def test_sensor_in_range_with_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "in_range" == state.attributes.get("position")
assert state.attributes.get("position") == "in_range"
assert state.state == "on"
hass.states.async_set("sensor.test_monitored", 22)
@ -255,7 +255,7 @@ async def test_sensor_in_range_with_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "in_range" == state.attributes.get("position")
assert state.attributes.get("position") == "in_range"
assert state.state == "on"
hass.states.async_set("sensor.test_monitored", 23)
@ -263,7 +263,7 @@ async def test_sensor_in_range_with_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "above" == state.attributes.get("position")
assert state.attributes.get("position") == "above"
assert state.state == "off"
hass.states.async_set("sensor.test_monitored", 18)
@ -271,7 +271,7 @@ async def test_sensor_in_range_with_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "above" == state.attributes.get("position")
assert state.attributes.get("position") == "above"
assert state.state == "off"
hass.states.async_set("sensor.test_monitored", 17)
@ -279,7 +279,7 @@ async def test_sensor_in_range_with_hysteresis(hass):
state = hass.states.get("binary_sensor.threshold")
assert "in_range" == state.attributes.get("position")
assert state.attributes.get("position") == "in_range"
assert state.state == "on"
@ -304,13 +304,13 @@ async def test_sensor_in_range_unknown_state(hass):
state = hass.states.get("binary_sensor.threshold")
assert "sensor.test_monitored" == state.attributes.get("entity_id")
assert 16 == state.attributes.get("sensor_value")
assert "in_range" == state.attributes.get("position")
assert float(config["binary_sensor"]["lower"]) == state.attributes.get("lower")
assert float(config["binary_sensor"]["upper"]) == state.attributes.get("upper")
assert 0.0 == state.attributes.get("hysteresis")
assert "range" == state.attributes.get("type")
assert state.attributes.get("entity_id") == "sensor.test_monitored"
assert state.attributes.get("sensor_value") == 16
assert state.attributes.get("position") == "in_range"
assert state.attributes.get("lower") == float(config["binary_sensor"]["lower"])
assert state.attributes.get("upper") == float(config["binary_sensor"]["upper"])
assert state.attributes.get("hysteresis") == 0.0
assert state.attributes.get("type") == "range"
assert state.state == "on"
@ -319,7 +319,7 @@ async def test_sensor_in_range_unknown_state(hass):
state = hass.states.get("binary_sensor.threshold")
assert "unknown" == state.attributes.get("position")
assert state.attributes.get("position") == "unknown"
assert state.state == "off"
@ -341,8 +341,8 @@ async def test_sensor_lower_zero_threshold(hass):
state = hass.states.get("binary_sensor.threshold")
assert "lower" == state.attributes.get("type")
assert float(config["binary_sensor"]["lower"]) == state.attributes.get("lower")
assert state.attributes.get("type") == "lower"
assert state.attributes.get("lower") == float(config["binary_sensor"]["lower"])
assert state.state == "off"
@ -372,8 +372,8 @@ async def test_sensor_upper_zero_threshold(hass):
state = hass.states.get("binary_sensor.threshold")
assert "upper" == state.attributes.get("type")
assert float(config["binary_sensor"]["upper"]) == state.attributes.get("upper")
assert state.attributes.get("type") == "upper"
assert state.attributes.get("upper") == float(config["binary_sensor"]["upper"])
assert state.state == "off"

View file

@ -120,16 +120,16 @@ async def test_config_options(hass):
assert state_2 is not None
assert state_3 is not None
assert STATUS_IDLE == state_1.state
assert state_1.state == STATUS_IDLE
assert ATTR_ICON not in state_1.attributes
assert ATTR_FRIENDLY_NAME not in state_1.attributes
assert STATUS_IDLE == state_2.state
assert "Hello World" == state_2.attributes.get(ATTR_FRIENDLY_NAME)
assert "mdi:work" == state_2.attributes.get(ATTR_ICON)
assert "0:00:10" == state_2.attributes.get(ATTR_DURATION)
assert state_2.state == STATUS_IDLE
assert state_2.attributes.get(ATTR_FRIENDLY_NAME) == "Hello World"
assert state_2.attributes.get(ATTR_ICON) == "mdi:work"
assert state_2.attributes.get(ATTR_DURATION) == "0:00:10"
assert STATUS_IDLE == state_3.state
assert state_3.state == STATUS_IDLE
assert str(cv.time_period(DEFAULT_DURATION)) == state_3.attributes.get(
CONF_DURATION
)
@ -280,14 +280,14 @@ async def test_config_reload(hass, hass_admin_user, hass_read_only_user):
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_2") is not None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_3") is None
assert STATUS_IDLE == state_1.state
assert state_1.state == STATUS_IDLE
assert ATTR_ICON not in state_1.attributes
assert ATTR_FRIENDLY_NAME not in state_1.attributes
assert STATUS_IDLE == state_2.state
assert "Hello World" == state_2.attributes.get(ATTR_FRIENDLY_NAME)
assert "mdi:work" == state_2.attributes.get(ATTR_ICON)
assert "0:00:10" == state_2.attributes.get(ATTR_DURATION)
assert state_2.state == STATUS_IDLE
assert state_2.attributes.get(ATTR_FRIENDLY_NAME) == "Hello World"
assert state_2.attributes.get(ATTR_ICON) == "mdi:work"
assert state_2.attributes.get(ATTR_DURATION) == "0:00:10"
with patch(
"homeassistant.config.load_yaml_config_file",
@ -331,12 +331,12 @@ async def test_config_reload(hass, hass_admin_user, hass_read_only_user):
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_2") is not None
assert ent_reg.async_get_entity_id(DOMAIN, DOMAIN, "test_3") is not None
assert STATUS_IDLE == state_2.state
assert "Hello World reloaded" == state_2.attributes.get(ATTR_FRIENDLY_NAME)
assert "mdi:work-reloaded" == state_2.attributes.get(ATTR_ICON)
assert "0:00:20" == state_2.attributes.get(ATTR_DURATION)
assert state_2.state == STATUS_IDLE
assert state_2.attributes.get(ATTR_FRIENDLY_NAME) == "Hello World reloaded"
assert state_2.attributes.get(ATTR_ICON) == "mdi:work-reloaded"
assert state_2.attributes.get(ATTR_DURATION) == "0:00:20"
assert STATUS_IDLE == state_3.state
assert state_3.state == STATUS_IDLE
assert ATTR_ICON not in state_3.attributes
assert ATTR_FRIENDLY_NAME not in state_3.attributes

View file

@ -54,14 +54,14 @@ async def test_arm_home_success(hass):
side_effect=responses,
):
await setup_platform(hass, ALARM_DOMAIN)
assert STATE_ALARM_DISARMED == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_DISARMED
await hass.services.async_call(
ALARM_DOMAIN, SERVICE_ALARM_ARM_HOME, DATA, blocking=True
)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_HOME == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_ARMED_HOME
async def test_arm_home_failure(hass):
@ -72,7 +72,7 @@ async def test_arm_home_failure(hass):
side_effect=responses,
):
await setup_platform(hass, ALARM_DOMAIN)
assert STATE_ALARM_DISARMED == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_DISARMED
with pytest.raises(HomeAssistantError) as err:
await hass.services.async_call(
@ -80,7 +80,7 @@ async def test_arm_home_failure(hass):
)
await hass.async_block_till_done()
assert f"{err.value}" == "TotalConnect failed to arm home test."
assert STATE_ALARM_DISARMED == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_DISARMED
async def test_arm_home_invalid_usercode(hass):
@ -91,7 +91,7 @@ async def test_arm_home_invalid_usercode(hass):
side_effect=responses,
):
await setup_platform(hass, ALARM_DOMAIN)
assert STATE_ALARM_DISARMED == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_DISARMED
with pytest.raises(HomeAssistantError) as err:
await hass.services.async_call(
@ -99,7 +99,7 @@ async def test_arm_home_invalid_usercode(hass):
)
await hass.async_block_till_done()
assert f"{err.value}" == "TotalConnect failed to arm home test."
assert STATE_ALARM_DISARMED == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_DISARMED
async def test_arm_away_success(hass):
@ -110,13 +110,13 @@ async def test_arm_away_success(hass):
side_effect=responses,
):
await setup_platform(hass, ALARM_DOMAIN)
assert STATE_ALARM_DISARMED == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_DISARMED
await hass.services.async_call(
ALARM_DOMAIN, SERVICE_ALARM_ARM_AWAY, DATA, blocking=True
)
await hass.async_block_till_done()
assert STATE_ALARM_ARMED_AWAY == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_ARMED_AWAY
async def test_arm_away_failure(hass):
@ -127,7 +127,7 @@ async def test_arm_away_failure(hass):
side_effect=responses,
):
await setup_platform(hass, ALARM_DOMAIN)
assert STATE_ALARM_DISARMED == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_DISARMED
with pytest.raises(HomeAssistantError) as err:
await hass.services.async_call(
@ -135,7 +135,7 @@ async def test_arm_away_failure(hass):
)
await hass.async_block_till_done()
assert f"{err.value}" == "TotalConnect failed to arm away test."
assert STATE_ALARM_DISARMED == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_DISARMED
async def test_disarm_success(hass):
@ -146,13 +146,13 @@ async def test_disarm_success(hass):
side_effect=responses,
):
await setup_platform(hass, ALARM_DOMAIN)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_ARMED_AWAY
await hass.services.async_call(
ALARM_DOMAIN, SERVICE_ALARM_DISARM, DATA, blocking=True
)
await hass.async_block_till_done()
assert STATE_ALARM_DISARMED == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_DISARMED
async def test_disarm_failure(hass):
@ -163,7 +163,7 @@ async def test_disarm_failure(hass):
side_effect=responses,
):
await setup_platform(hass, ALARM_DOMAIN)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_ARMED_AWAY
with pytest.raises(HomeAssistantError) as err:
await hass.services.async_call(
@ -171,7 +171,7 @@ async def test_disarm_failure(hass):
)
await hass.async_block_till_done()
assert f"{err.value}" == "TotalConnect failed to disarm test."
assert STATE_ALARM_ARMED_AWAY == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_ARMED_AWAY
async def test_disarm_invalid_usercode(hass):
@ -182,7 +182,7 @@ async def test_disarm_invalid_usercode(hass):
side_effect=responses,
):
await setup_platform(hass, ALARM_DOMAIN)
assert STATE_ALARM_ARMED_AWAY == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_ARMED_AWAY
with pytest.raises(HomeAssistantError) as err:
await hass.services.async_call(
@ -190,4 +190,4 @@ async def test_disarm_invalid_usercode(hass):
)
await hass.async_block_till_done()
assert f"{err.value}" == "TotalConnect failed to disarm test."
assert STATE_ALARM_ARMED_AWAY == hass.states.get(ENTITY_ID).state
assert hass.states.get(ENTITY_ID).state == STATE_ALARM_ARMED_AWAY

View file

@ -114,7 +114,7 @@ async def test_enter_and_exit(hass, client, webhook_id):
state_name = hass.states.get(
"{}.{}".format(DEVICE_TRACKER_DOMAIN, data["id"])
).state
assert STATE_HOME == state_name
assert state_name == STATE_HOME
# Enter Home again
req = await client.post(url, params=data)
@ -123,7 +123,7 @@ async def test_enter_and_exit(hass, client, webhook_id):
state_name = hass.states.get(
"{}.{}".format(DEVICE_TRACKER_DOMAIN, data["id"])
).state
assert STATE_HOME == state_name
assert state_name == STATE_HOME
data["lon"] = 0
data["lat"] = 0
@ -135,7 +135,7 @@ async def test_enter_and_exit(hass, client, webhook_id):
state_name = hass.states.get(
"{}.{}".format(DEVICE_TRACKER_DOMAIN, data["id"])
).state
assert STATE_NOT_HOME == state_name
assert state_name == STATE_NOT_HOME
dev_reg = dr.async_get(hass)
assert len(dev_reg.devices) == 1
@ -237,7 +237,7 @@ async def test_load_unload_entry(hass, client, webhook_id):
state_name = hass.states.get(
"{}.{}".format(DEVICE_TRACKER_DOMAIN, data["id"])
).state
assert STATE_HOME == state_name
assert state_name == STATE_HOME
assert len(hass.data[DATA_DISPATCHER][TRACKER_UPDATE]) == 1
entry = hass.config_entries.async_entries(DOMAIN)[0]

View file

@ -53,11 +53,11 @@ async def test_bus(hass):
bus_state = hass.states.get("sensor.next_bus_to_wantage")
assert None is not bus_state
assert f"Next bus to {BUS_DIRECTION}" == bus_state.name
assert BUS_ATCOCODE == bus_state.attributes[ATTR_ATCOCODE]
assert "Harwell Campus" == bus_state.attributes[ATTR_LOCALITY]
assert "Bus Station" == bus_state.attributes[ATTR_STOP_NAME]
assert 2 == len(bus_state.attributes.get(ATTR_NEXT_BUSES))
assert bus_state.name == f"Next bus to {BUS_DIRECTION}"
assert bus_state.attributes[ATTR_ATCOCODE] == BUS_ATCOCODE
assert bus_state.attributes[ATTR_LOCALITY] == "Harwell Campus"
assert bus_state.attributes[ATTR_STOP_NAME] == "Bus Station"
assert len(bus_state.attributes.get(ATTR_NEXT_BUSES)) == 2
direction_re = re.compile(BUS_DIRECTION)
for bus in bus_state.attributes.get(ATTR_NEXT_BUSES):
@ -77,13 +77,13 @@ async def test_train(hass):
train_state = hass.states.get("sensor.next_train_to_WAT")
assert None is not train_state
assert f"Next train to {TRAIN_DESTINATION_NAME}" == train_state.name
assert TRAIN_STATION_CODE == train_state.attributes[ATTR_STATION_CODE]
assert TRAIN_DESTINATION_NAME == train_state.attributes[ATTR_CALLING_AT]
assert 25 == len(train_state.attributes.get(ATTR_NEXT_TRAINS))
assert train_state.name == f"Next train to {TRAIN_DESTINATION_NAME}"
assert train_state.attributes[ATTR_STATION_CODE] == TRAIN_STATION_CODE
assert train_state.attributes[ATTR_CALLING_AT] == TRAIN_DESTINATION_NAME
assert len(train_state.attributes.get(ATTR_NEXT_TRAINS)) == 25
assert (
"London Waterloo"
== train_state.attributes[ATTR_NEXT_TRAINS][0]["destination_name"]
train_state.attributes[ATTR_NEXT_TRAINS][0]["destination_name"]
== "London Waterloo"
)
assert "06:13" == train_state.attributes[ATTR_NEXT_TRAINS][0]["estimated"]
assert train_state.attributes[ATTR_NEXT_TRAINS][0]["estimated"] == "06:13"

View file

@ -77,9 +77,9 @@ async def test_get_device_name(mock_ssh, hass):
mock_ssh.return_value.before = load_fixture("unifi_direct.txt")
scanner = get_scanner(hass, conf_dict)
devices = scanner.scan_devices()
assert 23 == len(devices)
assert "iPhone" == scanner.get_device_name("98:00:c6:56:34:12")
assert "iPhone" == scanner.get_device_name("98:00:C6:56:34:12")
assert len(devices) == 23
assert scanner.get_device_name("98:00:c6:56:34:12") == "iPhone"
assert scanner.get_device_name("98:00:C6:56:34:12") == "iPhone"
@patch("pexpect.pxssh.pxssh.logout")

View file

@ -357,7 +357,7 @@ class TestMediaPlayer(unittest.TestCase):
except MultipleInvalid:
setup_ok = False
assert not setup_ok
assert 0 == len(entities)
assert len(entities) == 0
asyncio.run_coroutine_threadsafe(
universal.async_setup_platform(
@ -365,8 +365,8 @@ class TestMediaPlayer(unittest.TestCase):
),
self.hass.loop,
).result()
assert 1 == len(entities)
assert "test" == entities[0].name
assert len(entities) == 1
assert entities[0].name == "test"
def test_master_state(self):
"""Test master state property."""
@ -382,9 +382,9 @@ class TestMediaPlayer(unittest.TestCase):
ump = universal.UniversalMediaPlayer(self.hass, **config)
assert STATE_OFF == ump.master_state
assert ump.master_state == STATE_OFF
self.hass.states.set(self.mock_state_switch_id, STATE_ON)
assert STATE_ON == ump.master_state
assert ump.master_state == STATE_ON
def test_master_state_with_bad_attrs(self):
"""Test master state property."""
@ -394,7 +394,7 @@ class TestMediaPlayer(unittest.TestCase):
ump = universal.UniversalMediaPlayer(self.hass, **config)
assert STATE_OFF == ump.master_state
assert ump.master_state == STATE_OFF
def test_active_child_state(self):
"""Test active child state property."""
@ -454,7 +454,7 @@ class TestMediaPlayer(unittest.TestCase):
self.mock_mp_1.schedule_update_ha_state()
self.hass.block_till_done()
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
assert STATE_PLAYING == ump.state
assert ump.state == STATE_PLAYING
def test_state_with_children_and_attrs(self):
"""Test media player with children and master state."""
@ -464,21 +464,21 @@ class TestMediaPlayer(unittest.TestCase):
ump.entity_id = media_player.ENTITY_ID_FORMAT.format(config["name"])
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
assert STATE_OFF == ump.state
assert ump.state == STATE_OFF
self.hass.states.set(self.mock_state_switch_id, STATE_ON)
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
assert STATE_ON == ump.state
assert ump.state == STATE_ON
self.mock_mp_1._state = STATE_PLAYING
self.mock_mp_1.schedule_update_ha_state()
self.hass.block_till_done()
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
assert STATE_PLAYING == ump.state
assert ump.state == STATE_PLAYING
self.hass.states.set(self.mock_state_switch_id, STATE_OFF)
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
assert STATE_OFF == ump.state
assert ump.state == STATE_OFF
def test_volume_level(self):
"""Test volume level property."""
@ -494,13 +494,13 @@ class TestMediaPlayer(unittest.TestCase):
self.mock_mp_1.schedule_update_ha_state()
self.hass.block_till_done()
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
assert 0 == ump.volume_level
assert ump.volume_level == 0
self.mock_mp_1._volume_level = 1
self.mock_mp_1.schedule_update_ha_state()
self.hass.block_till_done()
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
assert 1 == ump.volume_level
assert ump.volume_level == 1
def test_media_image_url(self):
"""Test media_image_url property."""
@ -550,10 +550,10 @@ class TestMediaPlayer(unittest.TestCase):
ump = universal.UniversalMediaPlayer(self.hass, **config)
assert "['music', 'movie']" == ump.sound_mode_list
assert ump.sound_mode_list == "['music', 'movie']"
self.hass.states.set(self.mock_sound_mode_list_id, ["music", "movie", "game"])
assert "['music', 'movie', 'game']" == ump.sound_mode_list
assert ump.sound_mode_list == "['music', 'movie', 'game']"
def test_source_list_children_and_attr(self):
"""Test source list property w/ children and attrs."""
@ -561,10 +561,10 @@ class TestMediaPlayer(unittest.TestCase):
ump = universal.UniversalMediaPlayer(self.hass, **config)
assert "['dvd', 'htpc']" == ump.source_list
assert ump.source_list == "['dvd', 'htpc']"
self.hass.states.set(self.mock_source_list_id, ["dvd", "htpc", "game"])
assert "['dvd', 'htpc', 'game']" == ump.source_list
assert ump.source_list == "['dvd', 'htpc', 'game']"
def test_sound_mode_children_and_attr(self):
"""Test sound modeproperty w/ children and attrs."""
@ -572,10 +572,10 @@ class TestMediaPlayer(unittest.TestCase):
ump = universal.UniversalMediaPlayer(self.hass, **config)
assert "music" == ump.sound_mode
assert ump.sound_mode == "music"
self.hass.states.set(self.mock_sound_mode_id, "movie")
assert "movie" == ump.sound_mode
assert ump.sound_mode == "movie"
def test_source_children_and_attr(self):
"""Test source property w/ children and attrs."""
@ -583,10 +583,10 @@ class TestMediaPlayer(unittest.TestCase):
ump = universal.UniversalMediaPlayer(self.hass, **config)
assert "dvd" == ump.source
assert ump.source == "dvd"
self.hass.states.set(self.mock_source_id, "htpc")
assert "htpc" == ump.source
assert ump.source == "htpc"
def test_volume_level_children_and_attr(self):
"""Test volume level property w/ children and attrs."""
@ -594,10 +594,10 @@ class TestMediaPlayer(unittest.TestCase):
ump = universal.UniversalMediaPlayer(self.hass, **config)
assert 0 == ump.volume_level
assert ump.volume_level == 0
self.hass.states.set(self.mock_volume_id, 100)
assert 100 == ump.volume_level
assert ump.volume_level == 100
def test_is_volume_muted_children_and_attr(self):
"""Test is volume muted property w/ children and attrs."""
@ -618,14 +618,14 @@ class TestMediaPlayer(unittest.TestCase):
ump.entity_id = media_player.ENTITY_ID_FORMAT.format(config["name"])
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
assert 0 == ump.supported_features
assert ump.supported_features == 0
self.mock_mp_1._supported_features = 512
self.mock_mp_1._state = STATE_PLAYING
self.mock_mp_1.schedule_update_ha_state()
self.hass.block_till_done()
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
assert 512 == ump.supported_features
assert ump.supported_features == 512
def test_supported_features_children_and_cmds(self):
"""Test supported media commands with children and attrs."""
@ -717,8 +717,8 @@ class TestMediaPlayer(unittest.TestCase):
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
asyncio.run_coroutine_threadsafe(ump.async_turn_off(), self.hass.loop).result()
assert 0 == len(self.mock_mp_1.service_calls["turn_off"])
assert 0 == len(self.mock_mp_2.service_calls["turn_off"])
assert len(self.mock_mp_1.service_calls["turn_off"]) == 0
assert len(self.mock_mp_2.service_calls["turn_off"]) == 0
def test_service_call_to_child(self):
"""Test service calls that should be routed to a child."""
@ -734,96 +734,96 @@ class TestMediaPlayer(unittest.TestCase):
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
asyncio.run_coroutine_threadsafe(ump.async_turn_off(), self.hass.loop).result()
assert 1 == len(self.mock_mp_2.service_calls["turn_off"])
assert len(self.mock_mp_2.service_calls["turn_off"]) == 1
asyncio.run_coroutine_threadsafe(ump.async_turn_on(), self.hass.loop).result()
assert 1 == len(self.mock_mp_2.service_calls["turn_on"])
assert len(self.mock_mp_2.service_calls["turn_on"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_mute_volume(True), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["mute_volume"])
assert len(self.mock_mp_2.service_calls["mute_volume"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_set_volume_level(0.5), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["set_volume_level"])
assert len(self.mock_mp_2.service_calls["set_volume_level"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_media_play(), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["media_play"])
assert len(self.mock_mp_2.service_calls["media_play"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_media_pause(), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["media_pause"])
assert len(self.mock_mp_2.service_calls["media_pause"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_media_stop(), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["media_stop"])
assert len(self.mock_mp_2.service_calls["media_stop"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_media_previous_track(), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["media_previous_track"])
assert len(self.mock_mp_2.service_calls["media_previous_track"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_media_next_track(), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["media_next_track"])
assert len(self.mock_mp_2.service_calls["media_next_track"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_media_seek(100), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["media_seek"])
assert len(self.mock_mp_2.service_calls["media_seek"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_play_media("movie", "batman"), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["play_media"])
assert len(self.mock_mp_2.service_calls["play_media"]) == 1
asyncio.run_coroutine_threadsafe(ump.async_volume_up(), self.hass.loop).result()
assert 1 == len(self.mock_mp_2.service_calls["volume_up"])
assert len(self.mock_mp_2.service_calls["volume_up"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_volume_down(), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["volume_down"])
assert len(self.mock_mp_2.service_calls["volume_down"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_media_play_pause(), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["media_play_pause"])
assert len(self.mock_mp_2.service_calls["media_play_pause"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_select_sound_mode("music"), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["select_sound_mode"])
assert len(self.mock_mp_2.service_calls["select_sound_mode"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_select_source("dvd"), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["select_source"])
assert len(self.mock_mp_2.service_calls["select_source"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_clear_playlist(), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["clear_playlist"])
assert len(self.mock_mp_2.service_calls["clear_playlist"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_set_repeat(True), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["repeat_set"])
assert len(self.mock_mp_2.service_calls["repeat_set"]) == 1
asyncio.run_coroutine_threadsafe(
ump.async_set_shuffle(True), self.hass.loop
).result()
assert 1 == len(self.mock_mp_2.service_calls["shuffle_set"])
assert len(self.mock_mp_2.service_calls["shuffle_set"]) == 1
asyncio.run_coroutine_threadsafe(ump.async_toggle(), self.hass.loop).result()
assert 1 == len(self.mock_mp_2.service_calls["toggle"])
assert len(self.mock_mp_2.service_calls["toggle"]) == 1
def test_service_call_to_command(self):
"""Test service call to command."""
@ -843,7 +843,7 @@ class TestMediaPlayer(unittest.TestCase):
asyncio.run_coroutine_threadsafe(ump.async_update(), self.hass.loop).result()
asyncio.run_coroutine_threadsafe(ump.async_turn_off(), self.hass.loop).result()
assert 1 == len(service)
assert len(service) == 1
async def test_state_template(hass):

View file

@ -73,35 +73,35 @@ class TestVultrBinarySensorSetup(unittest.TestCase):
# Test pre data retrieval
if device.subscription == "555555":
assert "Vultr {}" == device.name
assert device.name == "Vultr {}"
device.update()
device_attrs = device.extra_state_attributes
if device.subscription == "555555":
assert "Vultr Another Server" == device.name
assert device.name == "Vultr Another Server"
if device.name == "A Server":
assert device.is_on is True
assert "power" == device.device_class
assert "on" == device.state
assert "mdi:server" == device.icon
assert "1000" == device_attrs[ATTR_ALLOWED_BANDWIDTH]
assert "yes" == device_attrs[ATTR_AUTO_BACKUPS]
assert "123.123.123.123" == device_attrs[ATTR_IPV4_ADDRESS]
assert "10.05" == device_attrs[ATTR_COST_PER_MONTH]
assert "2013-12-19 14:45:41" == device_attrs[ATTR_CREATED_AT]
assert "576965" == device_attrs[ATTR_SUBSCRIPTION_ID]
assert device.device_class == "power"
assert device.state == "on"
assert device.icon == "mdi:server"
assert device_attrs[ATTR_ALLOWED_BANDWIDTH] == "1000"
assert device_attrs[ATTR_AUTO_BACKUPS] == "yes"
assert device_attrs[ATTR_IPV4_ADDRESS] == "123.123.123.123"
assert device_attrs[ATTR_COST_PER_MONTH] == "10.05"
assert device_attrs[ATTR_CREATED_AT] == "2013-12-19 14:45:41"
assert device_attrs[ATTR_SUBSCRIPTION_ID] == "576965"
elif device.name == "Failed Server":
assert device.is_on is False
assert "off" == device.state
assert "mdi:server-off" == device.icon
assert "1000" == device_attrs[ATTR_ALLOWED_BANDWIDTH]
assert "no" == device_attrs[ATTR_AUTO_BACKUPS]
assert "192.168.100.50" == device_attrs[ATTR_IPV4_ADDRESS]
assert "73.25" == device_attrs[ATTR_COST_PER_MONTH]
assert "2014-10-13 14:45:41" == device_attrs[ATTR_CREATED_AT]
assert "123456" == device_attrs[ATTR_SUBSCRIPTION_ID]
assert device.state == "off"
assert device.icon == "mdi:server-off"
assert device_attrs[ATTR_ALLOWED_BANDWIDTH] == "1000"
assert device_attrs[ATTR_AUTO_BACKUPS] == "no"
assert device_attrs[ATTR_IPV4_ADDRESS] == "192.168.100.50"
assert device_attrs[ATTR_COST_PER_MONTH] == "73.25"
assert device_attrs[ATTR_CREATED_AT] == "2014-10-13 14:45:41"
assert device_attrs[ATTR_SUBSCRIPTION_ID] == "123456"
def test_invalid_sensor_config(self):
"""Test config type failures."""

View file

@ -73,7 +73,7 @@ class TestVultrSensorSetup(unittest.TestCase):
assert setup is None
assert 5 == len(self.DEVICES)
assert len(self.DEVICES) == 5
tested = 0
@ -87,34 +87,34 @@ class TestVultrSensorSetup(unittest.TestCase):
if device.unit_of_measurement == DATA_GIGABYTES: # Test Bandwidth Used
if device.subscription == "576965":
assert "Vultr my new server Current Bandwidth Used" == device.name
assert "mdi:chart-histogram" == device.icon
assert 131.51 == device.state
assert "mdi:chart-histogram" == device.icon
assert device.name == "Vultr my new server Current Bandwidth Used"
assert device.icon == "mdi:chart-histogram"
assert device.state == 131.51
assert device.icon == "mdi:chart-histogram"
tested += 1
elif device.subscription == "123456":
assert "Server Current Bandwidth Used" == device.name
assert 957.46 == device.state
assert device.name == "Server Current Bandwidth Used"
assert device.state == 957.46
tested += 1
elif device.unit_of_measurement == "US$": # Test Pending Charges
if device.subscription == "576965": # Default 'Vultr {} {}'
assert "Vultr my new server Pending Charges" == device.name
assert "mdi:currency-usd" == device.icon
assert 46.67 == device.state
assert "mdi:currency-usd" == device.icon
assert device.name == "Vultr my new server Pending Charges"
assert device.icon == "mdi:currency-usd"
assert device.state == 46.67
assert device.icon == "mdi:currency-usd"
tested += 1
elif device.subscription == "123456": # Custom name with 1 {}
assert "Server Pending Charges" == device.name
assert "not a number" == device.state
assert device.name == "Server Pending Charges"
assert device.state == "not a number"
tested += 1
elif device.subscription == "555555": # No {} in name
assert "VPS Charges" == device.name
assert 5.45 == device.state
assert device.name == "VPS Charges"
assert device.state == 5.45
tested += 1
assert tested == 5
@ -161,4 +161,4 @@ class TestVultrSensorSetup(unittest.TestCase):
)
assert no_sub_setup is None
assert 0 == len(self.DEVICES)
assert len(self.DEVICES) == 0

View file

@ -41,7 +41,7 @@ async def test_valid_hostname(hass):
await hass.async_block_till_done()
state = hass.states.get("switch.wake_on_lan")
assert STATE_OFF == state.state
assert state.state == STATE_OFF
with patch.object(subprocess, "call", return_value=0):
@ -53,7 +53,7 @@ async def test_valid_hostname(hass):
)
state = hass.states.get("switch.wake_on_lan")
assert STATE_ON == state.state
assert state.state == STATE_ON
await hass.services.async_call(
switch.DOMAIN,
@ -63,7 +63,7 @@ async def test_valid_hostname(hass):
)
state = hass.states.get("switch.wake_on_lan")
assert STATE_ON == state.state
assert state.state == STATE_ON
async def test_valid_hostname_windows(hass):
@ -82,7 +82,7 @@ async def test_valid_hostname_windows(hass):
await hass.async_block_till_done()
state = hass.states.get("switch.wake_on_lan")
assert STATE_OFF == state.state
assert state.state == STATE_OFF
with patch.object(subprocess, "call", return_value=0), patch.object(
platform, "system", return_value="Windows"
@ -95,7 +95,7 @@ async def test_valid_hostname_windows(hass):
)
state = hass.states.get("switch.wake_on_lan")
assert STATE_ON == state.state
assert state.state == STATE_ON
async def test_broadcast_config_ip_and_port(hass, mock_send_magic_packet):
@ -119,7 +119,7 @@ async def test_broadcast_config_ip_and_port(hass, mock_send_magic_packet):
await hass.async_block_till_done()
state = hass.states.get("switch.wake_on_lan")
assert STATE_OFF == state.state
assert state.state == STATE_OFF
with patch.object(subprocess, "call", return_value=0):
@ -155,7 +155,7 @@ async def test_broadcast_config_ip(hass, mock_send_magic_packet):
await hass.async_block_till_done()
state = hass.states.get("switch.wake_on_lan")
assert STATE_OFF == state.state
assert state.state == STATE_OFF
with patch.object(subprocess, "call", return_value=0):
@ -183,7 +183,7 @@ async def test_broadcast_config_port(hass, mock_send_magic_packet):
await hass.async_block_till_done()
state = hass.states.get("switch.wake_on_lan")
assert STATE_OFF == state.state
assert state.state == STATE_OFF
with patch.object(subprocess, "call", return_value=0):
@ -216,7 +216,7 @@ async def test_off_script(hass):
calls = async_mock_service(hass, "shell_command", "turn_off_target")
state = hass.states.get("switch.wake_on_lan")
assert STATE_OFF == state.state
assert state.state == STATE_OFF
with patch.object(subprocess, "call", return_value=0):
@ -228,7 +228,7 @@ async def test_off_script(hass):
)
state = hass.states.get("switch.wake_on_lan")
assert STATE_ON == state.state
assert state.state == STATE_ON
assert len(calls) == 0
with patch.object(subprocess, "call", return_value=2):
@ -241,7 +241,7 @@ async def test_off_script(hass):
)
state = hass.states.get("switch.wake_on_lan")
assert STATE_OFF == state.state
assert state.state == STATE_OFF
assert len(calls) == 1
@ -262,7 +262,7 @@ async def test_invalid_hostname_windows(hass):
await hass.async_block_till_done()
state = hass.states.get("switch.wake_on_lan")
assert STATE_OFF == state.state
assert state.state == STATE_OFF
with patch.object(subprocess, "call", return_value=2):
@ -274,7 +274,7 @@ async def test_invalid_hostname_windows(hass):
)
state = hass.states.get("switch.wake_on_lan")
assert STATE_OFF == state.state
assert state.state == STATE_OFF
async def test_no_hostname_state(hass):

View file

@ -226,9 +226,9 @@ async def test_valid_credential(mock_get, mock_post, hass):
}
scanner = get_scanner(hass, config)
assert scanner is not None
assert 2 == len(scanner.scan_devices())
assert "Device1" == scanner.get_device_name("23:83:BF:F6:38:A0")
assert "Device2" == scanner.get_device_name("1D:98:EC:5E:D5:A6")
assert len(scanner.scan_devices()) == 2
assert scanner.get_device_name("23:83:BF:F6:38:A0") == "Device1"
assert scanner.get_device_name("1D:98:EC:5E:D5:A6") == "Device2"
@patch("requests.get", side_effect=mocked_requests)
@ -250,6 +250,6 @@ async def test_token_timed_out(mock_get, mock_post, hass):
}
scanner = get_scanner(hass, config)
assert scanner is not None
assert 2 == len(scanner.scan_devices())
assert "Device1" == scanner.get_device_name("23:83:BF:F6:38:A0")
assert "Device2" == scanner.get_device_name("1D:98:EC:5E:D5:A6")
assert len(scanner.scan_devices()) == 2
assert scanner.get_device_name("23:83:BF:F6:38:A0") == "Device1"
assert scanner.get_device_name("1D:98:EC:5E:D5:A6") == "Device2"

View file

@ -144,7 +144,7 @@ async def test_active_zone_skips_passive_zones_2(hass):
)
await hass.async_block_till_done()
active = zone.async_active_zone(hass, 32.880700, -117.237561)
assert "zone.active_zone" == active.entity_id
assert active.entity_id == "zone.active_zone"
async def test_active_zone_prefers_smaller_zone_if_same_distance(hass):
@ -173,7 +173,7 @@ async def test_active_zone_prefers_smaller_zone_if_same_distance(hass):
)
active = zone.async_active_zone(hass, latitude, longitude)
assert "zone.small_zone" == active.entity_id
assert active.entity_id == "zone.small_zone"
async def test_active_zone_prefers_smaller_zone_if_same_distance_2(hass):
@ -196,7 +196,7 @@ async def test_active_zone_prefers_smaller_zone_if_same_distance_2(hass):
)
active = zone.async_active_zone(hass, latitude, longitude)
assert "zone.smallest_zone" == active.entity_id
assert active.entity_id == "zone.smallest_zone"
async def test_in_zone_works_for_passive_zones(hass):

View file

@ -84,7 +84,7 @@ async def test_if_fires_on_zone_enter(hass, calls):
assert len(calls) == 1
assert calls[0].context.parent_id == context.id
assert "zone - test.entity - hello - hello - test" == calls[0].data["some"]
assert calls[0].data["some"] == "zone - test.entity - hello - hello - test"
# Set out of zone again so we can trigger call
hass.states.async_set(

View file

@ -934,7 +934,7 @@ def test_socket_timeout(): # pylint: disable=invalid-name
with pytest.raises(vol.Invalid):
schema(-1)
assert _GLOBAL_DEFAULT_TIMEOUT == schema(None)
assert schema(None) == _GLOBAL_DEFAULT_TIMEOUT
assert schema(1) == 1.0

View file

@ -880,41 +880,38 @@ def test_relative_time(mock_is_safe, hass):
"""Test relative_time method."""
now = datetime.strptime("2000-01-01 10:00:00 +00:00", "%Y-%m-%d %H:%M:%S %z")
with patch("homeassistant.util.dt.now", return_value=now):
assert (
"1 hour"
== template.Template(
'{{relative_time(strptime("2000-01-01 09:00:00", "%Y-%m-%d %H:%M:%S"))}}',
hass,
).async_render()
)
assert (
"2 hours"
== template.Template(
'{{relative_time(strptime("2000-01-01 09:00:00 +01:00", "%Y-%m-%d %H:%M:%S %z"))}}',
hass,
).async_render()
)
assert (
"1 hour"
== template.Template(
'{{relative_time(strptime("2000-01-01 03:00:00 -06:00", "%Y-%m-%d %H:%M:%S %z"))}}',
hass,
).async_render()
)
assert (
str(template.strptime("2000-01-01 11:00:00 +00:00", "%Y-%m-%d %H:%M:%S %z"))
== template.Template(
'{{relative_time(strptime("2000-01-01 11:00:00 +00:00", "%Y-%m-%d %H:%M:%S %z"))}}',
hass,
).async_render()
)
assert (
"string"
== template.Template(
'{{relative_time("string")}}',
hass,
).async_render()
result = template.Template(
'{{relative_time(strptime("2000-01-01 09:00:00", "%Y-%m-%d %H:%M:%S"))}}',
hass,
).async_render()
assert result == "1 hour"
result = template.Template(
'{{relative_time(strptime("2000-01-01 09:00:00 +01:00", "%Y-%m-%d %H:%M:%S %z"))}}',
hass,
).async_render()
assert result == "2 hours"
result = template.Template(
'{{relative_time(strptime("2000-01-01 03:00:00 -06:00", "%Y-%m-%d %H:%M:%S %z"))}}',
hass,
).async_render()
assert result == "1 hour"
result1 = str(
template.strptime("2000-01-01 11:00:00 +00:00", "%Y-%m-%d %H:%M:%S %z")
)
result2 = template.Template(
'{{relative_time(strptime("2000-01-01 11:00:00 +00:00", "%Y-%m-%d %H:%M:%S %z"))}}',
hass,
).async_render()
assert result1 == result2
result = template.Template(
'{{relative_time("string")}}',
hass,
).async_render()
assert result == "string"
@patch(
@ -925,55 +922,46 @@ def test_timedelta(mock_is_safe, hass):
"""Test relative_time method."""
now = datetime.strptime("2000-01-01 10:00:00 +00:00", "%Y-%m-%d %H:%M:%S %z")
with patch("homeassistant.util.dt.now", return_value=now):
assert (
"0:02:00"
== template.Template(
"{{timedelta(seconds=120)}}",
hass,
).async_render()
)
assert (
"1 day, 0:00:00"
== template.Template(
"{{timedelta(seconds=86400)}}",
hass,
).async_render()
)
assert (
"1 day, 4:00:00"
== template.Template(
"{{timedelta(days=1, hours=4)}}",
hass,
).async_render()
)
assert (
"1 hour"
== template.Template(
"{{relative_time(now() - timedelta(seconds=3600))}}",
hass,
).async_render()
)
assert (
"1 day"
== template.Template(
"{{relative_time(now() - timedelta(seconds=86400))}}",
hass,
).async_render()
)
assert (
"1 day"
== template.Template(
"{{relative_time(now() - timedelta(seconds=86401))}}",
hass,
).async_render()
)
assert (
"15 days"
== template.Template(
"{{relative_time(now() - timedelta(weeks=2, days=1))}}",
hass,
).async_render()
)
result = template.Template(
"{{timedelta(seconds=120)}}",
hass,
).async_render()
assert result == "0:02:00"
result = template.Template(
"{{timedelta(seconds=86400)}}",
hass,
).async_render()
assert result == "1 day, 0:00:00"
result = template.Template(
"{{timedelta(days=1, hours=4)}}", hass
).async_render()
assert result == "1 day, 4:00:00"
result = template.Template(
"{{relative_time(now() - timedelta(seconds=3600))}}",
hass,
).async_render()
assert result == "1 hour"
result = template.Template(
"{{relative_time(now() - timedelta(seconds=86400))}}",
hass,
).async_render()
assert result == "1 day"
result = template.Template(
"{{relative_time(now() - timedelta(seconds=86401))}}",
hass,
).async_render()
assert result == "1 day"
result = template.Template(
"{{relative_time(now() - timedelta(weeks=2, days=1))}}",
hass,
).async_render()
assert result == "15 days"
def test_regex_match(hass):

View file

@ -19,7 +19,7 @@ def test_get_time_zone_retrieves_valid_time_zone():
time_zone = dt_util.get_time_zone(TEST_TIME_ZONE)
assert time_zone is not None
assert TEST_TIME_ZONE == time_zone.zone
assert time_zone.zone == TEST_TIME_ZONE
def test_get_time_zone_returns_none_for_garbage_time_zone():

View file

@ -171,11 +171,11 @@ def test_pressure_to_imperial():
def test_properties():
"""Test the unit properties are returned as expected."""
assert LENGTH_KILOMETERS == METRIC_SYSTEM.length_unit
assert TEMP_CELSIUS == METRIC_SYSTEM.temperature_unit
assert MASS_GRAMS == METRIC_SYSTEM.mass_unit
assert VOLUME_LITERS == METRIC_SYSTEM.volume_unit
assert PRESSURE_PA == METRIC_SYSTEM.pressure_unit
assert METRIC_SYSTEM.length_unit == LENGTH_KILOMETERS
assert METRIC_SYSTEM.temperature_unit == TEMP_CELSIUS
assert METRIC_SYSTEM.mass_unit == MASS_GRAMS
assert METRIC_SYSTEM.volume_unit == VOLUME_LITERS
assert METRIC_SYSTEM.pressure_unit == PRESSURE_PA
def test_is_metric():