Ejemplo n.º 1
0
def test_rest_api_does_not_exist(stubbed_api_gateway):
    client, stub = stubbed_api_gateway
    query = ResourceQuery(None, apigateway_client=client)
    stub.add_response(
        'get_rest_apis',
        service_response={
            "items": [
                {
                    "createdDate": 1468102497,
                    "id": "first_id",
                    "name": "notmyapp"
                },
                {
                    "createdDate": 1468102497,
                    "id": "third_id",
                    "name": "notmyappaswell"
                },
            ]
        },
        expected_params={},
    )
    stub.activate()

    assert query.get_rest_api_id('myappname') is None
    stub.assert_no_pending_responses()
Ejemplo n.º 2
0
def test_can_query_lambda_function_exists(stubbed_lambda):
    client, stub = stubbed_lambda
    query = ResourceQuery(client, None)
    stub.add_response('get_function',
                      service_response={'Code': {}, 'Configuration': {}},
                      expected_params={'FunctionName': 'myappname'})
    stub.activate()
    assert query.lambda_function_exists(name='myappname')
    stub.assert_no_pending_responses()
Ejemplo n.º 3
0
def test_lambda_function_does_not_exist(stubbed_lambda):
    client, stub = stubbed_lambda
    query = ResourceQuery(client, None)
    stub.add_client_error('get_function',
                          service_error_code='ResourceNotFoundException',
                          service_message='ResourceNotFound')
    stub.activate()

    assert query.lambda_function_exists(name='noexist') == False
    stub.assert_no_pending_responses()
Ejemplo n.º 4
0
def test_lambda_function_does_not_exist(stubbed_lambda):
    client, stub = stubbed_lambda
    query = ResourceQuery(client, None)
    stub.add_client_error(
        'get_function', service_error_code='ResourceNotFoundException',
        service_message='ResourceNotFound'
    )
    stub.activate()

    assert query.lambda_function_exists(name='noexist') == False
    stub.assert_no_pending_responses()
Ejemplo n.º 5
0
def test_lambda_function_bad_error_propagates(stubbed_lambda):
    client, stub = stubbed_lambda
    query = ResourceQuery(client, None)
    stub.add_client_error('get_function',
                          service_error_code='SomeOtherBadException',
                          service_message='Internal Error',
                          http_status_code=500)
    stub.activate()

    with pytest.raises(botocore.exceptions.ClientError):
        query.lambda_function_exists(name='noexist')
    stub.assert_no_pending_responses()
Ejemplo n.º 6
0
def test_can_query_lambda_function_exists(stubbed_lambda):
    client, stub = stubbed_lambda
    query = ResourceQuery(client, None)
    stub.add_response('get_function',
                      service_response={
                          'Code': {},
                          'Configuration': {}
                      },
                      expected_params={'FunctionName': 'myappname'})
    stub.activate()
    assert query.lambda_function_exists(name='myappname')
    stub.assert_no_pending_responses()
Ejemplo n.º 7
0
def test_lambda_function_bad_error_propagates(stubbed_lambda):
    client, stub = stubbed_lambda
    query = ResourceQuery(client, None)
    stub.add_client_error(
        'get_function',
        service_error_code='SomeOtherBadException',
        service_message='Internal Error',
        http_status_code=500
    )
    stub.activate()

    with pytest.raises(botocore.exceptions.ClientError):
        query.lambda_function_exists(name='noexist')
    stub.assert_no_pending_responses()
Ejemplo n.º 8
0
def test_rest_api_does_not_exist(stubbed_api_gateway):
    client, stub = stubbed_api_gateway
    query = ResourceQuery(None, apigateway_client=client)
    stub.add_response(
        'get_rest_apis',
        service_response={
            "items": [
                {"createdDate": 1468102497,
                 "id": "first_id",
                 "name": "notmyapp"},
                {"createdDate": 1468102497,
                 "id": "third_id",
                 "name": "notmyappaswell"},
            ]
        },
        expected_params={},
    )
    stub.activate()

    assert query.get_rest_api_id('myappname') is None
    stub.assert_no_pending_responses()