Fix boto mocks in tests

- was getting KeyError: 'Error' test failures due to the side_effect not generating enough information to be used in the ClientError class, this PR adds missing information.
This commit is contained in:
Ken Tsang
2018-02-28 10:54:52 +00:00
parent d584ca4949
commit b6401e4858
2 changed files with 17 additions and 2 deletions

View File

@@ -1251,9 +1251,16 @@ def test_build_dvla_file_retries_if_all_notifications_are_not_created(sample_let
def test_build_dvla_file_retries_if_s3_err(sample_letter_template, mocker):
job = create_job(sample_letter_template, notification_count=1)
create_notification(job.template, job=job)
error_response = {
'Error': {
'Code': 'InvalidParameterValue',
'Message': 'some error message from amazon',
'Type': 'Sender'
}
}
mocker.patch('app.celery.tasks.LetterDVLATemplate', return_value='dvla|string')
mocker.patch('app.celery.tasks.s3upload', side_effect=ClientError({}, 'operation_name'))
mocker.patch('app.celery.tasks.s3upload', side_effect=ClientError(error_response, 'operation_name'))
retry_mock = mocker.patch('app.celery.tasks.build_dvla_file.retry', side_effect=Retry)
with pytest.raises(Retry):