diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-01-04 13:54:17 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-01-04 13:54:17 (GMT) |
commit | 4b54747c0ee3736591b3fb38b156837b0958b1cc (patch) | |
tree | 618a8454446f4f8f25aa5f7817c72bbcc706ae4d /tests | |
parent | aded4e75efc21319d5a777bf53bc087587f0740c (diff) |
Stuck to the Yaml specifications a little bit more.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/plugins/yamlrdr.py | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/tests/plugins/yamlrdr.py b/tests/plugins/yamlrdr.py index e09bb21..47f02ba 100644 --- a/tests/plugins/yamlrdr.py +++ b/tests/plugins/yamlrdr.py @@ -99,27 +99,35 @@ root: f.close() - def XXXtestSimpleYamlContent(self): + def testSimpleYamlContent(self): """Validate Yaml content readers.""" def _build_node_desc(node, left, extra = ''): - line = node.yaml_line + if hasattr(node, 'key'): + + line = node.yaml_line - if line: prefix = '- ' if line.is_list_item else extra desc = left + prefix + line.key + ':' + (' ' + line.value if line.value else '') + '\n' indent = ' ' + + collec = node.collection + else: + desc = '' indent = '' - if node.collection: + if hasattr(node, 'nodes'): + collec = node + + if collec: - if node.collection.is_sequence: + if collec.is_sequence: extra = ' ' - for child in node.collection.nodes: + for child in collec.nodes: desc += _build_node_desc(child, left + indent, extra) return desc @@ -158,7 +166,7 @@ root: self.assertEqual('\n' + fulldesc + '\n', self._mixed_data.decode('ascii')) - def XXXtestSimpleYamlContentFinder(self): + def testSimpleYamlContentFinder(self): """Validate Yaml nested content search.""" reader = YamlReader.new_from_path(self._nested.name) @@ -169,7 +177,7 @@ root: self.assertEqual(len(found), 1) if len(found) == 1: - self.assertEqual(found[0].yaml_line.key, 'sub') + self.assertEqual(found[0].key, 'sub') found = reader.tree.find_by_path('/root/sub/') @@ -184,7 +192,7 @@ root: self.assertEqual(len(found), 1) if len(found) == 1: - self.assertEqual(found[0].yaml_line.key, 'i') + self.assertEqual(found[0].key, 'i') self.assertEqual(found[0].yaml_line.is_list_item, True) found = reader.tree.find_by_path('/root/sub/cc') @@ -201,7 +209,7 @@ root: if len(found) == 1: - self.assertEqual(found[0].yaml_line.key, 'i') + self.assertEqual(found[0].key, 'i') self.assertEqual(found[0].yaml_line.is_list_item, True) found = root.find_by_path('/cc/i') @@ -210,7 +218,7 @@ root: if len(found) == 1: - self.assertEqual(found[0].yaml_line.key, 'i') + self.assertEqual(found[0].key, 'i') self.assertEqual(found[0].yaml_line.is_list_item, True) found = root.find_by_path('//i') @@ -219,7 +227,7 @@ root: if len(found) == 1: - self.assertEqual(found[0].yaml_line.key, 'i') + self.assertEqual(found[0].key, 'i') self.assertEqual(found[0].yaml_line.is_list_item, True) @@ -234,7 +242,7 @@ root: self.assertEqual(len(found), 1) if len(found) == 1: - self.assertEqual(found[0].yaml_line.key, 'root') + self.assertEqual(found[0].key, 'root') found = reader.tree.find_by_path('/root/', True) @@ -248,11 +256,11 @@ root: sub = found.find_one_by_path('/a') self.assertIsNotNone(sub) - self.assertEqual(sub.yaml_line.key, 'a') + self.assertEqual(sub.key, 'a') sub = found.find_one_by_path('/aa') self.assertIsNotNone(sub) - self.assertEqual(sub.yaml_line.key, 'aa') + self.assertEqual(sub.key, 'aa') found = reader.tree.find_by_path('/root/') @@ -262,8 +270,8 @@ root: sub = found[0].find_one_by_path('/a') self.assertIsNotNone(sub) - self.assertEqual(sub.yaml_line.key, 'a') + self.assertEqual(sub.key, 'a') sub = found[0].find_one_by_path('/aa') self.assertIsNotNone(sub) - self.assertEqual(sub.yaml_line.key, 'aa') + self.assertEqual(sub.key, 'aa') |