示例#1
0
def test_deployer_does_not_call_delete_when_no_resources(capsys):
    # If there is nothing to clean up the deployer should not call delete.
    lambda_deploy = mock.Mock(spec=LambdaDeployer)
    apig_deploy = mock.Mock(spec=APIGatewayDeployer)
    cfg = mock.Mock(spec=Config)
    deployed_resources = None
    cfg.deployed_resources.return_value = deployed_resources
    d = Deployer(apig_deploy, lambda_deploy)
    d.delete(cfg)

    out, _ = capsys.readouterr()
    assert 'No existing resources found for stage dev' in out
    lambda_deploy.delete.assert_not_called()
    apig_deploy.delete.assert_not_called()
示例#2
0
def test_deployer_delete_calls_deletes():
    # Check that athe deployer class calls other deployer classes delete
    # methods.
    lambda_deploy = mock.Mock(spec=LambdaDeployer)
    apig_deploy = mock.Mock(spec=APIGatewayDeployer)
    cfg = mock.Mock(spec=Config)
    deployed_resources = DeployedResources.from_dict({
        'backend': 'api',
        'api_handler_arn': 'lambda_arn',
        'api_handler_name': 'lambda_name',
        'rest_api_id': 'rest_id',
        'api_gateway_stage': 'dev',
        'region': 'us-west-2',
        'chalice_version': '0',
    })
    cfg.deployed_resources.return_value = deployed_resources

    d = Deployer(apig_deploy, lambda_deploy)
    d.delete(cfg)

    lambda_deploy.delete.assert_called_with(deployed_resources)
    apig_deploy.delete.assert_called_with(deployed_resources)