@@ 10-45 (lines=36) @@ | ||
7 | from kytos.utils.exceptions import KytosException |
|
8 | ||
9 | ||
10 | class TestWebParser(unittest.TestCase): |
|
11 | """Test the WebAPI parser methods.""" |
|
12 | ||
13 | @staticmethod |
|
14 | @patch('kytos.cli.commands.web.parser.call') |
|
15 | @patch('kytos.cli.commands.web.parser.docopt', return_value='args') |
|
16 | def test_parse(*args): |
|
17 | """Test parse method.""" |
|
18 | (_, mock_call) = args |
|
19 | with patch.object(sys, 'argv', ['A', 'B', 'C']): |
|
20 | parse('argv') |
|
21 | ||
22 | mock_call.assert_called_with('C', 'args') |
|
23 | ||
24 | @staticmethod |
|
25 | @patch('sys.exit') |
|
26 | @patch('kytos.cli.commands.web.parser.call') |
|
27 | @patch('kytos.cli.commands.web.parser.docopt', return_value='args') |
|
28 | def test_parse__error(*args): |
|
29 | """Test parse method to error case.""" |
|
30 | (_, mock_call, mock_exit) = args |
|
31 | mock_call.side_effect = KytosException |
|
32 | with patch.object(sys, 'argv', ['A', 'B', 'C']): |
|
33 | parse('argv') |
|
34 | ||
35 | mock_exit.assert_called() |
|
36 | ||
37 | @staticmethod |
|
38 | @patch('kytos.cli.commands.web.api.WebAPI.update') |
|
39 | @patch('kytos.utils.config.KytosConfig') |
|
40 | def test_call(*args): |
|
41 | """Test call method.""" |
|
42 | (_, mock_web_api) = args |
|
43 | call('update', 'args') |
|
44 | ||
45 | mock_web_api.assert_called_with('args') |
|
46 |
@@ 10-45 (lines=36) @@ | ||
7 | from kytos.utils.exceptions import KytosException |
|
8 | ||
9 | ||
10 | class TestUsersParser(unittest.TestCase): |
|
11 | """Test the UsersAPI parser methods.""" |
|
12 | ||
13 | @staticmethod |
|
14 | @patch('kytos.cli.commands.users.parser.call') |
|
15 | @patch('kytos.cli.commands.users.parser.docopt', return_value='args') |
|
16 | def test_parse(*args): |
|
17 | """Test parse method.""" |
|
18 | (_, mock_call) = args |
|
19 | with patch.object(sys, 'argv', ['A', 'B', 'C']): |
|
20 | parse('argv') |
|
21 | ||
22 | mock_call.assert_called_with('C', 'args') |
|
23 | ||
24 | @staticmethod |
|
25 | @patch('sys.exit') |
|
26 | @patch('kytos.cli.commands.users.parser.call') |
|
27 | @patch('kytos.cli.commands.users.parser.docopt', return_value='args') |
|
28 | def test_parse__error(*args): |
|
29 | """Test parse method to error case.""" |
|
30 | (_, mock_call, mock_exit) = args |
|
31 | mock_call.side_effect = KytosException |
|
32 | with patch.object(sys, 'argv', ['A', 'B', 'C']): |
|
33 | parse('argv') |
|
34 | ||
35 | mock_exit.assert_called() |
|
36 | ||
37 | @staticmethod |
|
38 | @patch('kytos.cli.commands.users.api.UsersAPI.register') |
|
39 | @patch('kytos.utils.config.KytosConfig') |
|
40 | def test_call(*args): |
|
41 | """Test call method.""" |
|
42 | (_, mock_users_api) = args |
|
43 | call('register', 'args') |
|
44 | ||
45 | mock_users_api.assert_called_with('args') |
|
46 |