From 1c587b319a308a877608531961491f1dbb79317b Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Tue, 13 Dec 2016 18:29:19 +0100 Subject: Indexing of entries --- .../085682ed-6792-499d-a3ab-9aebd683c011.yaml | 2 +- tests/test_collection.py | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/data/simple/items/085682ed-6792-499d-a3ab-9aebd683c011.yaml b/tests/data/simple/items/085682ed-6792-499d-a3ab-9aebd683c011.yaml index a66bb67..16d6917 100644 --- a/tests/data/simple/items/085682ed-6792-499d-a3ab-9aebd683c011.yaml +++ b/tests/data/simple/items/085682ed-6792-499d-a3ab-9aebd683c011.yaml @@ -3,4 +3,4 @@ description: | This is a long block of test that spans multiple lines. position: somewhere -id: 085682ed6792499da3ab9aebd683c011 +uid: 085682ed6792499da3ab9aebd683c011 diff --git a/tests/test_collection.py b/tests/test_collection.py index be9a4e5..c54dc32 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -3,6 +3,8 @@ import os.path import shutil import unittest +import ruamel.yaml + import lesana @@ -44,3 +46,24 @@ class testCollectionLoading(unittest.TestCase): self.collection = lesana.Collection('tests/data/simple') self.collection.safe = False self.collection.update_cache() + + +class testEntries(unittest.TestCase): + def setUp(self): + self.collection = lesana.Collection('tests/data/simple') + self.basepath = 'tests/data/simple/items' + + def test_simple(self): + fname = '085682ed-6792-499d-a3ab-9aebd683c011.yaml' + with open(os.path.join(self.basepath, fname)) as fp: + data = ruamel.yaml.load(fp) + entry = lesana.Entry(self.collection, data=data, fname=fname) + self.assertEqual(entry.idterm, 'Q'+data['uid']) + self.assertEqual(len(entry.indexed_fields), 3) + fname = '11189ee47ddf4796b718a483b379f976.yaml' + uid = '11189ee47ddf4796b718a483b379f976' + with open(os.path.join(self.basepath, fname)) as fp: + data = ruamel.yaml.load(fp) + entry = lesana.Entry(self.collection, data=data, fname=fname) + self.assertEqual(entry.idterm, 'Q'+uid) + self.assertEqual(len(entry.indexed_fields), 3) -- cgit v1.2.3