def test_put_retention_policy_no_credentials_error(mocker):
    mocker.patch('mount_efs.cloudwatch_put_retention_policy_helper',
                 side_effect=[NoCredentialsError()])
    is_completed = mount_efs.put_cloudwatch_log_retention_policy(
        MOCK_AGENT['client'], DEFAULT_CLOUDWATCH_LOG_GROUP,
        DEFAULT_RETENTION_DAYS)
    assert is_completed == False
def _test_put_retention_policy_client_error(mocker,
                                            exception,
                                            desired_result=False):
    operation_name = 'PutRetentionPolicy'
    response = {'Error': {'Code': exception, 'Message': exception}}
    mocker.patch('mount_efs.cloudwatch_put_retention_policy_helper',
                 side_effect=[ClientError(response, operation_name)])
    is_completed = mount_efs.put_cloudwatch_log_retention_policy(
        MOCK_AGENT['client'], DEFAULT_CLOUDWATCH_LOG_GROUP,
        DEFAULT_RETENTION_DAYS)
    assert is_completed == desired_result
Example #3
0
def _test_put_retention_policy_client_error(mocker,
                                            exception,
                                            desired_result=False):
    operation_name = "PutRetentionPolicy"
    response = {"Error": {"Code": exception, "Message": exception}}
    mocker.patch(
        "mount_efs.cloudwatch_put_retention_policy_helper",
        side_effect=[ClientError(response, operation_name)],
    )
    is_completed = mount_efs.put_cloudwatch_log_retention_policy(
        MOCK_AGENT["client"], DEFAULT_CLOUDWATCH_LOG_GROUP,
        DEFAULT_RETENTION_DAYS)
    assert is_completed == desired_result