Test Failed
Pull Request — master (#277)
by Gleyberson
01:32
created

tests.unit.commands.test_web_parser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 71.88 %

Importance

Changes 0
Metric Value
eloc 21
dl 23
loc 32
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A TestWebParser.test_call() 9 9 1
A TestWebParser.test_parse() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

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):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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