Ejemplo n.º 1
0
def test_deployer_returns_deployed_resources(sample_app):
    cfg = Config.create(
        chalice_stage='dev',
        chalice_app=sample_app,
        project_dir='.',
    )
    lambda_deploy = mock.Mock(spec=LambdaDeployer)
    apig_deploy = mock.Mock(spec=APIGatewayDeployer)

    apig_deploy.deploy.return_value = ('api_id', 'region', 'stage')
    lambda_deploy.deploy.return_value = {
        'api_handler_name': 'lambda_function',
        'api_handler_arn': 'my_lambda_arn',
    }

    d = Deployer(apig_deploy, lambda_deploy)
    deployed_values = d.deploy(cfg)
    assert deployed_values == {
        'dev': {
            'backend': 'api',
            'api_handler_arn': 'my_lambda_arn',
            'api_handler_name': 'lambda_function',
            'rest_api_id': 'api_id',
            'api_gateway_stage': 'stage',
            'region': 'region',
            'chalice_version': chalice_version,
        }
    }
Ejemplo n.º 2
0
def test_can_deploy_apig_and_lambda(sample_app):
    lambda_deploy = mock.Mock(spec=LambdaDeployer)
    apig_deploy = mock.Mock(spec=APIGatewayDeployer)

    lambda_deploy.deploy.return_value = {
        'api_handler_name': 'lambda_function',
        'api_handler_arn': 'my_lambda_arn',
    }
    apig_deploy.deploy.return_value = ('api_id', 'region', 'stage')

    d = Deployer(apig_deploy, lambda_deploy)
    cfg = Config.create(chalice_stage='dev',
                        chalice_app=sample_app,
                        project_dir='.')
    d.deploy(cfg)
    lambda_deploy.deploy.assert_called_with(cfg, None, 'dev')
    apig_deploy.deploy.assert_called_with(cfg, None, 'my_lambda_arn')
Ejemplo n.º 3
0
def test_can_deploy_apig_and_lambda(sample_app):
    lambda_deploy = mock.Mock(spec=LambdaDeployer)
    apig_deploy = mock.Mock(spec=APIGatewayDeployer)

    apig_deploy.deploy.return_value = ('api_id', 'region', 'stage')

    d = Deployer(apig_deploy, lambda_deploy)
    cfg = Config({'chalice_app': sample_app})
    result = d.deploy(cfg)
    assert result == ('api_id', 'region', 'stage')
    lambda_deploy.deploy.assert_called_with(cfg)
    apig_deploy.deploy.assert_called_with(cfg)