added test for basic default values, optional fields etc.

This commit is contained in:
collerek
2020-08-03 13:11:45 +02:00
parent 0bd964bdc4
commit 612f8d4604
2 changed files with 7 additions and 1 deletions

View File

@ -16,7 +16,7 @@ class ExampleModel(Model):
__metadata__ = metadata
test = fields.Integer(primary_key=True)
test_string = fields.String(length=250)
test_text = fields.Text()
test_text = fields.Text(default='')
test_bool = fields.Boolean(nullable=False)
test_float = fields.Float()
test_datetime = fields.DateTime(default=datetime.datetime.now)
@ -43,6 +43,12 @@ def test_model_attribute_access():
example = ExampleModel(test=1, test_string='test', test_bool=True)
assert example.test == 1
assert example.test_string == 'test'
assert example.test_datetime.year == datetime.datetime.now().year
assert example.test_date == datetime.date.today()
assert example.test_text == ''
assert example.test_float is None
assert example.test_bigint == 0
assert example.test_json == {}
example.test = 12
assert example.test == 12