| Total Complexity | 3 |
| Total Lines | 32 |
| Duplicated Lines | 71.88 % |
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | """kytos.cli.commands.web.parser tests.""" |
||
| 2 | import sys |
||
| 3 | import unittest |
||
| 4 | from unittest.mock import patch |
||
| 5 | |||
| 6 | from kytos.cli.commands.web.parser import call, parse |
||
| 7 | |||
| 8 | |||
| 9 | View Code Duplication | class TestWebParser(unittest.TestCase): |
|
|
|
|||
| 10 | """Test the WebAPI parser methods.""" |
||
| 11 | |||
| 12 | @staticmethod |
||
| 13 | @patch('kytos.cli.commands.web.parser.call') |
||
| 14 | @patch('kytos.cli.commands.web.parser.docopt', return_value='args') |
||
| 15 | def test_parse(*args): |
||
| 16 | """Test parse method.""" |
||
| 17 | (_, mock_call) = args |
||
| 18 | with patch.object(sys, 'argv', ['A', 'B', 'C']): |
||
| 19 | parse('argv') |
||
| 20 | |||
| 21 | mock_call.assert_called_with('C', 'args') |
||
| 22 | |||
| 23 | @staticmethod |
||
| 24 | @patch('kytos.cli.commands.web.api.WebAPI.update') |
||
| 25 | @patch('kytos.utils.config.KytosConfig') |
||
| 26 | def test_call(*args): |
||
| 27 | """Test call method.""" |
||
| 28 | (_, mock_web_api) = args |
||
| 29 | call('update', 'args') |
||
| 30 | |||
| 31 | mock_web_api.assert_called_with('args') |
||
| 32 |