Code Duplication    Length = 21-22 lines in 2 locations

tests/unit/tracing/test_trace_manager.py 2 locations

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