summaryrefslogtreecommitdiff
path: root/tests/test_collection.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_collection.py')
-rw-r--r--tests/test_collection.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py
index 4fa292e..527acf9 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -1,3 +1,4 @@
+import datetime
import logging
import os.path
import shutil
@@ -117,6 +118,13 @@ class testEntries(unittest.TestCase):
self.assertIn("name: ''", entry.yaml_data)
self.assertIn('quantity: 0', entry.yaml_data)
+ def test_update_entry(self):
+ eid = '11189ee47ddf4796b718a483b379f976'
+ entry = self.collection.entry_from_eid(eid)
+ old_data = entry.data.copy()
+ entry.update()
+ self.assertEqual(old_data, entry.data)
+
class testEmptyCollection(unittest.TestCase):
def setUp(self):
@@ -289,7 +297,7 @@ class testComplexCollection(unittest.TestCase):
self.collection.settings['name'],
"Fully featured lesana collection",
)
- self.assertEqual(len(self.collection.settings['fields']), 12)
+ self.assertEqual(len(self.collection.settings['fields']), 13)
self.assertIsNotNone(self.collection.stemmer)
self.assertEqual(len(self.collection.indexed_fields), 8)
@@ -412,6 +420,26 @@ class testComplexCollection(unittest.TestCase):
self.assertEqual(matches[7].data['order'], 'delta')
self.assertEqual(matches[8].data['order'], 'zucchini')
+ def test_update_entry(self):
+ eid = '5084bc6e94f24dc6976629282ef30419'
+ entry = self.collection.entry_from_eid(eid)
+ # we keep the old data, and check that the updated field is
+ # empty
+ old_data = entry.data.copy()
+ self.assertEqual(entry.data['updated'], None)
+
+ entry.update()
+
+ # after the update, fields that were not supposed to be updated
+ # are equal to what they were before, while updated has been
+ # changed to a datetime in this year (we don't check too deeply
+ # to avoid breaking tests too often with race conditions).
+ for field in ('created', 'epoch'):
+ self.assertEqual(old_data[field], entry.data[field])
+ now = datetime.datetime.now(datetime.timezone.utc)
+ self.assertIsInstance(entry.data['updated'], datetime.datetime)
+ self.assertEqual(entry.data['updated'].year, now.year)
+
class testCollectionWithErrors(unittest.TestCase):
def setUp(self):