diff options
| author | John Estabrook <jestabro@vyos.io> | 2026-11-02 13:29:16 -0600 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2026-11-03 07:31:49 -0600 |
| commit | a609f58fc0882ee2fc63ff6edd29fa4bef08c60f (patch) | |
| tree | a417ceb59a932fba597524d0b618583b58e751eb /src | |
| parent | 4ca0e76fc452aed8c0cb65dc983ba7cd91f10e96 (diff) | |
| download | vyos-1x-a609f58fc0882ee2fc63ff6edd29fa4bef08c60f.tar.gz vyos-1x-a609f58fc0882ee2fc63ff6edd29fa4bef08c60f.zip | |
T9562: add unitest to check argument of is_* path attribute functions.
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) |
