def get_field(self, eno: int, ftype: int) -> IpapField: obj = lib.ipap_template_get_field(self.obj, c_int(eno), c_int(ftype)) if obj: # not null field = IpapField(obj=obj) return field else: raise ValueError('Field with eno {0} and ftype {1} was not found'.format(str(eno), str(ftype)))
def get_field(self, eno: int, ftype: int) -> IpapField: obj = lib.ipap_field_container_get_field_pointer( self.obj, c_int(eno), c_int(ftype)) if obj: # not null field = IpapField(obj) return field else: raise ValueError('Field {0}.{1} not found'.format( str(eno), str(ftype)))
def test_add_template(self): ipap_field = IpapField() ipap_field.set_field_type(0, 30, 8, 3, b"campo_1", b"campo_2", b"campo_3") _id = 12 template = IpapTemplate() template.set_id(_id) template.set_type(TemplateType.IPAP_SETID_AUCTION_TEMPLATE) template.add_field(8, UnknownField.KNOWN, True, ipap_field) self.template_container.add_template(template)
def get_fields(self) -> list: size = lib.ipap_template_get_numfields(self.obj) list_return = [] for i in range(0, size): obj = lib.ipap_template_get_field_by_pos(self.obj, c_int(i)) if obj: # not null field = IpapField(obj=obj) list_return.append(field) else: raise ValueError('Field key not found') return list_return
def test_delete_all_templates(self): ipap_field = IpapField() ipap_field.set_field_type(0, 30, 8, 3, b"campo_1", b"campo_2", b"campo_3") _id = 12 template = IpapTemplate() template.set_id(_id) template.set_type(TemplateType.IPAP_SETID_AUCTION_TEMPLATE) template.add_field(8, UnknownField.KNOWN, True, ipap_field) self.template_container.add_template(template) self.template_container.delete_all_templates() val = self.template_container.get_num_templates() self.assertEqual(val, 0)
def setUp(self): self.ipap_field = IpapField() self.ipap_field.set_field_type(0, 30, 8, 3, b"campo_1", b"campo_2", b"campo_3") self.ipap_field2 = IpapField()
def test_add_field(self): ipap_field = IpapField() ipap_field.set_field_type(0, 30, 8, 3, b"campo_1", b"campo_2", b"campo_3") self.template.add_field(8, UnknownField.KNOWN, True, ipap_field)