aboutsummaryrefslogtreecommitdiff
path: root/tests/test_types.py
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-02-10 09:38:02 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-02-10 09:38:02 +0100
commit80df519ac361c93bd8de8e02c0cc2d693e82a59a (patch)
tree1cf16c468e61dfadd9bfe0b510a320dcddcaf4a4 /tests/test_types.py
parent836b4106aeef9acd30a4fd4dbca00c5d90e9aef7 (diff)
Rename the update method to auto.
Diffstat (limited to 'tests/test_types.py')
-rw-r--r--tests/test_types.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/test_types.py b/tests/test_types.py
index 1efcde1..32340d5 100644
--- a/tests/test_types.py
+++ b/tests/test_types.py
@@ -42,7 +42,7 @@ class testTypes(unittest.TestCase):
s = checker.load(None)
self.assertEqual(s, None)
- v = checker.update("Hello World!")
+ v = checker.auto("Hello World!")
self.assertEqual(v, "Hello World!")
def test_text(self):
@@ -57,7 +57,7 @@ class testTypes(unittest.TestCase):
s = checker.load(None)
self.assertEqual(s, None)
- v = checker.update("Hello World!")
+ v = checker.auto("Hello World!")
self.assertEqual(v, "Hello World!")
def test_int(self):
@@ -79,7 +79,7 @@ class testTypes(unittest.TestCase):
v = checker.load(None)
self.assertEqual(v, None)
- v = checker.update(10)
+ v = checker.auto(10)
self.assertEqual(v, 10)
def test_datetime_auto_increment(self):
@@ -90,25 +90,25 @@ class testTypes(unittest.TestCase):
v = checker.empty()
self.assertEqual(v, 0)
- v = checker.update(0)
+ v = checker.auto(0)
self.assertEqual(v, 1)
field_def['increment'] = -1
checker = types.LesanaInt(field_def, {})
- v = checker.update(0)
+ v = checker.auto(0)
self.assertEqual(v, -1)
field_def['increment'] = 0.5
checker = types.LesanaInt(field_def, {})
with self.assertLogs() as cm:
- v = checker.update(0)
+ v = checker.auto(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)
+ v = checker.auto(0)
self.assertEqual(v, 0)
def test_float(self):
@@ -133,7 +133,7 @@ class testTypes(unittest.TestCase):
v = checker.load(None)
self.assertEqual(v, None)
- v = checker.update(10.5)
+ v = checker.auto(10.5)
self.assertEqual(v, 10.5)
def test_decimal(self):
@@ -158,7 +158,7 @@ class testTypes(unittest.TestCase):
v = checker.load(None)
self.assertEqual(v, None)
- v = checker.update(decimal.Decimal("10.5"))
+ v = checker.auto(decimal.Decimal("10.5"))
self.assertEqual(v, decimal.Decimal("10.5"))
def test_timestamp(self):
@@ -191,7 +191,7 @@ class testTypes(unittest.TestCase):
v = checker.load(None)
self.assertEqual(v, None)
- v = checker.update(today)
+ v = checker.auto(today)
self.assertEqual(v, today)
def test_datetime(self):
@@ -223,7 +223,7 @@ class testTypes(unittest.TestCase):
v = checker.load(None)
self.assertEqual(v, None)
- v = checker.update(now)
+ v = checker.auto(now)
self.assertEqual(v, now)
def test_datetime_auto(self):
@@ -259,7 +259,7 @@ class testTypes(unittest.TestCase):
now = datetime.datetime.now()
past = datetime.datetime(2016, 12, 10, 21, 2)
# we pass a date in the past
- v = checker.update(past)
+ v = checker.auto(past)
self.assertIsInstance(v, datetime.datetime)
self.assertEqual(v.tzinfo, datetime.timezone.utc)
# and we want to get a date in the present
@@ -269,14 +269,14 @@ class testTypes(unittest.TestCase):
field_def['auto'] = False
checker = types.LesanaDatetime(field_def, {})
- v = checker.update(past)
+ v = checker.auto(past)
self.assertEqual(v, past)
# and the same should happen with auto=creation
field_def['auto'] = 'creation'
checker = types.LesanaDatetime(field_def, {})
- v = checker.update(past)
+ v = checker.auto(past)
self.assertEqual(v, past)
def test_date(self):
@@ -308,7 +308,7 @@ class testTypes(unittest.TestCase):
v = checker.load(None)
self.assertEqual(v, None)
- v = checker.update(today)
+ v = checker.auto(today)
self.assertEqual(v, today)
def test_date_auto(self):
@@ -343,7 +343,7 @@ class testTypes(unittest.TestCase):
today = datetime.date.today()
past = datetime.date(2016, 12, 10)
# we pass a date in the past
- v = checker.update(past)
+ v = checker.auto(past)
self.assertIsInstance(v, datetime.date)
# and we want to get a date in the present
self.assertEqual(v, today)
@@ -352,14 +352,14 @@ class testTypes(unittest.TestCase):
field_def['auto'] = False
checker = types.LesanaDate(field_def, {})
- v = checker.update(past)
+ v = checker.auto(past)
self.assertEqual(v, past)
# and the same should happen with auto=creation
field_def['auto'] = 'creation'
checker = types.LesanaDate(field_def, {})
- v = checker.update(past)
+ v = checker.auto(past)
self.assertEqual(v, past)
def test_boolean(self):
@@ -378,7 +378,7 @@ class testTypes(unittest.TestCase):
v = checker.load(None)
self.assertEqual(v, None)
- v = checker.update(True)
+ v = checker.auto(True)
self.assertEqual(v, True)
def test_file(self):
@@ -395,7 +395,7 @@ class testTypes(unittest.TestCase):
# TODO: check for invalid file paths
- v = checker.update("relative/path/to/file")
+ v = checker.auto("relative/path/to/file")
self.assertEqual(v, "relative/path/to/file")
def test_url(self):
@@ -412,7 +412,7 @@ class testTypes(unittest.TestCase):
# TODO: check for invalid URLs
- v = checker.update("http://example.org")
+ v = checker.auto("http://example.org")
self.assertEqual(v, "http://example.org")
def test_yaml(self):
@@ -431,7 +431,7 @@ class testTypes(unittest.TestCase):
v = checker.load(None)
self.assertEqual(v, None)
- v = checker.update(some_data)
+ v = checker.auto(some_data)
self.assertEqual(v, some_data)
def test_list(self):
@@ -454,7 +454,7 @@ class testTypes(unittest.TestCase):
with self.assertRaises(types.LesanaValueError):
checker.load(d)
- v = checker.update(some_data)
+ v = checker.auto(some_data)
self.assertEqual(v, some_data)
def test_list_unknown_subtype(self):