Skip to content

Commit

Permalink
Extract variables for mocked exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes-ucsc committed Dec 13, 2024
1 parent b16ca63 commit c471789
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/service/test_manifest_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ def wrapper(*args, **kwargs):
machine_arn = service.machine_arn
execution_arn = service.execution_arn(execution_name)

not_found = CachedManifestNotFound(manifest_key)
execution_exists = self._mock_sfn_exception(_sfn,
operation_name='StartExecution',
error_code='ExecutionAlreadyExists')

def assert_get_cached_manifest(filters=filters):
get_cached_manifest.assert_called_once_with(
format=format,
Expand Down Expand Up @@ -281,7 +286,7 @@ def assert_get_manifest(partition):
@reset
def put():
nonlocal url, state, token_url
get_cached_manifest.side_effect = CachedManifestNotFound(manifest_key)
get_cached_manifest.side_effect = not_found
_sfn.start_execution.return_value = {
'executionArn': execution_arn,
'startDate': 123
Expand Down Expand Up @@ -412,11 +417,8 @@ def modified_put():
@reset
def modified_put_after_expiration():
nonlocal url
get_cached_manifest.side_effect = CachedManifestNotFound(manifest_key)
exception = self._mock_sfn_exception(_sfn,
operation_name='StartExecution',
error_code='ExecutionAlreadyExists')
_sfn.start_execution.side_effect = exception
get_cached_manifest.side_effect = not_found
_sfn.start_execution.side_effect = execution_exists
_sfn.describe_execution.return_value = {
'status': 'SUCCEEDED',
'input': json.dumps(input),
Expand Down Expand Up @@ -460,7 +462,7 @@ def get_key():
@reset
def get_key_after_expiration():
verify_manifest_key.return_value = manifest_key
get_cached_manifest_with_key.side_effect = CachedManifestNotFound(manifest_key)
get_cached_manifest_with_key.side_effect = not_found
response = requests.get(str(key_url), allow_redirects=False)
self.assertEqual(410, response.status_code)
expected_response = {
Expand Down

0 comments on commit c471789

Please sign in to comment.