Esempio n. 1
0
    def test_update_docval_required_field_optional_parent(self):
        """Test that update_docval_args for a required field with an optional parent sets default: None."""
        spec = GroupSpec(doc='A test group specification with a data type',
                         data_type_def='Baz',
                         groups=[
                             GroupSpec(name='group1',
                                       doc='required untyped group',
                                       attributes=[
                                           AttributeSpec(
                                               name='attr1',
                                               doc='a string attribute',
                                               dtype='text')
                                       ],
                                       quantity='?')
                         ])
        not_inherited_fields = {
            'attr1': spec.get_group('group1').get_attribute('attr1')
        }

        docval_args = list()
        CustomClassGenerator.process_field_spec(
            classdict={},
            docval_args=docval_args,
            parent_cls=EmptyBar,  # <-- arbitrary class
            attr_name='attr1',
            not_inherited_fields=not_inherited_fields,
            type_map=TypeMap(),
            spec=spec)

        expected = [{
            'name': 'attr1',
            'type': str,
            'doc': 'a string attribute',
            'default': None
        }]
        self.assertListEqual(docval_args, expected)
Esempio n. 2
0
 def test_add_group(self):
     group = GroupSpec(doc='A test group', name='root')
     group.add_group('A test group', name='subgroup')
     self.assertIsInstance(group.get_group('subgroup'), GroupSpec)