Code Duplication    Length = 21-21 lines in 2 locations

tests/unit/tracing/test_trace_manager.py 1 location

@@ 55-75 (lines=21) @@
52
        """Clean up after each test method"""
53
        self.trace_manager.stop_traces()
54
55
    @classmethod
56
    def create_basic_switches(cls, controller):
57
        """Create basic mock switches for Kytos controller."""
58
        dpid_a = "00:00:00:00:00:00:00:01"
59
        dpid_b = "00:00:00:00:00:00:00:02"
60
61
        mock_switch_a = get_switch_mock(dpid_a, 0x04)
62
        mock_switch_b = get_switch_mock(dpid_b, 0x04)
63
        mock_interface_a = get_interface_mock("s1-eth1", 1, mock_switch_a)
64
        mock_interface_b = get_interface_mock("s2-eth1", 1, mock_switch_b)
65
66
        mock_link = get_link_mock(mock_interface_a, mock_interface_b)
67
        mock_link.id = "cf0f4071be4"
68
        mock_switch_a.id = dpid_a
69
        mock_switch_a.as_dict.return_value = {"metadata": {}}
70
        mock_switch_b.id = dpid_b
71
        mock_switch_b.as_dict.return_value = {"metadata": {}}
72
73
        controller.switches = {dpid_a: mock_switch_a, dpid_b: mock_switch_b}
74
75
        Switches(MagicMock())._switches = controller.switches
76
77
    def test_is_entry_invalid(self):
78
        """Test if the entry request does not have a valid switch."""

tests/unit/tracing/test_trace_pkt.py 1 location

@@ 48-68 (lines=21) @@
45
        """Set up before each test method"""
46
        self.create_basic_switches(get_controller_mock())
47
48
    @classmethod
49
    def create_basic_switches(cls, controller):
50
        """Create basic mock switches for Kytos controller."""
51
        dpid_a = "00:00:00:00:00:00:00:01"
52
        dpid_b = "00:00:00:00:00:00:00:02"
53
54
        mock_switch_a = get_switch_mock(dpid_a, 0x04)
55
        mock_switch_b = get_switch_mock(dpid_b, 0x04)
56
        mock_interface_a = get_interface_mock("s1-eth1", 1, mock_switch_a)
57
        mock_interface_b = get_interface_mock("s2-eth1", 1, mock_switch_b)
58
59
        mock_link = get_link_mock(mock_interface_a, mock_interface_b)
60
        mock_link.id = "cf0f4071be4"
61
        mock_switch_a.id = dpid_a
62
        mock_switch_a.as_dict.return_value = {"metadata": {}}
63
        mock_switch_b.id = dpid_b
64
        mock_switch_b.as_dict.return_value = {"metadata": {}}
65
66
        controller.switches = {dpid_a: mock_switch_a, dpid_b: mock_switch_b}
67
68
        Switches(MagicMock())._switches = controller.switches
69
70
    @patch("napps.amlight.sdntrace.shared.extd_nw_types.randrange")
71
    def test_generate_trace_pkt_tcp(self, mock_rand):