Exemple #1
0
def test_copy_lambda_handler_conflict(s3_event):
    import os
    os.environ["TARGET_BUCKET"] = target_bucket = 'foo'
    import boto3
    s3 = MagicMock()
    boto3.client = MagicMock(return_value=s3)
    def f(*args):
        return True
    maven_lambda.copy.s3_object_has_more_than_one_version = f
    assert copy_lambda_handler(s3_event, {}) == {"statusCode": 409}
Exemple #2
0
def test_copy_lambda_handler_conflict(s3_event):
    import os
    os.environ["TARGET_BUCKET"] = target_bucket = 'foo'
    import boto3
    s3 = MagicMock()
    boto3.client = MagicMock(return_value=s3)
    def f(*args):
        return False
    maven_lambda.copy.s3_object_has_more_than_one_version = f
    assert copy_lambda_handler(s3_event, {}) == {"statusCode": 200}
    s3.copy_object.assert_called_once_with(
        Bucket=target_bucket,
        CopySource={
            "Bucket": "source_bucket",
            "Key": "object_key",
        },
        Key="object_key",
    )