diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/data/complex/items/5084bc6e94f24dc6976629282ef30419.yaml | 15 | ||||
| -rw-r--r-- | tests/test_collection.py | 23 | 
2 files changed, 32 insertions, 6 deletions
| diff --git a/tests/data/complex/items/5084bc6e94f24dc6976629282ef30419.yaml b/tests/data/complex/items/5084bc6e94f24dc6976629282ef30419.yaml new file mode 100644 index 0000000..874833e --- /dev/null +++ b/tests/data/complex/items/5084bc6e94f24dc6976629282ef30419.yaml @@ -0,0 +1,15 @@ +# This entry has a comment at the beginning +name: 'A commented entry' +# ruamel.yaml does not support preserving indent levels, so please leave the +# description indented by two spaces. +description: | +  An entry with comments in the yaml data +position: 'there' +# There is a comment above something +something: +tags: [] +keywords: [] +exists: true +with_default: default value +amount: 1 +# and a comment at the end 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): | 
