Exemple #1
0
    def test_struct_added_without_min_version(self):

        added_struct = schema.Struct('new_Struct', 1000, '')
        self.get_test_typespace().struct_list.append(added_struct)
        self.get_test_typespace().version = 2

        self.assert_invalid(added_object_validator.AddedObjectValidator,
                            self.NEW_OBJECT_ADDED_ERR_MSG)
Exemple #2
0
    def test_wrong_struct_type(self):
        trait = self.get_test_trait()
        sub_field = schema.Field('a_field', 1000, '',
                                 schema.Field.DataType.STRUCT, None)
        sub_field.metadata = self.get_test_struct()
        trait.state_list.append(sub_field)

        super_field = schema.Field('a_field', 1000, '',
                                   schema.Field.DataType.STRUCT, None)
        super_field.metadata = schema.Struct('SomeStruct', 1, '')

        trait.extends = schema.Trait('super_trait', 1000, '')
        trait.extends.state_list.append(super_field)

        self.assert_invalid(extends_validator.ExtendsValidator,
                            'types for field a_field do not match')
Exemple #3
0
    def test_trait_referencing_old_trait(self):
        trait = schema.Trait('Test2Trait', 2, '')
        trait.version = 2
        self.get_test_vendor().trait_list.append(trait)

        struct = schema.Struct('Test2Struct', 2, '')
        trait.struct_list.append(struct)

        field = schema.Field('field', 1000, '')
        field.struct_type = struct

        self.get_test_trait().state_list.append(field)

        trait.stability = schema.Stability.ALPHA
        self.get_test_trait().stability = schema.Stability.BETA

        self.assert_valid(
            stability_reference_validator.StabilityReferenceValidator)
Exemple #4
0
    def test_trait_referencing_current_trait(self):
        trait = schema.Trait('Test2Trait', 2, '')
        trait.version = 2
        self.get_test_vendor().trait_list.append(trait)

        struct = schema.Struct('Test2Struct', 2, '')
        trait.struct_list.append(struct)

        field = schema.Field('field', 1000, '')
        field.struct_type = struct

        self.get_test_trait().state_list.append(field)
        self.get_test_trait().version_map = schema.VersionMap()
        self.get_test_trait().version_map._parsed_map = {2: {'Test2Trait': 2}}  # pylint: disable=protected-access

        trait.stability = schema.Stability.ALPHA
        self.get_test_trait().stability = schema.Stability.BETA

        self.assert_invalid(
            stability_reference_validator.StabilityReferenceValidator,
            r'.*Traits can only reference Traits.*')
    def gen_test_schema(self):
        schema_obj = schema.Schema()

        vendor = schema.Vendor('test', 0xfe00, '')
        schema_obj.vendor_list.append(vendor)

        resource = schema.Resource('TestResource', 0x0001, '')
        resource.file = schema.File('test_resource', 1, '')
        resource.version = 2
        vendor.resource_list.append(resource)

        iface = schema.Interface('TestIface', 0x0001, '')
        iface.file = schema.File('test_iface', 1, '')
        vendor.interface_list.append(iface)

        trait = schema.Trait('TestTrait', 1, '')
        trait.file = schema.File('test_trait', 1, '')
        vendor.trait_list.append(trait)

        typespace = schema.Typespace('TestTypespace', 1, '')
        typespace.file = schema.File('test_typespace', 1, '')
        vendor.typespace_list.append(typespace)

        trait.version = 2
        trait.stability = schema.Stability.ALPHA

        field = schema.Field('test_field', 1, '', schema.Field.DataType.INT32,
                             None)
        trait.state_list.append(field)

        resource_component = schema.ResourceComponent('test_component', 1, '')
        resource_component.trait = trait
        resource.component_list.append(resource_component)

        interface_component = schema.InterfaceComponent(
            'test_component', 1, '')
        interface_component.trait = trait
        iface.component_list.append(interface_component)

        group = schema.Group('test_group', 1, '')
        group.interface = iface
        resource.group_list.append(group)

        struct = schema.Struct('TestStruct', 1, '')
        trait.struct_list.append(struct)

        enum = schema.Enum('TestEnum', 1, '')
        enum.pair_list.append(schema.EnumPair('TEST_ENUM_UNSPECIFIED', 0, ''))
        enum.pair_list.append(schema.EnumPair('TEST_ENUM_ONE', 1, ''))
        enum.pair_list.append(schema.EnumPair('TEST_ENUM_TWO', 2, ''))
        trait.enum_list.append(enum)

        event = schema.Event('TestEvent', 1, '')
        event.field_list.append(field)
        trait.event_list.append(event)

        response = schema.CommandResponse('TestRequestResponse', 1, '')
        response.field_list.append(field)

        command = schema.Command('TestRequest', 1, '')
        command.parameter_list.append(field)
        trait.command_list.append(command)

        command.response = response
        response.parent = command

        return schema_obj
Exemple #6
0
 def test_bad_struct_suffix(self):
     self.get_test_trait().struct_list.append(
         schema.Struct('TestStructEvent', 2, ''))
     self.assert_invalid(name_suffix_validator.NameSuffixValidator,
                         'name should not have suffix Event')