def test_invalid_implicit_mapping(self): extra_iface_component = schema.InterfaceComponent( 'extra_component', 99, '') extra_iface_component.trait = self.get_test_trait() self.get_test_iface().component_list.append(extra_iface_component) self.assert_invalid(iface_mapping_validator.IfaceMappingValidator, r'.*No valid mapping.*')
def test_trait_added_to_interface_without_min_version(self): new_trait = schema.Trait('NewTrait', 2, '') interface_component = schema.InterfaceComponent( 'new_test_component', 1000, '') interface_component.trait = new_trait self.get_test_vendor().trait_list.append(new_trait) self.get_test_iface().version = 2 self.get_test_iface().component_list.append(interface_component) self.assert_invalid(added_object_validator.AddedObjectValidator, self.NEW_OBJECT_ADDED_ERR_MSG)
def test_valid_explicit_mapping(self): iface_component = schema.InterfaceComponent('iface_component', 99, '') iface_component.trait = self.get_test_trait() self.get_test_iface().component_list.append(iface_component) resource_component = schema.Component('resource_component', 66, '') resource_component.trait = self.get_test_trait() self.get_test_resource().component_list.append(resource_component) group_ref = schema.GroupComponentRef('iface_component', 1, '') group_ref.source_component = resource_component self.get_test_group().component_list.append(group_ref) self.assert_valid(iface_mapping_validator.IfaceMappingValidator)
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