From e805981462505b0a9187bd98be87df44ea69eb72 Mon Sep 17 00:00:00 2001 From: Kamil Berdychowski Date: Wed, 13 Sep 2023 09:49:32 +0200 Subject: [PATCH] fix: do not retry creating a ZIP when response code is 202 --- boxsdk/client/client.py | 2 +- test/unit/client/test_client.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/boxsdk/client/client.py b/boxsdk/client/client.py index f2f30953..6b23afce 100644 --- a/boxsdk/client/client.py +++ b/boxsdk/client/client.py @@ -1461,7 +1461,7 @@ def __create_zip(self, name: str, items: Iterable) -> dict: 'download_file_name': name, 'items': zip_file_items } - return self._session.post(url, data=json.dumps(data)).json() + return self._session.post(url, data=json.dumps(data), skip_retry_codes={202}).json() @api_call def download_zip(self, name: str, items: Iterable, writeable_stream: IO) -> dict: diff --git a/test/unit/client/test_client.py b/test/unit/client/test_client.py index aa123bce..d21a3e50 100644 --- a/test/unit/client/test_client.py +++ b/test/unit/client/test_client.py @@ -1546,7 +1546,9 @@ def test_download_zip(mock_client, mock_box_session, mock_content_response): mock_box_session.get.side_effect = [mock_content_response, status_response_mock] status_returned = mock_client.download_zip(name, items, mock_writeable_stream) - mock_box_session.post.assert_called_once_with(expected_create_url, data=json.dumps(expected_create_body)) + mock_box_session.post.assert_called_once_with(expected_create_url, + data=json.dumps(expected_create_body), + skip_retry_codes={202}) mock_box_session.get.assert_any_call('https://dl.boxcloud.com/2.0/zip_downloads/124hfiowk3fa8kmrwh/content', expect_json_response=False, stream=True) mock_box_session.get.assert_called_with('https://api.box.com/2.0/zip_downloads/124hfiowk3fa8kmrwh/status')