Code Duplication    Length = 22-23 lines in 2 locations

tests/unit/test_main.py 2 locations

@@ 196-218 (lines=23) @@
193
        json_response = json.loads(response.data)
194
        assert len(json_response) == 0
195
196
    @patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id")
197
    def test_bytes_count_per_flow(self, mock_from_flow):
198
        """Test bytes_count_per_flow rest call."""
199
        flow_stats = {
200
            'byte_count': 10,
201
            'duration_sec': 20,
202
            'duration_nsec': 30,
203
            'packet_count': 40
204
            }
205
        flow_id = '6055f13593fad45e0b4699f49d56b105'
206
        flow_stats_dict_mock = {flow_id: flow_stats}
207
        dpid_id = "00:00:00:00:00:00:00:01"
208
        flow_by_sw = {dpid_id: flow_stats_dict_mock}
209
        mock_from_flow.return_value = flow_by_sw
210
211
        rest_name = "bytes_count/per_flow"
212
        self._patch_switch_flow(flow_id)
213
214
        response = self._get_rest_response(rest_name, dpid_id)
215
        json_response = json.loads(response.data)
216
        assert json_response[0]["flow_id"] == flow_id
217
        assert json_response[0]["bytes_counter"] == 10
218
        assert json_response[0]["bits_per_second"] == 4.0
219
220
    @patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id")
221
    def test_flows_counters_packet(self, mock_from_flow):
@@ 165-186 (lines=22) @@
162
        json_response = json.loads(response.data)
163
        assert len(json_response) == 0
164
165
    @patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id")
166
    def test_packet_count_per_flow(self, mock_from_flow):
167
        """Test packet_count_per_flow rest call."""
168
        flow_stats = {
169
            'byte_count': 10,
170
            'duration_sec': 20,
171
            'duration_nsec': 30,
172
            'packet_count': 40
173
            }
174
        flow_id = '6055f13593fad45e0b4699f49d56b105'
175
        flow_stats_dict_mock = {flow_id: flow_stats}
176
        dpid_id = "00:00:00:00:00:00:00:01"
177
        flow_by_sw = {dpid_id: flow_stats_dict_mock}
178
        mock_from_flow.return_value = flow_by_sw
179
180
        rest_name = "packet_count/per_flow"
181
        self._patch_switch_flow(flow_id)
182
        response = self._get_rest_response(rest_name, dpid_id)
183
        json_response = json.loads(response.data)
184
        assert json_response[0]["flow_id"] == flow_id
185
        assert json_response[0]["packet_counter"] == 40
186
        assert json_response[0]["packet_per_second"] == 2.0
187
188
    def test_bytes_count_per_flow__empty(self):
189
        """Test bytes_count rest call with a flow that does not exist ."""