Address code review from litterrobot PR (#78699)

Address code review
pull/78713/head
Nathan Spencer 2022-09-18 13:21:24 -06:00 committed by GitHub
parent 6094c00705
commit b03de1c92f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 10 deletions

View File

@ -58,17 +58,14 @@ async def test_on_off_commands(
data = {ATTR_ENTITY_ID: entity_id}
count = 0
for service in (SERVICE_TURN_ON, SERVICE_TURN_OFF):
services = ((SERVICE_TURN_ON, STATE_ON, "1"), (SERVICE_TURN_OFF, STATE_OFF, "0"))
for service, new_state, new_value in services:
count += 1
await hass.services.async_call(
PLATFORM_DOMAIN,
service,
data,
blocking=True,
await hass.services.async_call(PLATFORM_DOMAIN, service, data, blocking=True)
robot._update_data( # pylint:disable=protected-access
{updated_field: new_value}, partial=True
)
robot._update_data({updated_field: 1 if service == SERVICE_TURN_ON else 0})
assert getattr(robot, robot_command).call_count == count
state = hass.states.get(entity_id)
assert state
assert state.state == STATE_ON if service == SERVICE_TURN_ON else STATE_OFF
assert (state := hass.states.get(entity_id))
assert state.state == new_state