示例#1
0
    def test_resource_passes_through_arguments(self):
        boto3_wasabi.DEFAULT_SESSION = self.Session()

        boto3_wasabi.resource('sqs', region_name='us-west-2', verify=False)

        boto3_wasabi.DEFAULT_SESSION.resource.assert_called_with(
            'sqs', region_name='us-west-2', verify=False)
示例#2
0
    def test_resource_uses_existing_session(self, setup_session):
        boto3_wasabi.DEFAULT_SESSION = self.Session()

        boto3_wasabi.resource('sqs')

        self.assertFalse(setup_session.called,
            'setup_default_session should not have been called')
        self.assertTrue(boto3_wasabi.DEFAULT_SESSION.resource.called,
            'Default session resource method not called')
示例#3
0
    def test_resource_creates_default_session(self, setup_session):
        boto3_wasabi.DEFAULT_SESSION = None

        boto3_wasabi.resource('sqs')

        self.assertTrue(setup_session.called,
            'setup_default_session not called')
        self.assertTrue(boto3_wasabi.DEFAULT_SESSION.resource.called,
            'Default session resource method not called')
示例#4
0
def test_docs_generated():
    """Verify we can generate the appropriate docs for all services"""
    botocore_session = botocore.session.get_session()
    session = boto3_wasabi.Session(region_name='us-east-1')
    for service_name in session.get_available_services():
        generated_docs = ServiceDocumenter(service_name,
                                           session=session).document_service()
        generated_docs = generated_docs.decode('utf-8')
        client = boto3_wasabi.client(service_name, 'us-east-1')

        # Check that all of the services have the appropriate title
        yield (_assert_has_title, generated_docs, client)

        # 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:
            waiter_model = botocore_session.get_waiter_model(service_name)
            yield (_assert_has_waiter_documentation, generated_docs,
                   service_name, client, waiter_model)

        # If the service has resources, make sure the service resource
        # is at least documented.
        if service_name in session.get_available_resources():
            resource = boto3_wasabi.resource(service_name, 'us-east-1')
            yield (_assert_has_resource_documentation, generated_docs,
                   service_name, resource)
示例#5
0
 def test_s3_available_subresources_exists(self):
     s3 = boto3_wasabi.resource('s3')
     self.assertTrue(hasattr(s3, 'get_available_subresources'))
示例#6
0
 def test_has_good_error_message_when_no_resource(self):
     bad_resource_name = 'doesnotexist'
     err_regex = ('%s.*resource does not exist.' % bad_resource_name)
     with self.assertRaisesRegexp(ResourceNotExistsError, err_regex):
         boto3_wasabi.resource(bad_resource_name)
示例#7
0
 def setUp(self):
     self.resource = boto3_wasabi.resource('dynamodb', 'us-east-1')