Skip to content

Commit

Permalink
fix: do not retry creating a ZIP when response code is 202
Browse files Browse the repository at this point in the history
  • Loading branch information
antusus committed Sep 13, 2023
1 parent 9492b61 commit e805981
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion boxsdk/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion test/unit/client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit e805981

Please sign in to comment.