def test_command_without_min_version(self): added_command = schema.Command('NewCommand', 1000, '') self.get_test_trait().command_list.append(added_command) self.assert_invalid(added_object_validator.AddedObjectValidator, self.NEW_OBJECT_ADDED_ERR_MSG)
def test_command_added_to_prod_trait_without_increment_trait_version(self): self.get_test_trait().stability = schema.Stability.PROD self.get_previous_test_trait().stability = schema.Stability.PROD added_command = schema.Command('NewRequest', 1000, '') added_command.min_version = self.get_test_trait().version self.get_test_trait().command_list.append(added_command) self.assert_invalid(added_object_validator.AddedObjectValidator, self.NEW_OBJECT_ON_PROD_ERR_MSG)
def test_duplicate_command_ids(self): self.trait.command_list.append(schema.Command('Cmd', 1, '')) with self.assertRaisesRegexp( exception.DuplicateObject, r'Duplicate <class \'.*\.Command\'> object by_number'): self.trait.command_list.append(schema.Command('Dupe', 1, ''))
def test_schema_list_append_bad_type(self): with self.assertRaisesRegexp( exception.InvalidValue, r'Expected <class \'.*\.Trait\'> instance, got'): self.vendor.trait_list.append(schema.Command('Dupe', 1, ''))
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