-
Notifications
You must be signed in to change notification settings - Fork 2
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
DAS-2034 - Remove custom retry logic from HOSS in favour of harmony-service-lib. #4
Changes from 1 commit
0b45c1f
828cd16
0a89db0
cbd5153
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.0 | ||
1.0.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,12 @@ | |
from harmony.exceptions import ForbiddenException, ServerException | ||
from harmony.util import config | ||
|
||
from hoss.exceptions import UrlAccessFailed, UrlAccessFailedWithRetries | ||
from hoss.exceptions import UrlAccessFailed | ||
from hoss.utilities import (download_url, format_dictionary_string, | ||
format_variable_set_string, | ||
get_constraint_expression, get_file_mimetype, | ||
get_opendap_nc4, get_value_or_default, | ||
HTTP_REQUEST_ATTEMPTS, move_downloaded_nc4, | ||
rgetattr) | ||
move_downloaded_nc4, rgetattr) | ||
|
||
|
||
class TestUtilities(TestCase): | ||
|
@@ -92,10 +91,18 @@ def test_download_url(self, mock_util_download): | |
mock_util_download.side_effect = [self.harmony_500_error, | ||
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. This subtest name is incorrect now. 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. Good catch. I updated that test name (and also the doc string for the overall test that mentioned retries would be tested) |
||
http_response] | ||
|
||
response = download_url(test_url, output_directory, self.logger) | ||
with self.assertRaises(UrlAccessFailed): | ||
download_url(test_url, output_directory, self.logger, | ||
access_token, self.config) | ||
|
||
self.assertEqual(response, http_response) | ||
self.assertEqual(mock_util_download.call_count, 2) | ||
mock_util_download.assert_called_once_with( | ||
test_url, | ||
output_directory, | ||
self.logger, | ||
access_token=access_token, | ||
data=None, | ||
cfg=self.config | ||
) | ||
mock_util_download.reset_mock() | ||
|
||
with self.subTest('Non-500 error does not retry, and is re-raised.'): | ||
|
@@ -116,17 +123,6 @@ def test_download_url(self, mock_util_download): | |
) | ||
mock_util_download.reset_mock() | ||
|
||
with self.subTest('Maximum number of attempts not exceeded.'): | ||
mock_util_download.side_effect = [ | ||
self.harmony_500_error | ||
] * (HTTP_REQUEST_ATTEMPTS + 1) | ||
with self.assertRaises(UrlAccessFailedWithRetries): | ||
download_url(test_url, output_directory, self.logger) | ||
|
||
self.assertEqual(mock_util_download.call_count, | ||
HTTP_REQUEST_ATTEMPTS) | ||
mock_util_download.reset_mock() | ||
|
||
@patch('hoss.utilities.move_downloaded_nc4') | ||
@patch('hoss.utilities.util_download') | ||
def test_get_opendap_nc4(self, mock_download, mock_move_download): | ||
|
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.
Initially I included the path to the shape file, but this is somewhat meaningless as Harmony creates a temporary file, which obfuscates any original user naming convention (the file name is essentially a generated ID).