diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-02-10 09:32:37 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-02-10 09:32:37 +0100 |
commit | 836b4106aeef9acd30a4fd4dbca00c5d90e9aef7 (patch) | |
tree | eed85d2ef57efee4a6332755c8bdbfe72a7dc18e /tests/test_types.py | |
parent | 8579962d017c4ec46d731b852353d38e4fb031df (diff) |
Add the option to autoincrement integer values
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'), {}) |