本文整理汇总了Python中awscli.clidocs.OperationDocumentEventHandler.doc_output方法的典型用法代码示例。如果您正苦于以下问题:Python OperationDocumentEventHandler.doc_output方法的具体用法?Python OperationDocumentEventHandler.doc_output怎么用?Python OperationDocumentEventHandler.doc_output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类awscli.clidocs.OperationDocumentEventHandler
的用法示例。
在下文中一共展示了OperationDocumentEventHandler.doc_output方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRecursiveShapes
# 需要导入模块: from awscli.clidocs import OperationDocumentEventHandler [as 别名]
# 或者: from awscli.clidocs.OperationDocumentEventHandler import doc_output [as 别名]
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 ... )')
示例2: TestRecursiveShapes
# 需要导入模块: from awscli.clidocs import OperationDocumentEventHandler [as 别名]
# 或者: from awscli.clidocs.OperationDocumentEventHandler import doc_output [as 别名]
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()