Пример #1
0
    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
0
    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 ... }')
Пример #3
0
 def test_documents_nested_structure(self):
     shape_map = {
         'UpperStructure': {
             'type': 'structure',
             'members': {
                 'A': {
                     'shape': 'NestedStruct'
                 },
                 'B': {
                     'shape': 'NestedStruct'
                 },
             }
         },
         'NestedStruct': {
             'type': 'structure',
             'members': {
                 'Nested_A': {
                     'shape': 'Line'
                 },
                 'Nested_B': {
                     'shape': 'Line'
                 },
             }
         },
         'Line': {
             'type': 'string'
         }
     }
     shape = StructureShape('UpperStructure', shape_map['UpperStructure'],
                            ShapeResolver(shape_map))
     rendered = self.get_help_docs_for_argument(shape)
     self.assertEqual(rendered.count('A -> (structure)'), 1)
     self.assertEqual(rendered.count('B -> (structure)'), 1)
     self.assertEqual(rendered.count('Nested_A -> (string)'), 2)
     self.assertEqual(rendered.count('Nested_B -> (string)'), 2)
Пример #4
0
    def test_handle_memberless_output_shape(self):
        shape_map = {'NoMembers': {'type': 'structure', 'members': {}}}
        shape = StructureShape('NoMembers', shape_map['NoMembers'],
                               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('None')
Пример #5
0
    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()
Пример #6
0
 def test_documents_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))
     rendered = self.get_help_docs_for_argument(shape)
     self.assertIn('( ... recursive ... )', rendered)