Пример #1
0
 def test_role_does_not_exist(self):
     client = self.client
     client.get_role_arn_for_name.side_effect = ResourceDoesNotExistError()
     role = models.ManagedIAMRole('my_role',
                                  role_name='app-dev',
                                  trust_policy={},
                                  policy=None)
     assert not self.remote_state.resource_exists(role)
     self.client.get_role_arn_for_name.assert_called_with('app-dev')
Пример #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)
Пример #3
0
def test_api_gateway_deployer_delete_already_deleted(capsys):
    rest_api_id = 'abcdef1234'
    aws_client = mock.Mock(spec=TypedAWSClient, region_name='us-west-2')
    aws_client.delete_rest_api.side_effect = ResourceDoesNotExistError(
        rest_api_id)
    deployed = DeployedResources(None, None, None, rest_api_id, 'dev', None,
                                 None)
    aws_client.rest_api_exists.return_value = True
    d = APIGatewayDeployer(aws_client)
    d.delete(deployed)

    # Check that we printed out that no rest api with that id was found
    out, _ = capsys.readouterr()
    assert "No rest API with id %s found." % rest_api_id in out
    aws_client.delete_rest_api.assert_called_with(rest_api_id)