From c2885894c06e15a5be0b6a00edd8e0de7746b4a9 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sat, 5 Aug 2017 16:58:45 +0200 Subject: Fix printing Entry id when data includes the id --- tests/test_collection.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') 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 -- cgit v1.2.3