Code Duplication    Length = 21-22 lines in 2 locations

tests/unit/tracing/test_trace_manager.py 2 locations

@@ 132-153 (lines=22) @@
129
        entry = self.trace_manager.is_entry_valid(entries)
130
        assert entry.dpid == "00:00:00:00:00:00:00:01"
131
132
    @patch("napps.amlight.sdntrace.shared.colors.Colors.get_switch_color")
133
    def test_new_trace(self, mock_colors):
134
        """Test trace manager new trace creation."""
135
        mock_colors.return_value = {
136
            "color_field": "dl_src",
137
            "color_value": "ee:ee:ee:ee:ee:01",
138
        }
139
140
        eth = {"dl_vlan": 100}
141
        dpid = {"dpid": "00:00:00:00:00:00:00:01", "in_port": 1}
142
        switch = {"switch": dpid, "eth": eth}
143
        entries = {"trace": switch}
144
145
        trace_entries = self.trace_manager.is_entry_valid(entries)
146
        assert isinstance(trace_entries, TraceEntries)
147
148
        trace_id = self.trace_manager.new_trace(trace_entries)
149
        assert trace_id == 30001
150
151
        # new_trace does not check duplicated request.
152
        trace_id = self.trace_manager.new_trace(trace_entries)
153
        assert trace_id == 30002
154
155
    def test_get_id(self):
156
        """Test trace manager ID control."""
@@ 265-285 (lines=21) @@
262
        assert result["request"]["trace"]["switch"]["dpid"] == "00:00:00:00:00:00:00:01"
263
        assert result["request"]["trace"]["switch"]["in_port"] == 1
264
265
    @patch("napps.amlight.sdntrace.shared.colors.Colors.get_switch_color")
266
    def test_duplicated_request(self, mock_colors):
267
        """Test trace manager new trace creation."""
268
        mock_colors.return_value = {
269
            "color_field": "dl_src",
270
            "color_value": "ee:ee:ee:ee:ee:01",
271
        }
272
273
        eth = {"dl_vlan": 100}
274
        dpid = {"dpid": "00:00:00:00:00:00:00:01", "in_port": 1}
275
        switch = {"switch": dpid, "eth": eth}
276
        entries = {"trace": switch}
277
278
        trace_entries = self.trace_manager.is_entry_valid(entries)
279
        assert isinstance(trace_entries, TraceEntries)
280
281
        trace_id = self.trace_manager.new_trace(trace_entries)
282
        assert trace_id == 30001
283
284
        duplicated = self.trace_manager.avoid_duplicated_request(trace_entries)
285
        assert duplicated is True
286
287
    @patch("napps.amlight.sdntrace.shared.colors.Colors.get_switch_color")
288
    def test_avoid_duplicated_request(self, mock_colors):