aboutsummaryrefslogtreecommitdiff
path: root/tests/test_collection.py
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-10-28 11:52:26 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-10-28 11:52:26 +0100
commit1dee2ede32b1fcf47640cfc24e26e04e533146c0 (patch)
tree6aeaec2eb59e1b1f931792dec570d97662d77cb9 /tests/test_collection.py
parent68e43fd418e800700f71cf6cde9a413259d5a486 (diff)
Improve round trip loading of yaml files
Diffstat (limited to 'tests/test_collection.py')
-rw-r--r--tests/test_collection.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py
index f7ddf6d..bbc35ba 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -153,12 +153,6 @@ class testSimpleCollection(unittest.TestCase):
self.collection.update_cache()
self.assertIsNotNone(self.collection.stemmer)
- def test_load_safe(self):
- # Simply run the code with self.collection.safe = True to check
- # that it doesn't break.
- self.collection.safe = True
- self.collection.update_cache()
-
def test_full_search(self):
self.collection.start_search('Item')
res = self.collection.get_all_search_results()
@@ -321,6 +315,23 @@ class testComplexCollection(unittest.TestCase):
for f in to_test:
self.assertIsInstance(self.collection.fields[f[0]], f[1])
+ def test_comments_are_preserved(self):
+ e = self.collection.entry_from_eid('5084bc6e94f24dc6976629282ef30419')
+ yaml_data = e.yaml_data
+ self.assertTrue(
+ yaml_data.startswith("# This entry has a comment at the beginning")
+ )
+ self.assertTrue(
+ yaml_data.endswith("# and a comment at the end\n")
+ )
+
+ def test_data_is_stored_as_written_on_file(self):
+ e = self.collection.entry_from_eid('5084bc6e94f24dc6976629282ef30419')
+ fname = 'tests/data/complex/items/' + \
+ '5084bc6e94f24dc6976629282ef30419.yaml'
+ with open(fname, 'r') as fp:
+ self.assertEqual(e.yaml_data, fp.read())
+
class testCollectionWithErrors(unittest.TestCase):
def setUp(self):