Add test coverage for doorbird events (#122617)

This commit is contained in:
J. Nick Koston 2024-07-26 09:55:14 -05:00 committed by GitHub
parent 850703824b
commit 5bb6272dfa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 91 additions and 14 deletions

View file

@ -25,19 +25,12 @@ class DoorBirdRequestView(HomeAssistantView):
"""Respond to requests from the device."""
hass = request.app[KEY_HASS]
token: str | None = request.query.get("token")
if (
token is None
or (door_station := get_door_station_by_token(hass, token)) is None
):
if not token or not (door_station := get_door_station_by_token(hass, token)):
return web.Response(
status=HTTPStatus.UNAUTHORIZED, text="Invalid token provided."
)
if door_station:
event_data = door_station.get_event_data(event)
else:
event_data = {}
event_data = door_station.get_event_data(event)
#
# This integration uses a multiple different events.
# It would be a major breaking change to change this to