def test_all_collections_have_paginators_if_needed():
    # If a collection relies on an operation that is paginated, it
    # will require a paginator to iterate through all of the resources
    # with the all() method. If there is no paginator, it will only
    # make it through the first page of results. So we need to make sure
    # if a collection looks like it uses a paginated operation then there
    # should be a paginator applied to it.
    botocore_session = botocore.session.get_session()
    session = Session(botocore_session=botocore_session)
    loader = botocore_session.get_component('data_loader')
    for service_name in session.get_available_resources():
        client = session.client(service_name, region_name='us-east-1')
        json_resource_model = loader.load_service_model(
            service_name, 'resources-1')
        resource_defs = json_resource_model['resources']
        resource_models = []
        # Get the service resource model
        service_resource_model = ResourceModel(
            service_name, json_resource_model['service'], resource_defs)
        resource_models.append(service_resource_model)
        # Generate all of the resource models for a service
        for resource_name, resource_defintion in resource_defs.items():
            resource_models.append(ResourceModel(
                resource_name, resource_defintion, resource_defs))
        for resource_model in resource_models:
            # Iterate over all of the collections for each resource model
            # and ensure that the collection has a paginator if it needs one.
            for collection_model in resource_model.collections:
                yield (
                    _assert_collection_has_paginator_if_needed, client,
                    service_name, resource_name, collection_model)
Esempio n. 2
0
def _collection_test_args():
    botocore_session = botocore.session.get_session()
    session = Session(botocore_session=botocore_session)
    loader = botocore_session.get_component('data_loader')
    for service_name in session.get_available_resources():
        client = session.client(service_name, region_name='us-east-1')
        json_resource_model = loader.load_service_model(
            service_name, 'resources-1')
        resource_defs = json_resource_model['resources']
        resource_models = []
        # Get the service resource model
        service_resource_model = ResourceModel(service_name,
                                               json_resource_model['service'],
                                               resource_defs)
        resource_models.append(service_resource_model)
        # Generate all of the resource models for a service
        for resource_name, resource_defintion in resource_defs.items():
            resource_models.append(
                ResourceModel(resource_name, resource_defintion,
                              resource_defs))
        for resource_model in resource_models:
            # Iterate over all of the collections for each resource model
            # and ensure that the collection has a paginator if it needs one.
            for collection_model in resource_model.collections:
                yield (client, service_name, resource_name, collection_model)
Esempio n. 3
0
def test_docs_generated():
    """Verify we can generate the appropriate docs for all services"""
    botocore_session = botocore.session.get_session()
    session = boto3.Session()
    for service_name in session.get_available_services():
        generated_docs = ServiceDocumenter(service_name).document_service()
        generated_docs = generated_docs.decode('utf-8')
        client = boto3.client(service_name, 'us-east-1')

        # Check that all services have the client documented.
        yield (_assert_has_client_documentation, generated_docs, service_name,
               client)

        # If the client can paginate, make sure the paginators are documented.
        try:
            paginator_model = botocore_session.get_paginator_model(
                service_name)
            yield (_assert_has_paginator_documentation, generated_docs,
                   service_name, client,
                   sorted(paginator_model._paginator_config))
        except DataNotFoundError:
            pass

        # If the client has waiters, make sure the waiters are documented
        if client.waiter_names:
            yield (_assert_has_waiter_documentation, generated_docs,
                   service_name, client)

        # If the service has resources, make sure the service resource
        # is at least documented.
        if service_name in session.get_available_resources():
            resource = boto3.resource(service_name, 'us-east-1')
            yield (_assert_has_resource_documentation, generated_docs,
                   service_name, resource)
def test_all_collections_have_paginators_if_needed():
    # If a collection relies on an operation that is paginated, it
    # will require a paginator to iterate through all of the resources
    # with the all() method. If there is no paginator, it will only
    # make it through the first page of results. So we need to make sure
    # if a collection looks like it uses a paginated operation then there
    # should be a paginator applied to it.
    botocore_session = botocore.session.get_session()
    session = Session(botocore_session=botocore_session)
    loader = botocore_session.get_component('data_loader')
    for service_name in session.get_available_resources():
        client = session.client(service_name, region_name='us-east-1')
        json_resource_model = loader.load_service_model(
            service_name, 'resources-1')
        resource_defs = json_resource_model['resources']
        resource_models = []
        # Get the service resource model
        service_resource_model = ResourceModel(
            service_name, json_resource_model['service'], resource_defs)
        resource_models.append(service_resource_model)
        # Generate all of the resource models for a service
        for resource_name, resource_defintion in resource_defs.items():
            resource_models.append(ResourceModel(
                resource_name, resource_defintion, resource_defs))
        for resource_model in resource_models:
            # Iterate over all of the collections for each resource model
            # and ensure that the collection has a paginator if it needs one.
            for collection_model in resource_model.collections:
                yield (
                    _assert_collection_has_paginator_if_needed, client,
                    service_name, resource_name, collection_model)
Esempio n. 5
0
def test_docs_generated():
    """Verify we can generate the appropriate docs for all services"""
    botocore_session = botocore.session.get_session()
    session = boto3.Session()
    for service_name in session.get_available_services():
        generated_docs = ServiceDocumenter(service_name).document_service()
        generated_docs = generated_docs.decode('utf-8')
        client = boto3.client(service_name, 'us-east-1')

        # Check that all services have the client documented.
        yield (_assert_has_client_documentation, generated_docs, service_name,
               client)

        # If the client can paginate, make sure the paginators are documented.
        try:
            paginator_model = botocore_session.get_paginator_model(
                service_name)
            yield (_assert_has_paginator_documentation, generated_docs,
                   service_name, client,
                   sorted(paginator_model._paginator_config))
        except DataNotFoundError:
            pass

        # If the client has waiters, make sure the waiters are documented
        if client.waiter_names:
            yield (_assert_has_waiter_documentation, generated_docs,
                   service_name, client)

        # If the service has resources, make sure the service resource
        # is at least documented.
        if service_name in session.get_available_resources():
            resource = boto3.resource(service_name, 'us-east-1')
            yield (_assert_has_resource_documentation, generated_docs,
                   service_name, resource)
Esempio n. 6
0
def _all_resources():
    session = create_session()
    for service_name in session.get_available_resources():
        yield session, service_name
Esempio n. 7
0
def test_can_create_all_resources():
    """Verify we can create all existing resources."""
    session = create_session()
    for service_name in session.get_available_resources():
        yield _test_create_resource, session, service_name
Esempio n. 8
0
def available_resources():
    session = boto3.Session(region_name='us-east-1')
    return session.get_available_resources()