Add SetSystemDateandTime Button (#66419)

* add SetSystemDateandTime

* fix

* address review

* follow recommendation to set date and time on start

* add set date and time button test
This commit is contained in:
Diogo Gomes 2022-07-07 15:25:44 +01:00 committed by GitHub
parent 29cbd9d469
commit 4e2de2479a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 79 additions and 2 deletions

View file

@ -38,3 +38,33 @@ async def test_reboot_button_press(hass):
await hass.async_block_till_done()
devicemgmt.SystemReboot.assert_called_once()
async def test_set_dateandtime_button(hass):
"""Test states of the SetDateAndTime button."""
await setup_onvif_integration(hass)
state = hass.states.get("button.testcamera_set_system_date_and_time")
assert state
assert state.state == STATE_UNKNOWN
registry = er.async_get(hass)
entry = registry.async_get("button.testcamera_set_system_date_and_time")
assert entry
assert entry.unique_id == f"{MAC}_setsystemdatetime"
async def test_set_dateandtime_button_press(hass):
"""Test SetDateAndTime button press."""
_, camera, device = await setup_onvif_integration(hass)
device.async_manually_set_date_and_time = AsyncMock(return_value=True)
await hass.services.async_call(
BUTTON_DOMAIN,
"press",
{ATTR_ENTITY_ID: "button.testcamera_set_system_date_and_time"},
blocking=True,
)
await hass.async_block_till_done()
device.async_manually_set_date_and_time.assert_called_once()