diff options
Diffstat (limited to 'tests/test_types.py')
-rw-r--r-- | tests/test_types.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_types.py b/tests/test_types.py index 260167c..1efcde1 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -82,6 +82,35 @@ class testTypes(unittest.TestCase): v = checker.update(10) self.assertEqual(v, 10) + def test_datetime_auto_increment(self): + field_def = self._get_field_def('integer') + field_def['auto'] = 'increment' + checker = types.LesanaInt(field_def, {}) + + v = checker.empty() + self.assertEqual(v, 0) + + v = checker.update(0) + self.assertEqual(v, 1) + + field_def['increment'] = -1 + checker = types.LesanaInt(field_def, {}) + v = checker.update(0) + self.assertEqual(v, -1) + + field_def['increment'] = 0.5 + checker = types.LesanaInt(field_def, {}) + with self.assertLogs() as cm: + v = checker.update(0) + self.assertIn('WARNING', cm.output[0]) + self.assertIn('Invalid configuration value', cm.output[0]) + self.assertEqual(v, 0) + + field_def['auto'] = 'false' + checker = types.LesanaInt(field_def, {}) + v = checker.update(0) + self.assertEqual(v, 0) + def test_float(self): checker = types.LesanaFloat(self._get_field_def('float'), {}) |