Esempio n. 1
0
def test_lambda_deployer_delete():
    aws_client = mock.Mock(spec=TypedAWSClient)
    aws_client.get_role_arn_for_name.return_value = 'arn_prefix/role_name'
    lambda_function_name = 'lambda_name'
    deployed = DeployedResources('api', 'api_handler_arn/lambda_name',
                                 lambda_function_name, None, 'dev', None, None)
    d = LambdaDeployer(aws_client, None, CustomConfirmPrompt(True), None, None)
    d.delete(deployed)

    aws_client.get_role_arn_for_name.assert_called_with(lambda_function_name)
    aws_client.delete_function.assert_called_with(lambda_function_name)
    aws_client.delete_role.assert_called_with('role_name')
Esempio n. 2
0
def test_lambda_deployer_delete_already_deleted(capsys):
    lambda_function_name = 'lambda_name'
    aws_client = mock.Mock(spec=TypedAWSClient)
    aws_client.get_role_arn_for_name.return_value = 'arn_prefix/role_name'
    aws_client.delete_function.side_effect = ResourceDoesNotExistError(
        lambda_function_name)
    deployed = DeployedResources('api', 'api_handler_arn/lambda_name',
                                 lambda_function_name, None, 'dev', None, None)
    d = LambdaDeployer(aws_client, None, NoPrompt(), None, None)
    d.delete(deployed)

    # check that we printed that no lambda function with that name was found
    out, _ = capsys.readouterr()
    assert "No lambda function named %s found." % lambda_function_name in out
    aws_client.delete_function.assert_called_with(lambda_function_name)