aboutsummaryrefslogtreecommitdiff
path: root/tests/test_types.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_types.py')
-rw-r--r--tests/test_types.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_types.py b/tests/test_types.py
index 6f0c33e..9663288 100644
--- a/tests/test_types.py
+++ b/tests/test_types.py
@@ -176,6 +176,23 @@ class testTypes(unittest.TestCase):
v = checker.load(None)
self.assertEqual(v, None)
+ def test_datetime_auto(self):
+ field_def = self._get_field_def('datetime')
+ field_def['auto'] = 'creation'
+ checker = types.LesanaDatetime(field_def, {})
+
+ now = datetime.datetime.now()
+ v = checker.empty()
+ self.assertIsInstance(v, datetime.datetime)
+ self.assertEqual(v.tzinfo, datetime.timezone.utc)
+ self.assertEqual(v.year, now.year)
+
+ field_def['auto'] = False
+ checker = types.LesanaDatetime(field_def, {})
+
+ v = checker.empty()
+ self.assertEqual(v, None)
+
def test_date(self):
checker = types.LesanaDate(self._get_field_def('date'), {})
@@ -205,6 +222,22 @@ class testTypes(unittest.TestCase):
v = checker.load(None)
self.assertEqual(v, None)
+ def test_date_auto(self):
+ field_def = self._get_field_def('date')
+ field_def['auto'] = 'creation'
+ checker = types.LesanaDate(field_def, {})
+
+ today = datetime.date.today()
+ v = checker.empty()
+ self.assertIsInstance(v, datetime.date)
+ self.assertEqual(v, today)
+
+ field_def['auto'] = False
+ checker = types.LesanaDate(field_def, {})
+
+ v = checker.empty()
+ self.assertEqual(v, None)
+
def test_boolean(self):
checker = types.LesanaBoolean(self._get_field_def('boolean'), {})