From 9d6c7b5ef7f651a64e27db3d676a3a0153a85e7b Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sun, 21 May 2017 13:01:23 +0200 Subject: Fix creation of an entry with uid but no filename --- tests/test_collection.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests') diff --git a/tests/test_collection.py b/tests/test_collection.py index bcd45e7..891a439 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -164,6 +164,30 @@ class testEntries(unittest.TestCase): '{uid}: {name}'.format(uid=uid, name='Another item') ) + def test_entry_creation_uid_but_no_filename(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(entry.fname, fname) + + def test_entry_creation_no_uid_no_filename(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) + self.assertIsNotNone(entry.uid) + self.assertIsNotNone(entry.fname) + + def test_entry_creation_filename_but_no_uid(self): + fname = '11189ee47ddf4796b718a483b379f976.yaml' + uid = '11189ee47ddf4796b718a483b379f976' + with open(os.path.join(self.basepath, fname)) as fp: + data = ruamel.yaml.safe_load(fp) + entry = lesana.Entry(self.collection, data=data, fname=fname) + self.assertEqual(entry.uid, uid) + class testComplexCollection(unittest.TestCase): @classmethod -- cgit v1.2.3