当前位置: 首页>>代码示例>>Python>>正文


Python clidocs.OperationDocumentEventHandler类代码示例

本文整理汇总了Python中awscli.clidocs.OperationDocumentEventHandler的典型用法代码示例。如果您正苦于以下问题:Python OperationDocumentEventHandler类的具体用法?Python OperationDocumentEventHandler怎么用?Python OperationDocumentEventHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OperationDocumentEventHandler类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_description_only_for_crosslink_manpage

 def test_description_only_for_crosslink_manpage(self):
     help_command = self.create_help_command()
     operation_handler = OperationDocumentEventHandler(help_command)
     operation_handler.doc_description(help_command=help_command)
     rendered = help_command.doc.getvalue().decode('utf-8')
     # The links are generated in the "man" mode.
     self.assertIn('See also: AWS API Documentation', rendered)
开发者ID:rnaveiras,项目名称:aws-cli,代码行数:7,代码来源:test_clidocs.py

示例2: test_includes_global_args_ref_in_man_options

 def test_includes_global_args_ref_in_man_options(self):
     help_command = self.create_help_command()
     operation_handler = OperationDocumentEventHandler(help_command)
     operation_handler.doc_options_end(help_command=help_command)
     rendered = help_command.doc.getvalue().decode('utf-8')
     # The links aren't generated in the "man" mode.
     self.assertIn(
         "See 'aws help' for descriptions of global parameters", rendered
     )
开发者ID:aws,项目名称:aws-cli,代码行数:9,代码来源:test_clidocs.py

示例3: TestRecursiveShapes

class TestRecursiveShapes(unittest.TestCase):
    def setUp(self):
        self.arg_table = {}
        self.help_command = mock.Mock()
        self.help_command.event_class = 'custom'
        self.help_command.arg_table = self.arg_table
        self.operation_model = mock.Mock()
        self.operation_model.service_model.operation_names = []
        self.help_command.obj = self.operation_model
        self.operation_handler = OperationDocumentEventHandler(
            self.help_command)

    def assert_rendered_docs_contain(self, expected):
        writes = [args[0][0] for args in
                  self.help_command.doc.write.call_args_list]
        writes = '\n'.join(writes)
        self.assertIn(expected, writes)

    def test_handle_recursive_input(self):
        shape_map = {
            'RecursiveStruct': {
                'type': 'structure',
                'members': {
                    'A': {'shape': 'NonRecursive'},
                    'B':  {'shape': 'RecursiveStruct'},
                }
            },
            'NonRecursive': {'type': 'string'}
        }
        shape = StructureShape('RecursiveStruct', shape_map['RecursiveStruct'],
                               ShapeResolver(shape_map))

        self.arg_table['arg-name'] = mock.Mock(argument_model=shape)
        self.operation_handler.doc_option_example(
            'arg-name', self.help_command)
        self.assert_rendered_docs_contain('{ ... recursive ... }')

    def test_handle_recursive_output(self):
        shape_map = {
            'RecursiveStruct': {
                'type': 'structure',
                'members': {
                    'A': {'shape': 'NonRecursive'},
                    'B':  {'shape': 'RecursiveStruct'},
                }
            },
            'NonRecursive': {'type': 'string'}
        }
        shape = StructureShape('RecursiveStruct', shape_map['RecursiveStruct'],
                               ShapeResolver(shape_map))

        operation_model = mock.Mock()
        operation_model.output_shape = shape
        self.help_command.obj = operation_model
        self.operation_handler.doc_output(self.help_command, 'event-name')
        self.assert_rendered_docs_contain('( ... recursive ... )')
开发者ID:Bryan420,项目名称:aws-cli,代码行数:56,代码来源:test_clidocs.py

示例4: test_includes_global_args_ref_in_html_options

 def test_includes_global_args_ref_in_html_options(self):
     help_command = self.create_help_command()
     help_command.doc.target = 'html'
     operation_handler = OperationDocumentEventHandler(help_command)
     operation_handler.doc_options_end(help_command=help_command)
     rendered = help_command.doc.getvalue().decode('utf-8')
     self.assertIn(
         "See :doc:`'aws help' </reference/index>` for descriptions of "
         "global parameters", rendered
     )
开发者ID:aws,项目名称:aws-cli,代码行数:10,代码来源:test_clidocs.py

示例5: test_includes_webapi_crosslink_in_html

    def test_includes_webapi_crosslink_in_html(self):
        help_command = self.create_help_command()
        # Configure this for 'html' generation:
        help_command.obj.service_model.metadata = {'uid': 'service-1-2-3'}
        help_command.obj.name = 'myoperation'
        help_command.doc.target = 'html'

        operation_handler = OperationDocumentEventHandler(help_command)
        operation_handler.doc_description(help_command=help_command)
        rendered = help_command.doc.getvalue().decode('utf-8')
        # Should expect an externa link because we're generating html.
        self.assertIn(
            'See also: `AWS API Documentation '
            '<https://docs.aws.amazon.com/goto/'
            'WebAPI/service-1-2-3/myoperation>`_', rendered)
开发者ID:rnaveiras,项目名称:aws-cli,代码行数:15,代码来源:test_clidocs.py

示例6: TestTranslationMap

class TestTranslationMap(unittest.TestCase):
    def setUp(self):
        self.arg_table = {}
        self.help_command = mock.Mock()
        self.help_command.event_class = 'custom'
        self.help_command.arg_table = self.arg_table
        self.operation_model = mock.Mock()
        self.operation_model.service_model.operation_names = []
        self.help_command.obj = self.operation_model
        self.operation_handler = OperationDocumentEventHandler(
            self.help_command)

    def assert_rendered_docs_contain(self, expected):
        writes = [args[0][0] for args in
                  self.help_command.doc.write.call_args_list]
        writes = '\n'.join(writes)
        self.assertIn(expected, writes)

    def test_boolean_arg_groups(self):
        builder = DenormalizedStructureBuilder()
        input_model = builder.with_members({
            'Flag': {'type': 'boolean'}
        }).build_model()
        argument_model = input_model.members['Flag']
        argument_model.name = 'Flag'
        self.arg_table['flag'] = mock.Mock(
            cli_type_name='boolean', argument_model=argument_model)
        self.arg_table['no-flag'] = mock.Mock(
            cli_type_name='boolean', argument_model=argument_model)
        # The --no-flag should not be used in the translation.
        self.assertEqual(
            self.operation_handler.build_translation_map(),
            {'Flag': 'flag'}
        )
开发者ID:Bryan420,项目名称:aws-cli,代码行数:34,代码来源:test_clidocs.py

示例7: setUp

 def setUp(self):
     self.arg_table = {}
     self.help_command = mock.Mock()
     self.help_command.event_class = 'custom'
     self.help_command.arg_table = self.arg_table
     self.help_command.obj.service.operations = []
     self.operation_handler = OperationDocumentEventHandler(
         self.help_command)
开发者ID:hardiku,项目名称:aws-cli,代码行数:8,代码来源:test_clidocs.py

示例8: test_documents_enum_values

 def test_documents_enum_values(self):
     shape = {
         'type': 'string',
         'enum': ['FOO', 'BAZ']
     }
     shape = StringShape('EnumArg', shape)
     arg_table = {'arg-name': mock.Mock(argument_model=shape)}
     help_command = mock.Mock()
     help_command.doc = ReSTDocument()
     help_command.event_class = 'custom'
     help_command.arg_table = arg_table
     operation_model = mock.Mock()
     operation_model.service_model.operation_names = []
     help_command.obj = operation_model
     operation_handler = OperationDocumentEventHandler(help_command)
     operation_handler.doc_option('arg-name', help_command)
     rendered = help_command.doc.getvalue().decode('utf-8')
     self.assertIn('Possible values', rendered)
     self.assertIn('FOO', rendered)
     self.assertIn('BAZ', rendered)
开发者ID:Bryan420,项目名称:aws-cli,代码行数:20,代码来源:test_clidocs.py

示例9: test_documents_json_header_shape

 def test_documents_json_header_shape(self):
     shape = {
         'type': 'string',
         'jsonvalue': True,
         'location': 'header',
         'locationName': 'X-Amz-Header-Name'
     }
     shape = StringShape('JSONValueArg', shape)
     arg_table = {'arg-name': mock.Mock(argument_model=shape)}
     help_command = mock.Mock()
     help_command.doc = ReSTDocument()
     help_command.event_class = 'custom'
     help_command.arg_table = arg_table
     operation_model = mock.Mock()
     operation_model.service_model.operation_names = []
     help_command.obj = operation_model
     operation_handler = OperationDocumentEventHandler(help_command)
     operation_handler.doc_option('arg-name', help_command)
     rendered = help_command.doc.getvalue().decode('utf-8')
     self.assertIn('(JSON)', rendered)
开发者ID:rnaveiras,项目名称:aws-cli,代码行数:20,代码来源:test_clidocs.py

示例10: TestRecursiveShapes

class TestRecursiveShapes(unittest.TestCase):
    def setUp(self):
        self.arg_table = {}
        self.help_command = mock.Mock()
        self.help_command.event_class = 'custom'
        self.help_command.arg_table = self.arg_table
        self.operation_model = mock.Mock()
        self.operation_model.service_model.operation_names = []
        self.help_command.obj = self.operation_model
        self.operation_handler = OperationDocumentEventHandler(
            self.help_command)

    def assert_rendered_docs_contain(self, expected):
        writes = [args[0][0] for args in
                  self.help_command.doc.write.call_args_list]
        writes = '\n'.join(writes)
        self.assertIn(expected, writes)

    def assert_proper_indentation(self):
        indent = self.help_command.doc.style.indent.call_count
        dedent = self.help_command.doc.style.dedent.call_count
        message = 'Imbalanced indentation: indent (%s) != dedent (%s)'
        self.assertEquals(indent, dedent, message % (indent, dedent))

    def test_handle_recursive_input(self):
        shape_map = {
            'RecursiveStruct': {
                'type': 'structure',
                'members': {
                    'A': {'shape': 'NonRecursive'},
                    'B':  {'shape': 'RecursiveStruct'},
                }
            },
            'NonRecursive': {'type': 'string'}
        }
        shape = StructureShape('RecursiveStruct', shape_map['RecursiveStruct'],
                               ShapeResolver(shape_map))

        self.arg_table['arg-name'] = mock.Mock(argument_model=shape)
        self.operation_handler.doc_option_example(
            'arg-name', self.help_command, 'process-cli-arg.foo.bar')
        self.assert_rendered_docs_contain('{ ... recursive ... }')

    def test_handle_recursive_output(self):
        shape_map = {
            'RecursiveStruct': {
                'type': 'structure',
                'members': {
                    'A': {'shape': 'NonRecursive'},
                    'B':  {'shape': 'RecursiveStruct'},
                }
            },
            'NonRecursive': {'type': 'string'}
        }
        shape = StructureShape('RecursiveStruct', shape_map['RecursiveStruct'],
                               ShapeResolver(shape_map))

        operation_model = mock.Mock()
        operation_model.output_shape = shape
        self.help_command.obj = operation_model
        self.operation_handler.doc_output(self.help_command, 'event-name')
        self.assert_rendered_docs_contain('( ... recursive ... )')

    def test_handle_empty_nested_struct(self):
        shape_map = {
            'InputStruct': {
                'type': 'structure',
                'members': {
                    'A': {'shape': 'Empty'},
                }
            },
            'Empty': {'type': 'structure', 'members': {}}
        }
        shape = StructureShape('InputStruct', shape_map['InputStruct'],
                               ShapeResolver(shape_map))

        self.arg_table['arg-name'] = mock.Mock(argument_model=shape)
        self.operation_handler.doc_option_example(
            'arg-name', self.help_command, 'process-cli-arg.foo.bar')
        self.assert_proper_indentation()
开发者ID:rnaveiras,项目名称:aws-cli,代码行数:80,代码来源:test_clidocs.py


注:本文中的awscli.clidocs.OperationDocumentEventHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。