-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corrupt GDP1h files when downloading Issue #531 #532
Draft
KevinShuman
wants to merge
15
commits into
Cloud-Drift:main
Choose a base branch
from
KevinShuman:531-corrupt-gdp1h
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8c4100a
Empty commit
KevinShuman 8b65a76
Creates verify and fix functions w/ tests
KevinShuman f6ec330
Reformats verify and fix functions and their tests
KevinShuman 5b7f1c4
Removes verify/fix functions & tests
KevinShuman 5b18813
Includes multi-attempt check for 0 byte files
KevinShuman 5d750d1
Modifies _download_with_progress() to pass tests
KevinShuman 25f9442
Modifies _download_with_progress() to pass mypy
KevinShuman 476757e
Adjusts _download_with_progress to handle buffer
KevinShuman 87d18ae
Adjusts tests to work with changes with _download_with_progress
KevinShuman 9c9a1f2
Ignores type errors for cut_str(), which were not resulting in errors…
KevinShuman fc70232
Ignores type errors for cut_str(), which were not resulting in errors…
KevinShuman 6c92c02
Adds test for better coverage
KevinShuman d7dce77
Adds test for better coverage
KevinShuman 44cbcfa
Adds another test to improve coverage
KevinShuman 40e2292
Resolves linting error
KevinShuman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,9 @@ class utils_tests(unittest.TestCase): | |
bar_mock: Mock | ||
|
||
def setUp(self) -> None: | ||
''' | ||
""" | ||
Set up the mocks for the tests. | ||
''' | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Frankly, not sure why I changed these. Might change them back. |
||
|
||
# Mock responses for requests.head and requests.get | ||
self.head_response_mock = Mock() | ||
|
@@ -351,9 +351,7 @@ def test_download_with_empty_chunk_raises_error_after_max_attempts(self): | |
|
||
with MultiPatcher( | ||
[ | ||
patch( | ||
"clouddrift.adapters.utils.tqdm", Mock() | ||
), | ||
patch("clouddrift.adapters.utils.tqdm", Mock()), | ||
patch( | ||
"clouddrift.adapters.utils.os.path.exists", Mock(return_value=False) | ||
), | ||
|
@@ -412,7 +410,9 @@ def test_download_request_exception_context_manager(self): | |
patch("clouddrift.adapters.utils.os.rename", Mock()), | ||
patch( | ||
"clouddrift.adapters.utils.requests.get", | ||
MagicMock(side_effect=[RequestException("Network error")] * max_attempts), | ||
MagicMock( | ||
side_effect=[RequestException("Network error")] * max_attempts | ||
), | ||
), | ||
patch("clouddrift.adapters.utils._logger.error", Mock()), | ||
] | ||
|
@@ -431,7 +431,7 @@ def test_download_request_exception_context_manager(self): | |
|
||
# Verify that _logger.error was called max_attempts times with appropriate messages | ||
expected_error_calls = [ | ||
call.error(f"Request failed: Network error") for _ in range(max_attempts) | ||
call.error("Request failed: Network error") for _ in range(max_attempts) | ||
] | ||
utils._logger.error.assert_has_calls(expected_error_calls, any_order=False) | ||
self.assertEqual(utils._logger.error.call_count, max_attempts) | ||
|
@@ -440,7 +440,10 @@ def test_download_request_exception_context_manager(self): | |
utils.os.rename.assert_not_called() | ||
|
||
# Verify that the exception message contains the expected text | ||
self.assertIn("Failed to download http://example.com/file after 5 attempts", str(context.exception)) | ||
self.assertIn( | ||
"Failed to download http://example.com/file after 5 attempts", | ||
str(context.exception), | ||
) | ||
|
||
# Verify that buffer.write was not called | ||
buffer = Mock(spec=BufferedIOBase) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mypy doesn't recognize that because temp_output is a str that output is a str. The definition of temp_out comes from determining is output is a str. I.e. if output is a str, define temp_output as a str.