fields.Function no requiere getter

FossilOrigin-Name: 47f9b9427ef55c688678001361260e5d00ea53d82977ea13e3414ed04878fb36
This commit is contained in:
bit4bit
2021-06-24 01:28:07 +00:00
parent 0216d0141a
commit a015a9361b
2 changed files with 21 additions and 1 deletions

View File

@@ -257,4 +257,18 @@ def test_field_function_setter():
person = Person()
person.password = 'calculate'
assert '<Person hash="calculate+2"/>' == person.to_xml()
def test_field_function_only_setter():
class Person(facho.model.Model):
__name__ = 'Person'
hash = fields.Attribute('hash')
password = fields.Function(setter='set_hash')
def set_hash(self, name, value):
self.hash = "%s+2" % (value)
person = Person()
person.password = 'calculate'
assert '<Person hash="calculate+2"/>' == person.to_xml()