Code Duplication    Length = 29-29 lines in 2 locations

tests/test_models.py 1 location

@@ 406-434 (lines=29) @@
403
        }
404
        self.assertEqual(expected_flow_mod, flow_mod)
405
406
    def test_prepare_push_flow(self):
407
        """Test prepare push flow method."""
408
        attributes = {
409
            "name": "custom_name",
410
            "uni_a": get_uni_mocked(interface_port=1, is_valid=True),
411
            "uni_z": get_uni_mocked(interface_port=2, is_valid=True),
412
        }
413
        evc = EVC(**attributes)
414
        interface_a = evc.uni_a.interface
415
        interface_z = evc.uni_z.interface
416
        in_vlan_a = 10
417
        out_vlan_a = 20
418
        in_vlan_z = 3
419
        flow_mod = evc.prepare_push_flow(interface_a, interface_z,
420
                                         in_vlan_a, out_vlan_a, in_vlan_z)
421
        expected_flow_mod = {
422
            'match': {'in_port': interface_a.port_number,
423
                      'dl_vlan': in_vlan_a
424
                      },
425
            'actions': [
426
                        {'action_type': 'set_vlan', 'vlan_id': in_vlan_z},
427
                        {'action_type': 'push_vlan', 'tag_type': 's'},
428
                        {'action_type': 'set_vlan', 'vlan_id': out_vlan_a},
429
                        {'action_type': 'output',
430
                         'port': interface_z.port_number
431
                         }
432
            ]
433
        }
434
        self.assertEqual(expected_flow_mod, flow_mod)
435
436
    @staticmethod
437
    @patch('napps.kytos.mef_eline.models.EVC.send_flow_mods')

tests/models/test_evc_deploy.py 1 location

@@ 135-163 (lines=29) @@
132
        }
133
        self.assertEqual(expected_flow_mod, flow_mod)
134
135
    def test_prepare_push_flow(self):
136
        """Test prepare push flow method."""
137
        attributes = {
138
            "name": "custom_name",
139
            "uni_a": get_uni_mocked(interface_port=1, is_valid=True),
140
            "uni_z": get_uni_mocked(interface_port=2, is_valid=True),
141
        }
142
        evc = EVC(**attributes)
143
        interface_a = evc.uni_a.interface
144
        interface_z = evc.uni_z.interface
145
        in_vlan_a = 10
146
        out_vlan_a = 20
147
        in_vlan_z = 3
148
        flow_mod = evc.prepare_push_flow(interface_a, interface_z,
149
                                         in_vlan_a, out_vlan_a, in_vlan_z)
150
        expected_flow_mod = {
151
            'match': {'in_port': interface_a.port_number,
152
                      'dl_vlan': in_vlan_a
153
                      },
154
            'actions': [
155
                        {'action_type': 'set_vlan', 'vlan_id': in_vlan_z},
156
                        {'action_type': 'push_vlan', 'tag_type': 's'},
157
                        {'action_type': 'set_vlan', 'vlan_id': out_vlan_a},
158
                        {'action_type': 'output',
159
                         'port': interface_z.port_number
160
                         }
161
            ]
162
        }
163
        self.assertEqual(expected_flow_mod, flow_mod)
164
165
    @staticmethod
166
    @patch('napps.kytos.mef_eline.models.EVC.send_flow_mods')