Пример #1
0
 def setUp(self):
     super(TestServiceDocumenter, self).setUp()
     self.add_shape_to_params('Biz', 'String')
     self.setup_client()
     with mock.patch('botocore.session.create_loader',
                     return_value=self.loader):
         self.service_documenter = ServiceDocumenter('myservice')
Пример #2
0
 def get_title_section_for(self, service_name):
     contents = ServiceDocumenter(
         service_name, self._session).document_service().decode('utf-8')
     start_of_table_of_contents = 'Table of Contents'
     start_index = contents.find(start_of_table_of_contents)
     contents = contents[:start_index]
     contents = contents.encode('utf-8')
     return contents
Пример #3
0
class TestServiceDocumenter(BaseDocsTest):
    def setUp(self):
        super(TestServiceDocumenter, self).setUp()
        self.add_shape_to_params('Biz', 'String')
        self.setup_client()
        with mock.patch('botocore.session.create_loader',
                        return_value=self.loader):
            session = get_session()
            self.service_documenter = ServiceDocumenter(
                'myservice', session)

    def test_document_service(self):
        # Note that not everything will be included as it is just
        # a smoke test to make sure all of the main parts are inluded.
        contents = self.service_documenter.document_service().decode('utf-8')
        lines = [
            '*********',
            'MyService',
            '*********',
            '.. contents:: Table of Contents',
            '   :depth: 2',
            '======',
            'Client',
            '======',
            '.. py:class:: MyService.Client',
            '  A low-level client representing AWS MyService::',
            '    client = session.create_client(\'myservice\')',
            '  These are the available methods:',
            '  *   :py:meth:`sample_operation`',
            '  .. py:method:: sample_operation(**kwargs)',
            '    **Examples** ',
            '    Sample Description.',
            '    ::',
            '      response = client.sample_operation(',
            '==========',
            'Paginators',
            '==========',
            '.. py:class:: MyService.Paginator.SampleOperation',
            '  .. py:method:: paginate(**kwargs)',
            '=======',
            'Waiters',
            '=======',
            '.. py:class:: MyService.Waiter.SampleOperationComplete',
            '  .. py:method:: wait(**kwargs)'
        ]
        for line in lines:
            self.assertIn(line, contents)

    def test_document_service_no_paginator(self):
        os.remove(self.paginator_model_file)
        contents = self.service_documenter.document_service().decode('utf-8')
        self.assertNotIn('Paginators', contents)

    def test_document_service_no_waiter(self):
        os.remove(self.waiter_model_file)
        contents = self.service_documenter.document_service().decode('utf-8')
        self.assertNotIn('Waiters', contents)
Пример #4
0
class TestServiceDocumenter(BaseDocsTest):
    def setUp(self):
        super(TestServiceDocumenter, self).setUp()
        self.add_shape_to_params('Biz', 'String')
        self.setup_client()
        with mock.patch('botocore.session.create_loader',
                        return_value=self.loader):
            session = get_session()
            self.service_documenter = ServiceDocumenter(
                'myservice', session)

    def test_document_service(self):
        # Note that not everything will be included as it is just
        # a smoke test to make sure all of the main parts are inluded.
        contents = self.service_documenter.document_service().decode('utf-8')
        lines = [
            '*********',
            'MyService',
            '*********',
            '.. contents:: Table of Contents',
            '   :depth: 2',
            '======',
            'Client',
            '======',
            '.. py:class:: MyService.Client',
            '  A low-level client representing AWS MyService::',
            '    client = session.create_client(\'myservice\')',
            '  These are the available methods:',
            '  *   :py:meth:`sample_operation`',
            '  .. py:method:: sample_operation(**kwargs)',
            '==========',
            'Paginators',
            '==========',
            '.. py:class:: MyService.Paginator.SampleOperation',
            '  .. py:method:: paginate(**kwargs)',
            '=======',
            'Waiters',
            '=======',
            '.. py:class:: MyService.Waiter.SampleOperationComplete',
            '  .. py:method:: wait(**kwargs)'
        ]
        for line in lines:
            self.assertIn(line, contents)

    def test_document_service_no_paginator(self):
        os.remove(self.paginator_model_file)
        contents = self.service_documenter.document_service().decode('utf-8')
        self.assertNotIn('Paginators', contents)

    def test_document_service_no_waiter(self):
        os.remove(self.waiter_model_file)
        contents = self.service_documenter.document_service().decode('utf-8')
        self.assertNotIn('Waiters', contents)
Пример #5
0
 def setUp(self):
     super(TestServiceDocumenter, self).setUp()
     self.add_shape_to_params('Biz', 'String')
     self.setup_client()
     with mock.patch('botocore.session.create_loader',
                     return_value=self.loader):
         self.service_documenter = ServiceDocumenter('myservice')
Пример #6
0
    def assert_is_documented_as_autopopulated_param(self,
                                                    service_name,
                                                    method_name,
                                                    param_name,
                                                    doc_string=None):
        contents = ServiceDocumenter(service_name,
                                     self._session).document_service()
        # Pick an arbitrary method that uses AccountId.
        method_contents = self.get_method_document_block(method_name, contents)

        # Ensure it is not in the example.
        self.assert_not_contains_line('%s=\'string\'' % param_name,
                                      method_contents)

        # Ensure it is in the params.
        param_contents = self.get_parameter_document_block(
            param_name, method_contents)

        # Ensure it is not labeled as required.
        self.assert_not_contains_line('REQUIRED', param_contents)

        # Ensure the note about autopopulation was added.
        if doc_string is None:
            doc_string = 'Please note that this parameter is automatically'
        self.assert_contains_line(doc_string, param_contents)
Пример #7
0
 def get_parameter_documentation_from_service(
         self, service_name, method_name, param_name):
     contents = ServiceDocumenter(
         service_name, self._session).document_service()
     method_contents = self.get_method_document_block(
         method_name, contents)
     return self.get_parameter_document_block(
         param_name, method_contents)
Пример #8
0
 def test_hides_content_md5_when_impossible_to_provide(self):
     modified_methods = ['delete_objects', 'put_bucket_acl',
                         'put_bucket_cors', 'put_bucket_lifecycle',
                         'put_bucket_logging', 'put_bucket_policy',
                         'put_bucket_notification', 'put_bucket_tagging',
                         'put_bucket_replication', 'put_bucket_website',
                         'put_bucket_request_payment', 'put_object_acl',
                         'put_bucket_versioning']
     service_contents = ServiceDocumenter('s3').document_service()
     for method_name in modified_methods:
         method_contents = self.get_method_document_block(
             method_name, service_contents)
         self.assertNotIn('ContentMD5=\'string\'',
                          method_contents.decode('utf-8'))
Пример #9
0
def generate_docs(root_dir, session):
    """Generates the reference documentation for botocore

    This will go through every available AWS service and output ReSTructured
    text files documenting each service.

    :param root_dir: The directory to write the reference files to. Each
        service's reference documentation is loacated at
        root_dir/reference/services/service-name.rst
    """
    services_doc_path = os.path.join(root_dir, 'reference', 'services')
    if not os.path.exists(services_doc_path):
        os.makedirs(services_doc_path)

    # Generate reference docs and write them out.
    for service_name in session.get_available_services():
        docs = ServiceDocumenter(service_name, session).document_service()
        service_doc_path = os.path.join(services_doc_path,
                                        service_name + '.rst')
        with open(service_doc_path, 'wb') as f:
            f.write(docs)
Пример #10
0
 def get_docstring_for_method(self, service_name, method_name):
     contents = ServiceDocumenter(service_name,
                                  self._session).document_service()
     method_contents = self.get_method_document_block(method_name, contents)
     return method_contents
Пример #11
0
 def test_generate_presigned_url_is_not_documented(self):
     documenter = ServiceDocumenter('secretsmanager', self._session)
     docs = documenter.document_service()
     self.assert_not_contains_line('generate_presigned_url', docs)
 def assert_streaming_body_is_properly_documented(self, service, operation):
     service_docs = ServiceDocumenter(service,
                                      self._session).document_service()
     method_docs = self.get_method_document_block(operation, service_docs)
     self.assert_contains_line('StreamingBody', method_docs)