diff options
Diffstat (limited to 'tests/test_collection.py')
-rw-r--r-- | tests/test_collection.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py index 5c326e3..869828a 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -196,6 +196,26 @@ class testEntries(unittest.TestCase): entry = lesana.Entry(self.collection, data=data, fname=fname) self.assertEqual(entry.uid, uid) + def test_entry_str_filename_and_uid(self): + fname = '11189ee47ddf4796b718a483b379f976.yaml' + with open(os.path.join(self.basepath, fname)) as fp: + data = ruamel.yaml.safe_load(fp) + data['uid'] = '11189ee47ddf4796b718a483b379f976' + entry = lesana.Entry(self.collection, data=data) + self.assertEqual(str(entry), data['uid']) + self.collection.settings['entry_label'] = '{{ uid }}: {{ name }}' + self.assertEqual(str(entry), data['uid'] + ': Another item') + + def test_entry_str_filename_no_uid(self): + fname = '11189ee47ddf4796b718a483b379f976.yaml' + with open(os.path.join(self.basepath, fname)) as fp: + data = ruamel.yaml.safe_load(fp) + entry = lesana.Entry(self.collection, data=data) + uid = entry.uid + self.assertEqual(str(entry), uid) + self.collection.settings['entry_label'] = '{{ uid }}: {{ name }}' + self.assertEqual(str(entry), uid + ': Another item') + class testComplexCollection(unittest.TestCase): @classmethod |