mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 15:27:08 +00:00
Fix missing id in Habitica completed todos API response (#124565)
* Fix missing id in completed todos API response * Copy id only if none * Update homeassistant/components/habitica/coordinator.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> --------- Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
5550b1a74e
commit
c9e7c76ee5
@ -56,7 +56,14 @@ class HabiticaDataUpdateCoordinator(DataUpdateCoordinator[HabiticaData]):
|
|||||||
try:
|
try:
|
||||||
user_response = await self.api.user.get()
|
user_response = await self.api.user.get()
|
||||||
tasks_response = await self.api.tasks.user.get()
|
tasks_response = await self.api.tasks.user.get()
|
||||||
tasks_response.extend(await self.api.tasks.user.get(type="completedTodos"))
|
tasks_response.extend(
|
||||||
|
[
|
||||||
|
{"id": task["_id"], **task}
|
||||||
|
for task in await self.api.tasks.user.get(type="completedTodos")
|
||||||
|
if task.get("_id")
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
except ClientResponseError as error:
|
except ClientResponseError as error:
|
||||||
if error.status == HTTPStatus.TOO_MANY_REQUESTS:
|
if error.status == HTTPStatus.TOO_MANY_REQUESTS:
|
||||||
_LOGGER.debug("Currently rate limited, skipping update")
|
_LOGGER.debug("Currently rate limited, skipping update")
|
||||||
|
@ -73,7 +73,20 @@ def common_requests(aioclient_mock: AiohttpClientMocker) -> AiohttpClientMocker:
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
aioclient_mock.get(
|
||||||
|
"https://habitica.com/api/v3/tasks/user?type=completedTodos",
|
||||||
|
json={
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"text": "this is a mock todo #5",
|
||||||
|
"id": 5,
|
||||||
|
"_id": 5,
|
||||||
|
"type": "todo",
|
||||||
|
"completed": True,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
)
|
||||||
aioclient_mock.get(
|
aioclient_mock.get(
|
||||||
"https://habitica.com/api/v3/tasks/user",
|
"https://habitica.com/api/v3/tasks/user",
|
||||||
json={
|
json={
|
||||||
@ -88,19 +101,6 @@ def common_requests(aioclient_mock: AiohttpClientMocker) -> AiohttpClientMocker:
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
aioclient_mock.get(
|
|
||||||
"https://habitica.com/api/v3/tasks/user?type=completedTodos",
|
|
||||||
json={
|
|
||||||
"data": [
|
|
||||||
{
|
|
||||||
"text": "this is a mock todo #5",
|
|
||||||
"id": 5,
|
|
||||||
"type": "todo",
|
|
||||||
"completed": True,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
aioclient_mock.post(
|
aioclient_mock.post(
|
||||||
"https://habitica.com/api/v3/tasks/user",
|
"https://habitica.com/api/v3/tasks/user",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user