Fix Google Tasks parsing of remove responses (#115258)

This commit is contained in:
Allen Porter 2024-04-08 22:39:31 -07:00 committed by GitHub
parent d4500cf945
commit 4a7a22641e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

View file

@ -112,8 +112,9 @@ class AsyncConfigEntryAuth:
raise GoogleTasksApiError(
f"Google Tasks API responded with error ({exception.status_code})"
) from exception
data = json.loads(response)
_raise_if_error(data)
if response:
data = json.loads(response)
_raise_if_error(data)
for task_id in task_ids:
batch.add(

View file

@ -156,7 +156,7 @@ def create_response_object(api_response: dict | list) -> tuple[Response, bytes]:
def create_batch_response_object(
content_ids: list[str], api_responses: list[dict | list | Response]
content_ids: list[str], api_responses: list[dict | list | Response | None]
) -> tuple[Response, bytes]:
"""Create a batch response in the multipart/mixed format."""
assert len(api_responses) == len(content_ids)
@ -166,7 +166,7 @@ def create_batch_response_object(
body = ""
if isinstance(api_response, Response):
status = api_response.status
else:
elif api_response is not None:
body = json.dumps(api_response)
content.extend(
[
@ -194,7 +194,7 @@ def create_batch_response_object(
def create_batch_response_handler(
api_responses: list[dict | list | Response],
api_responses: list[dict | list | Response | None],
) -> Callable[[Any], tuple[Response, bytes]]:
"""Create a fake http2lib response handler that supports generating batch responses.
@ -598,11 +598,11 @@ async def test_partial_update_status(
[
LIST_TASK_LIST_RESPONSE,
LIST_TASKS_RESPONSE_MULTIPLE,
[EMPTY_RESPONSE, EMPTY_RESPONSE, EMPTY_RESPONSE], # Delete batch
[None, None, None], # Delete batch empty responses
LIST_TASKS_RESPONSE, # refresh after delete
]
)
)
),
],
)
async def test_delete_todo_list_item(