summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2019-02-14 23:57:59 +0100
committerDaniil Baturin <daniil@baturin.org>2019-02-14 23:57:59 +0100
commit80a96d620bdf47ba0b3e109f3789a9777a2eb6ba (patch)
treeb52bf6162160a5acab381505b20e606c9bb48042 /src
parent1842fc9fdbcfa877e42714eaf620dff18ff9859c (diff)
downloadvyos-1x-80a96d620bdf47ba0b3e109f3789a9777a2eb6ba.tar.gz
vyos-1x-80a96d620bdf47ba0b3e109f3789a9777a2eb6ba.zip
[vyos.configtree] T1248: add a function for node copying
Also improve sanity checks in the rename function and add unit tests for copy and rename.
Diffstat (limited to 'src')
-rw-r--r--src/tests/test_config_parser.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tests/test_config_parser.py b/src/tests/test_config_parser.py
index f58ff23bf..e47770a7f 100644
--- a/src/tests/test_config_parser.py
+++ b/src/tests/test_config_parser.py
@@ -41,3 +41,21 @@ class TestConfigParser(TestCase):
self.assertTrue(self.config.exists(["top-level-tag-node"]))
# No sorting is intentional, child order must be preserved
self.assertEqual(self.config.list_nodes(["top-level-tag-node"]), ["foo", "bar"])
+
+ def test_copy(self):
+ self.config.copy(["top-level-tag-node", "bar"], ["top-level-tag-node", "baz"])
+ print(self.config.to_string())
+ self.assertTrue(self.config.exists(["top-level-tag-node", "baz"]))
+
+ def test_copy_duplicate(self):
+ with self.assertRaises(vyos.configtree.ConfigTreeError):
+ self.config.copy(["top-level-tag-node", "foo"], ["top-level-tag-node", "bar"])
+
+ def test_rename(self):
+ self.config.rename(["top-level-tag-node", "bar"], "quux")
+ print(self.config.to_string())
+ self.assertTrue(self.config.exists(["top-level-tag-node", "quux"]))
+
+ def test_rename_duplicate(self):
+ with self.assertRaises(vyos.configtree.ConfigTreeError):
+ self.config.rename(["top-level-tag-node", "foo"], "bar")