Code Duplication    Length = 77-77 lines in 2 locations

tests/models/test_path.py 1 location

@@ 15-91 (lines=77) @@
12
from napps.kytos.mef_eline.tests.helpers import get_link_mocked  # NOQA
13
14
15
class TestPath(TestCase):
16
    """"Class to test path methods."""
17
18
    def test_status_case_1(self):
19
        """Test if empty link is DISABLED."""
20
        current_path = Path()
21
        self.assertEqual(current_path.status, EntityStatus.DISABLED)
22
23
    def test_status_case_2(self):
24
        """Test if link status is DOWN."""
25
        links = [
26
                 get_link_mocked(status=EntityStatus.DOWN),
27
                 get_link_mocked(status=EntityStatus.UP)
28
        ]
29
        current_path = Path(links)
30
        self.assertEqual(current_path.status, EntityStatus.DOWN)
31
32
    def test_status_case_3(self):
33
        """Test if link status is DISABLED."""
34
        links = [
35
                 get_link_mocked(status=EntityStatus.DISABLED),
36
                 get_link_mocked(status=EntityStatus.UP)
37
        ]
38
        current_path = Path(links)
39
        self.assertEqual(current_path.status, EntityStatus.DISABLED)
40
41
    def test_status_case_4(self):
42
        """Test if link status is UP."""
43
        links = [
44
                 get_link_mocked(status=EntityStatus.UP),
45
                 get_link_mocked(status=EntityStatus.UP)
46
        ]
47
        current_path = Path(links)
48
        self.assertEqual(current_path.status, EntityStatus.UP)
49
50
    def test_compare_same_paths(self):
51
        """Test compare paths with same links."""
52
        links = [
53
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
54
                                metadata={"s_vlan": 5}),
55
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
56
                                metadata={"s_vlan": 6})
57
            ]
58
59
        path_1 = Path(links)
60
        path_2 = Path(links)
61
        self.assertEqual(path_1, path_2)
62
63
    def test_compare_different_paths(self):
64
        """Test compare paths with different links."""
65
        links_1 = [
66
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
67
                                metadata={"s_vlan": 5}),
68
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
69
                                metadata={"s_vlan": 6})
70
            ]
71
        links_2 = [
72
                get_link_mocked(endpoint_a_port=12, endpoint_b_port=11,
73
                                metadata={"s_vlan": 5}),
74
                get_link_mocked(endpoint_a_port=14, endpoint_b_port=16,
75
                                metadata={"s_vlan": 11})
76
            ]
77
78
        path_1 = Path(links_1)
79
        path_2 = Path(links_2)
80
        self.assertNotEqual(path_1, path_2)
81
82
    def test_as_dict(self):
83
        """Test path as dict."""
84
        links = [
85
                get_link_mocked(link_dict={"id": 3}),
86
                get_link_mocked(link_dict={"id": 2})
87
            ]
88
89
        current_path = Path(links)
90
        expected_dict = [{"id": 3}, {"id": 2}]
91
        self.assertEqual(expected_dict, current_path.as_dict())
92
93
94

tests/test_models.py 1 location

@@ 14-90 (lines=77) @@
11
from .helpers import get_link_mocked, get_uni_mocked
12
13
14
class TestPath(TestCase):
15
    """"Class to test path methods."""
16
17
    def test_status_case_1(self):
18
        """Test if empty link is DISABLED."""
19
        current_path = Path()
20
        self.assertEqual(current_path.status, EntityStatus.DISABLED)
21
22
    def test_status_case_2(self):
23
        """Test if link status is DOWN."""
24
        links = [
25
                 get_link_mocked(status=EntityStatus.DOWN),
26
                 get_link_mocked(status=EntityStatus.UP)
27
        ]
28
        current_path = Path(links)
29
        self.assertEqual(current_path.status, EntityStatus.DOWN)
30
31
    def test_status_case_3(self):
32
        """Test if link status is DISABLED."""
33
        links = [
34
                 get_link_mocked(status=EntityStatus.DISABLED),
35
                 get_link_mocked(status=EntityStatus.UP)
36
        ]
37
        current_path = Path(links)
38
        self.assertEqual(current_path.status, EntityStatus.DISABLED)
39
40
    def test_status_case_4(self):
41
        """Test if link status is UP."""
42
        links = [
43
                 get_link_mocked(status=EntityStatus.UP),
44
                 get_link_mocked(status=EntityStatus.UP)
45
        ]
46
        current_path = Path(links)
47
        self.assertEqual(current_path.status, EntityStatus.UP)
48
49
    def test_compare_same_paths(self):
50
        """Test compare paths with same links."""
51
        links = [
52
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
53
                                metadata={"s_vlan": 5}),
54
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
55
                                metadata={"s_vlan": 6})
56
            ]
57
58
        path_1 = Path(links)
59
        path_2 = Path(links)
60
        self.assertEqual(path_1, path_2)
61
62
    def test_compare_different_paths(self):
63
        """Test compare paths with different links."""
64
        links_1 = [
65
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
66
                                metadata={"s_vlan": 5}),
67
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
68
                                metadata={"s_vlan": 6})
69
            ]
70
        links_2 = [
71
                get_link_mocked(endpoint_a_port=12, endpoint_b_port=11,
72
                                metadata={"s_vlan": 5}),
73
                get_link_mocked(endpoint_a_port=14, endpoint_b_port=16,
74
                                metadata={"s_vlan": 11})
75
            ]
76
77
        path_1 = Path(links_1)
78
        path_2 = Path(links_2)
79
        self.assertNotEqual(path_1, path_2)
80
81
    def test_as_dict(self):
82
        """Test path as dict."""
83
        links = [
84
                get_link_mocked(link_dict={"id": 3}),
85
                get_link_mocked(link_dict={"id": 2})
86
            ]
87
88
        current_path = Path(links)
89
        expected_dict = [{"id": 3}, {"id": 2}]
90
        self.assertEqual(expected_dict, current_path.as_dict())
91
92
93
class TestEVC(TestCase):  # pylint: disable=too-many-public-methods