diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-08-05 16:58:45 +0200 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-08-05 16:58:45 +0200 |
commit | c2885894c06e15a5be0b6a00edd8e0de7746b4a9 (patch) | |
tree | 65ea4e7498eff16030bf0a68b5c66471857f5c0d /tests | |
parent | 96465262f72b1b4230513e978d8412d0affc75a1 (diff) |
Fix printing Entry id when data includes the id
Diffstat (limited to 'tests')
-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 |