Code Duplication    Length = 21-21 lines in 3 locations

tests/unit/tracing/test_trace_manager.py 1 location

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

tests/unit/tracing/test_tracer.py 1 location

@@ 50-70 (lines=21) @@
47
        self.create_basic_switches(get_controller_mock())
48
        self.trace_manager = TraceManager(controller=get_controller_mock())
49
50
    @classmethod
51
    def create_basic_switches(cls, controller):
52
        """Create basic mock switches for Kytos controller."""
53
        dpid_a = "00:00:00:00:00:00:00:01"
54
        dpid_b = "00:00:00:00:00:00:00:02"
55
56
        mock_switch_a = get_switch_mock(dpid_a, 0x04)
57
        mock_switch_b = get_switch_mock(dpid_b, 0x04)
58
        mock_interface_a = get_interface_mock("s1-eth1", 1, mock_switch_a)
59
        mock_interface_b = get_interface_mock("s2-eth1", 1, mock_switch_b)
60
61
        mock_link = get_link_mock(mock_interface_a, mock_interface_b)
62
        mock_link.id = "cf0f4071be4"
63
        mock_switch_a.id = dpid_a
64
        mock_switch_a.as_dict.return_value = {"metadata": {}}
65
        mock_switch_b.id = dpid_b
66
        mock_switch_b.as_dict.return_value = {"metadata": {}}
67
68
        controller.switches = {dpid_a: mock_switch_a, dpid_b: mock_switch_b}
69
70
        Switches(controller.switches)
71
72
    @patch("napps.amlight.sdntrace.shared.colors.Colors.get_switch_color")
73
    @patch("napps.amlight.sdntrace.shared.colors.Colors._get_colors")

tests/unit/tracing/test_trace_pkt.py 1 location

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