aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-08-05 17:06:22 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-08-05 17:06:22 +0200
commitba79c95627a0a650721d73cddaf43be6a89bc6c6 (patch)
treedae272b1060652f6ce5185313e59cba5a6a2789e /tests
parent15ae1a931e51f96b644c7003d6420bbddffbc2e1 (diff)
parentc2885894c06e15a5be0b6a00edd8e0de7746b4a9 (diff)
Merge branch 'master' into tellico
Diffstat (limited to 'tests')
-rw-r--r--tests/test_collection.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py
index 891a439..869828a 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -87,6 +87,14 @@ class testCollection(unittest.TestCase):
matches = list(self.collection.get_all_search_results())
self.assertEqual(matches, [])
+ def test_all_entries(self):
+ self.collection = lesana.Collection('tests/data/simple')
+ res = self.collection.get_all_documents()
+ matches = list(res)
+ self.assertEqual(len(matches), 3)
+ for m in matches:
+ self.assertIsInstance(m, lesana.Entry)
+
def test_entry_from_uid(self):
self.collection = lesana.Collection('tests/data/simple')
entry = self.collection.entry_from_uid(
@@ -188,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