fields.Model se permite cambiar el nombre de la etiqueta

FossilOrigin-Name: 896b797629e426a5e366d5be76fc00c3cc272299d6749e40f8317893b1545a9e
This commit is contained in:
bit4bit
2021-06-24 01:18:27 +00:00
parent 49feee8809
commit 6cc4610b45
2 changed files with 18 additions and 1 deletions

View File

@@ -108,6 +108,20 @@ def test_field_model_failed_initialization():
person.id = 33
assert "<Person><ID>33</ID></Person>" == person.to_xml()
def test_field_model_with_custom_name():
class ID(facho.model.Model):
__name__ = 'ID'
class Person(facho.model.Model):
__name__ = 'Person'
id = fields.Model(ID, name='DID')
person = Person()
person.id = 33
assert "<Person><DID>33</DID></Person>" == person.to_xml()
def test_field_model_default_initialization_with_attributes():
class ID(facho.model.Model):
__name__ = 'ID'