diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-11-03 16:32:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-03 16:32:42 +0100 |
| commit | a100a7f62325beac2c9c3a75778bca09da3e9d08 (patch) | |
| tree | 6191d03622eb150c26c602bf57411b8cd1294cc3 /src | |
| parent | 6fe3f483aafe9ac27cd45791dde574f1b4a8b0b7 (diff) | |
| parent | a609f58fc0882ee2fc63ff6edd29fa4bef08c60f (diff) | |
| download | vyos-1x-a100a7f62325beac2c9c3a75778bca09da3e9d08.tar.gz vyos-1x-a100a7f62325beac2c9c3a75778bca09da3e9d08.zip | |
Merge pull request #5622 from jestabro/fix-call-get-level
T9562: Fix typo in vyos.config passing method instead of function value in is_multi/is_tag/is_leaf
Diffstat (limited to 'src')
| -rw-r--r-- | src/tests/test_config.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/tests/test_config.py b/src/tests/test_config.py new file mode 100644 index 000000000..331938a56 --- /dev/null +++ b/src/tests/test_config.py @@ -0,0 +1,45 @@ +# 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/>. + +from unittest import TestCase +from unittest.mock import MagicMock + +from vyos.config import Config +from vyos.configsource import ConfigSourceSession + + +class TestPathAttrFunc(TestCase): + def _call_func(self, func_name): + mock_config_source = MagicMock(spec=ConfigSourceSession) + mock_config_source.get_configtree_tuple.return_value = (None, None) + config = Config(config_source=mock_config_source) + + func = getattr(config, func_name) + func(['some', 'path']) + mock_config_source.set_level.assert_called_once() + + args, _ = mock_config_source.set_level.call_args + return args[0] + + def test_is_multi_level_arg(self): + res = self._call_func('is_multi') + self.assertEqual(type(res), list) + + def test_is_tag_level_arg(self): + res = self._call_func('is_tag') + self.assertEqual(type(res), list) + + def test_is_leaf_level_arg(self): + res = self._call_func('is_leaf') + self.assertEqual(type(res), list) |
