blob: 331938a564888fc449c275346bcdf1494f9d3b87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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)
|