diff options
| author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2016-12-13 18:29:19 +0100 | 
|---|---|---|
| committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2016-12-13 18:29:19 +0100 | 
| commit | 1c587b319a308a877608531961491f1dbb79317b (patch) | |
| tree | 2722df12c41c9653dc426aa30c17c785d2489f2a /tests | |
| parent | 8ec0cae371a0b392b81bf34d5ee849c233ebbf65 (diff) | |
Indexing of entries
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/data/simple/items/085682ed-6792-499d-a3ab-9aebd683c011.yaml | 2 | ||||
| -rw-r--r-- | tests/test_collection.py | 23 | 
2 files changed, 24 insertions, 1 deletions
| 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) | 
