Beispiel #1
0
    def test_check_zip_file_exist_return_false(self, aws_mock):
        exception = botocore.exceptions.ClientError(
            error_response={'Error': {
                'Code': 'NoSuchKey'
            }},
            operation_name='get_object')
        aws_mock.s3.get_object.side_effect = exception
        officer = OfficerFactory(first_name='Jerome', last_name='Finnigan')

        expect(officer.check_zip_file_exist(with_docs=False)).to.be.false()
        expect(officer.check_zip_file_exist(with_docs=True)).to.be.false()
Beispiel #2
0
    def test_check_zip_file_exist(self, aws_mock):
        aws_mock.s3.get_object.return_value = {}
        officer = OfficerFactory(id=1,
                                 first_name='Jerome',
                                 last_name='Finnigan')

        expect(officer.check_zip_file_exist(with_docs=False)).to.be.true()
        expect(aws_mock.s3.get_object).to.be.called_with(
            Bucket='officer_content_bucket', Key='zip/Jerome_Finnigan.zip')

        expect(officer.check_zip_file_exist(with_docs=True)).to.be.true()
        expect(aws_mock.s3.get_object).to.be.called_with(
            Bucket='officer_content_bucket',
            Key='zip_with_docs/Jerome_Finnigan_with_docs.zip')
Beispiel #3
0
    def test_check_zip_file_exist_raise_exception(self, aws_mock):
        client_exception = botocore.exceptions.ClientError(
            error_response={'Error': {
                'Code': 'NoSuchBucket'
            }},
            operation_name='get_object')
        other_exception = Exception('some other exception')

        aws_mock.s3.get_object.side_effect = [
            client_exception, other_exception
        ]
        officer = OfficerFactory(first_name='Jerome', last_name='Finnigan')

        expect(lambda: officer.check_zip_file_exist(with_docs=False)).to.throw(
            botocore.exceptions.ClientError)
        expect(lambda: officer.check_zip_file_exist(with_docs=True)).to.throw(
            Exception)