Improve homekit_controller tests (#65266)

This commit is contained in:
Jc2k 2022-01-30 22:59:39 +00:00 committed by GitHub
parent eb94fe1ca7
commit 58b8c30221
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 1487 additions and 650 deletions

View file

@ -40,7 +40,7 @@ async def test_press_button(hass):
helper = await setup_test_component(hass, create_switch_with_setup_button)
# Helper will be for the primary entity, which is the outlet. Make a helper for the button.
energy_helper = Helper(
button = Helper(
hass,
"button.testdevice_setup",
helper.pairing,
@ -48,16 +48,18 @@ async def test_press_button(hass):
helper.config_entry,
)
outlet = energy_helper.accessory.services.first(service_type=ServicesTypes.OUTLET)
setup = outlet[CharacteristicsTypes.Vendor.HAA_SETUP]
await hass.services.async_call(
"button",
"press",
{"entity_id": "button.testdevice_setup"},
blocking=True,
)
assert setup.value == "#HAA@trcmd"
button.async_assert_service_values(
ServicesTypes.OUTLET,
{
CharacteristicsTypes.Vendor.HAA_SETUP: "#HAA@trcmd",
},
)
async def test_ecobee_clear_hold_press_button(hass):
@ -67,7 +69,7 @@ async def test_ecobee_clear_hold_press_button(hass):
)
# Helper will be for the primary entity, which is the outlet. Make a helper for the button.
energy_helper = Helper(
clear_hold = Helper(
hass,
"button.testdevice_clear_hold",
helper.pairing,
@ -75,13 +77,15 @@ async def test_ecobee_clear_hold_press_button(hass):
helper.config_entry,
)
outlet = energy_helper.accessory.services.first(service_type=ServicesTypes.OUTLET)
setup = outlet[CharacteristicsTypes.Vendor.ECOBEE_CLEAR_HOLD]
await hass.services.async_call(
"button",
"press",
{"entity_id": "button.testdevice_clear_hold"},
blocking=True,
)
assert setup.value is True
clear_hold.async_assert_service_values(
ServicesTypes.OUTLET,
{
CharacteristicsTypes.Vendor.ECOBEE_CLEAR_HOLD: True,
},
)