summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2026-05-28 08:40:57 -0500
committerGitHub <noreply@github.com>2026-05-28 08:40:57 -0500
commitd4bb72161387132475e68c9186419f0384c28b32 (patch)
tree2642e3042134e5d45dc888bac7fb3bfa27500f81 /src/tests
parent07410437cde7b1df74cf62343a47549051279f08 (diff)
parent8aa9fe5d526e3a7432959e60216ca3363bde90fb (diff)
downloadvyos-1x-d4bb72161387132475e68c9186419f0384c28b32.tar.gz
vyos-1x-d4bb72161387132475e68c9186419f0384c28b32.zip
Merge pull request #5169 from jestabro/exclusive-mask-config-sync
T8502: Add exclusion mask to config-sync
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_config_tree.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/tests/test_config_tree.py b/src/tests/test_config_tree.py
new file mode 100644
index 000000000..d6339c570
--- /dev/null
+++ b/src/tests/test_config_tree.py
@@ -0,0 +1,48 @@
+# Copyright (C) VyOS Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#
+
+import json
+import unittest
+from unittest import TestCase
+
+from vyos.configtree import ConfigTree
+from vyos.referencetree import ReferenceTree
+from vyos.derivedtree import subtree_from_list_of_partial_paths
+
+
+class TestInitialSetup(TestCase):
+ def setUp(self):
+ with open('data/config.boot.default') as f:
+ config_str = f.read()
+ self.ct = ConfigTree(config_str)
+
+ def test_subtree_from_partial(self):
+ reftree = ReferenceTree(cache_file='data/reftree.cache')
+
+ # workaround since configtree.list_nodes does not take an empty path
+ d = json.loads(self.ct.to_json())
+ top_nodes = list(d)
+ paths = [s.split() for s in top_nodes]
+
+ reassemble = subtree_from_list_of_partial_paths(
+ self.ct, paths, reference_tree=reftree
+ )
+
+ self.assertEqual(self.ct, reassemble)
+
+
+if __name__ == '__main__':
+ unittest.main()