Passed
Pull Request — master (#184)
by Gleyberson
03:03
created

build.tests.unit.models.test_evc_deploy   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 559
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 405
dl 0
loc 559
rs 10
c 0
b 0
f 0
wmc 16

16 Methods

Rating   Name   Duplication   Size   Complexity  
A TestEVC.test_prepare_pop_flow() 0 27 1
A TestEVC.test_prepare_push_flow() 0 35 1
B TestEVC.test_deploy_successfully() 0 53 1
B TestEVC.test_deploy_fail() 0 51 1
A TestEVC.test_should_deploy_case1() 0 15 1
B TestEVC.test_remove_current_flows() 0 48 1
A TestEVC.test_send_flow_mods_case1() 0 14 1
A TestEVC.test_send_flow_mods_case2() 0 14 1
A TestEVC.test_prepare_flow_mod() 0 26 1
A TestEVC.test_install_nni_flows() 0 56 1
A TestEVC.test_should_deploy_case4() 0 15 1
A TestEVC.test_primary_links_zipped() 0 2 1
A TestEVC.test_should_deploy_case2() 0 15 1
B TestEVC.test_deploy_without_path_case1() 0 53 1
A TestEVC.test_should_deploy_case3() 0 15 1
B TestEVC.test_install_uni_flows() 0 83 1
1
"""Method to thest EVCDeploy class."""
2
import sys
3
from unittest import TestCase
4
from unittest.mock import Mock, patch
5
6
from kytos.core.interface import Interface
7
from kytos.core.switch import Switch
8
9
# pylint: disable=wrong-import-position
10
sys.path.insert(0, '/var/lib/kytos/napps/..')
11
# pylint: enable=wrong-import-position
12
13
from napps.kytos.mef_eline.models import EVC, Path  # NOQA
14
from napps.kytos.mef_eline.settings import MANAGER_URL  # NOQA
15
from tests.helpers import get_link_mocked,\
16
    get_uni_mocked, get_controller_mock  # NOQA
17
18
19
class TestEVC(TestCase):  # pylint: disable=too-many-public-methods
20
    """Tests to verify EVC class."""
21
22
    def test_primary_links_zipped(self):
23
        """Test primary links zipped method."""
24
25
    @staticmethod
26
    @patch('napps.kytos.mef_eline.models.log')
27
    def test_should_deploy_case1(log_mock):
28
        """Test should deploy method without primary links."""
29
        log_mock.debug.return_value = True
30
        attributes = {
31
            "controller": get_controller_mock(),
32
            "name": "custom_name",
33
            "uni_a": get_uni_mocked(is_valid=True),
34
            "uni_z": get_uni_mocked(is_valid=True)
35
        }
36
37
        evc = EVC(**attributes)
38
        evc.should_deploy()
39
        log_mock.debug.assert_called_with('Path is empty.')
40
41
    @patch('napps.kytos.mef_eline.models.log')
42
    def test_should_deploy_case2(self, log_mock):
43
        """Test should deploy method with disable circuit."""
44
        log_mock.debug.return_value = True
45
        attributes = {
46
            "controller": get_controller_mock(),
47
            "name": "custom_name",
48
            "uni_a": get_uni_mocked(is_valid=True),
49
            "uni_z": get_uni_mocked(is_valid=True),
50
            "primary_links": [get_link_mocked(), get_link_mocked()]
51
        }
52
        evc = EVC(**attributes)
53
54
        self.assertFalse(evc.should_deploy(attributes['primary_links']))
55
        log_mock.debug.assert_called_with(f'{evc} is disabled.')
56
57
    @patch('napps.kytos.mef_eline.models.log')
58
    def test_should_deploy_case3(self, log_mock):
59
        """Test should deploy method with enabled and not active circuit."""
60
        log_mock.debug.return_value = True
61
        attributes = {
62
            "controller": get_controller_mock(),
63
            "name": "custom_name",
64
            "uni_a": get_uni_mocked(is_valid=True),
65
            "uni_z": get_uni_mocked(is_valid=True),
66
            "primary_links": [get_link_mocked(), get_link_mocked()],
67
            "enabled": True
68
        }
69
        evc = EVC(**attributes)
70
        self.assertTrue(evc.should_deploy(attributes['primary_links']))
71
        log_mock.debug.assert_called_with(f'{evc} will be deployed.')
72
73
    @patch('napps.kytos.mef_eline.models.log')
74
    def test_should_deploy_case4(self, log_mock):
75
        """Test should deploy method with enabled and active circuit."""
76
        log_mock.debug.return_value = True
77
        attributes = {
78
            "controller": get_controller_mock(),
79
            "name": "custom_name",
80
            "uni_a": get_uni_mocked(is_valid=True),
81
            "uni_z": get_uni_mocked(is_valid=True),
82
            "primary_links": [get_link_mocked(), get_link_mocked()],
83
            "enabled": True,
84
            "active": True
85
        }
86
        evc = EVC(**attributes)
87
        self.assertFalse(evc.should_deploy(attributes['primary_links']))
88
89
    @patch('napps.kytos.mef_eline.models.requests')
90
    def test_send_flow_mods_case1(self, requests_mock):
91
        """Test if you are sending flow_mods."""
92
        flow_mods = {"id": 20}
93
        switch = Mock(spec=Switch, id=1)
94
95
        # pylint: disable=protected-access
96
        EVC._send_flow_mods(switch, flow_mods)
97
98
        expected_endpoint = f"{MANAGER_URL}/flows/{switch.id}"
99
        expected_data = {"flows": flow_mods}
100
        self.assertEqual(requests_mock.post.call_count, 1)
101
        requests_mock.post.assert_called_once_with(expected_endpoint,
102
                                                   json=expected_data)
103
104
    @patch('napps.kytos.mef_eline.models.requests')
105
    def test_send_flow_mods_case2(self, requests_mock):
106
        """Test if you are sending flow_mods."""
107
        flow_mods = {"id": 20}
108
        switch = Mock(spec=Switch, id=1)
109
110
        # pylint: disable=protected-access
111
        EVC._send_flow_mods(switch, flow_mods, command='delete')
112
113
        expected_endpoint = f"{MANAGER_URL}/delete/{switch.id}"
114
        expected_data = {"flows": flow_mods}
115
        self.assertEqual(requests_mock.post.call_count, 1)
116
        requests_mock.post.assert_called_once_with(expected_endpoint,
117
                                                   json=expected_data)
118
119
    def test_prepare_flow_mod(self):
120
        """Test prepare flow_mod method."""
121
        interface_a = Interface('eth0', 1, Mock(spec=Switch))
122
        interface_z = Interface('eth1', 3, Mock(spec=Switch))
123
        attributes = {
124
            "controller": get_controller_mock(),
125
            "name": "custom_name",
126
            "uni_a": get_uni_mocked(is_valid=True),
127
            "uni_z": get_uni_mocked(is_valid=True),
128
            "primary_links": [get_link_mocked(), get_link_mocked()],
129
            "enabled": True,
130
            "active": True
131
        }
132
        evc = EVC(**attributes)
133
134
        # pylint: disable=protected-access
135
        flow_mod = evc._prepare_flow_mod(interface_a, interface_z)
136
        expected_flow_mod = {
137
                           'match': {'in_port': interface_a.port_number},
138
                           'cookie': evc.get_cookie(),
139
                           'actions': [
140
                                       {'action_type': 'output',
141
                                        'port': interface_z.port_number}
142
                           ]
143
        }
144
        self.assertEqual(expected_flow_mod, flow_mod)
145
146
    def test_prepare_pop_flow(self):
147
        """Test prepare pop flow  method."""
148
        attributes = {
149
            "controller": get_controller_mock(),
150
            "name": "custom_name",
151
            "uni_a": get_uni_mocked(interface_port=1, is_valid=True),
152
            "uni_z": get_uni_mocked(interface_port=2, is_valid=True),
153
        }
154
        evc = EVC(**attributes)
155
        interface_a = evc.uni_a.interface
156
        interface_z = evc.uni_z.interface
157
        in_vlan = 10
158
159
        # pylint: disable=protected-access
160
        flow_mod = evc._prepare_pop_flow(interface_a, interface_z, in_vlan)
161
162
        expected_flow_mod = {
163
            'match': {'in_port': interface_a.port_number, 'dl_vlan': in_vlan},
164
            'cookie': evc.get_cookie(),
165
            'actions': [
166
                        {'action_type': 'pop_vlan'},
167
                        {'action_type': 'output',
168
                         'port': interface_z.port_number
169
                         }
170
            ]
171
        }
172
        self.assertEqual(expected_flow_mod, flow_mod)
173
174
    def test_prepare_push_flow(self):
175
        """Test prepare push flow method."""
176
        attributes = {
177
            "controller": get_controller_mock(),
178
            "name": "custom_name",
179
            "uni_a": get_uni_mocked(interface_port=1, is_valid=True),
180
            "uni_z": get_uni_mocked(interface_port=2, is_valid=True),
181
        }
182
        evc = EVC(**attributes)
183
        interface_a = evc.uni_a.interface
184
        interface_z = evc.uni_z.interface
185
        in_vlan_a = 10
186
        out_vlan_a = 20
187
        in_vlan_z = 3
188
189
        # pylint: disable=protected-access
190
        flow_mod = evc._prepare_push_flow(interface_a, interface_z,
191
                                          in_vlan_a, out_vlan_a,
192
                                          in_vlan_z)
193
194
        expected_flow_mod = {
195
            'match': {'in_port': interface_a.port_number,
196
                      'dl_vlan': in_vlan_a
197
                      },
198
            'cookie': evc.get_cookie(),
199
            'actions': [
200
                        {'action_type': 'set_vlan', 'vlan_id': in_vlan_z},
201
                        {'action_type': 'push_vlan', 'tag_type': 's'},
202
                        {'action_type': 'set_vlan', 'vlan_id': out_vlan_a},
203
                        {'action_type': 'output',
204
                         'port': interface_z.port_number
205
                         }
206
            ]
207
        }
208
        self.assertEqual(expected_flow_mod, flow_mod)
209
210
    @staticmethod
211
    @patch('napps.kytos.mef_eline.models.EVC._send_flow_mods')
212
    def test_install_uni_flows(send_flow_mods_mock):
213
        """Test install uni flows method.
214
215
        This test will verify the flows send to the send_flow_mods method.
216
        """
217
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
218
                               switch_id="switch_uni_a", is_valid=True)
219
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
220
                               switch_id="switch_uni_z", is_valid=True)
221
222
        attributes = {
223
            "controller": get_controller_mock(),
224
            "name": "custom_name",
225
            "uni_a": uni_a,
226
            "uni_z": uni_z,
227
            "primary_links": [
228
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
229
                                metadata={"s_vlan": 5}),
230
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
231
                                metadata={"s_vlan": 6})
232
            ]
233
        }
234
        evc = EVC(**attributes)
235
236
        # pylint: disable=protected-access
237
        evc._install_uni_flows(attributes['primary_links'])
238
239
        expected_flow_mod_a = [
240
            {'match': {'in_port': uni_a.interface.port_number,
241
                       'dl_vlan': uni_a.user_tag.value},
242
             'cookie': evc.get_cookie(),
243
             'actions': [
244
                {'action_type': 'set_vlan', 'vlan_id': uni_z.user_tag.value},
245
                {'action_type': 'push_vlan', 'tag_type': 's'},
246
                {'action_type': 'set_vlan',
247
                 'vlan_id': evc.primary_links[0].get_metadata('s_vlan').value},
248
                {'action_type': 'output',
249
                 'port': evc.primary_links[0].endpoint_a.port_number}
250
             ]},
251
            {'match': {
252
                'in_port': evc.primary_links[0].endpoint_a.port_number,
253
                'dl_vlan': evc.primary_links[0].get_metadata('s_vlan').value
254
             },
255
             'cookie': evc.get_cookie(),
256
             'actions': [
257
                {'action_type': 'pop_vlan'},
258
                {'action_type': 'output', 'port': uni_a.interface.port_number}
259
             ]
260
             }
261
        ]
262
        send_flow_mods_mock.assert_any_call(uni_a.interface.switch,
263
                                            expected_flow_mod_a)
264
265
        expected_flow_mod_z = [
266
            {'match': {'in_port': uni_z.interface.port_number,
267
                       'dl_vlan': uni_z.user_tag.value},
268
             'cookie': evc.get_cookie(),
269
             'actions': [
270
                {'action_type': 'set_vlan', 'vlan_id': uni_a.user_tag.value},
271
                {'action_type': 'push_vlan', 'tag_type': 's'},
272
                {'action_type': 'set_vlan',
273
                 'vlan_id': evc.primary_links[-1].get_metadata('s_vlan').value
274
                 },
275
                {'action_type': 'output',
276
                 'port': evc.primary_links[-1].endpoint_b.port_number}
277
              ]
278
             },
279
            {'match': {
280
                 'in_port': evc.primary_links[-1].endpoint_b.port_number,
281
                 'dl_vlan': evc.primary_links[-1].get_metadata('s_vlan').value
282
             },
283
             'cookie': evc.get_cookie(),
284
             'actions': [
285
                {'action_type': 'pop_vlan'},
286
                {'action_type': 'output', 'port': uni_z.interface.port_number}
287
              ]
288
             }
289
        ]
290
291
        send_flow_mods_mock.assert_any_call(uni_z.interface.switch,
292
                                            expected_flow_mod_z)
293
294
    @staticmethod
295
    @patch('napps.kytos.mef_eline.models.EVC._send_flow_mods')
296
    def test_install_nni_flows(send_flow_mods_mock):
297
        """Test install nni flows method.
298
299
        This test will verify the flows send to the send_flow_mods method.
300
        """
301
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
302
                               switch_id="switch_uni_a", is_valid=True)
303
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
304
                               switch_id="switch_uni_z", is_valid=True)
305
306
        attributes = {
307
            "controller": get_controller_mock(),
308
            "name": "custom_name",
309
            "uni_a": uni_a,
310
            "uni_z": uni_z,
311
            "primary_links": [
312
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
313
                                metadata={"s_vlan": 5}),
314
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
315
                                metadata={"s_vlan": 6})
316
            ]
317
        }
318
        evc = EVC(**attributes)
319
320
        # pylint: disable=protected-access
321
        evc._install_nni_flows(attributes['primary_links'])
322
323
        in_vlan = evc.primary_links[0].get_metadata('s_vlan').value
324
        out_vlan = evc.primary_links[-1].get_metadata('s_vlan').value
325
326
        in_port = evc.primary_links[0].endpoint_b.port_number
327
        out_port = evc.primary_links[-1].endpoint_a.port_number
328
329
        expected_flow_mods = [
330
            {
331
             'match': {'in_port': in_port, 'dl_vlan': in_vlan},
332
             'cookie': evc.get_cookie(),
333
             'actions': [
334
                    {'action_type': 'set_vlan', 'vlan_id': out_vlan},
335
                    {'action_type': 'output', 'port': out_port}
336
                ]
337
             },
338
            {
339
             'match': {'in_port': out_port, 'dl_vlan': out_vlan},
340
             'cookie': evc.get_cookie(),
341
             'actions': [
342
                {'action_type': 'set_vlan', 'vlan_id': in_vlan},
343
                {'action_type': 'output', 'port': in_port}
344
              ]
345
             }
346
        ]
347
348
        switch = evc.primary_links[0].endpoint_b.switch
349
        send_flow_mods_mock.assert_called_once_with(switch, expected_flow_mods)
350
351
    @patch('napps.kytos.mef_eline.models.log')
352
    @patch('napps.kytos.mef_eline.models.Path.choose_vlans')
353
    @patch('napps.kytos.mef_eline.models.EVC._install_nni_flows')
354
    @patch('napps.kytos.mef_eline.models.EVC._install_uni_flows')
355
    @patch('napps.kytos.mef_eline.models.EVC.activate')
356
    @patch('napps.kytos.mef_eline.models.EVC.should_deploy')
357
    def test_deploy_successfully(self, *args):
358
        """Test if all methods to deploy are called."""
359
        # pylint: disable=too-many-locals
360
        (should_deploy_mock, activate_mock,
361
         install_uni_flows_mock, install_nni_flows, chose_vlans_mock,
362
         log_mock) = args
363
364
        should_deploy_mock.return_value = True
365
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
366
                               switch_id="switch_uni_a", is_valid=True)
367
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
368
                               switch_id="switch_uni_z", is_valid=True)
369
370
        primary_links = [
371
            get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
372
                            metadata={"s_vlan": 5}),
373
            get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
374
                            metadata={"s_vlan": 6})
375
        ]
376
377
        attributes = {
378
            "controller": get_controller_mock(),
379
            "name": "custom_name",
380
            "uni_a": uni_a,
381
            "uni_z": uni_z,
382
            "primary_links": primary_links
383
        }
384
        # Setup path to deploy
385
        path = Path()
386
        path.append(primary_links[0])
387
        path.append(primary_links[1])
388
389
        evc = EVC(**attributes)
390
391
        # storehouse mock
392
        evc._storehouse.box = Mock()  # pylint: disable=protected-access
393
        evc._storehouse.box.data = {}  # pylint: disable=protected-access
394
395
        deployed = evc.deploy_to_path(path)
396
397
        self.assertEqual(should_deploy_mock.call_count, 1)
398
        self.assertEqual(activate_mock.call_count, 1)
399
        self.assertEqual(install_uni_flows_mock.call_count, 1)
400
        self.assertEqual(install_nni_flows.call_count, 1)
401
        self.assertEqual(chose_vlans_mock.call_count, 1)
402
        log_mock.info.assert_called_with(f"{evc} was deployed.")
403
        self.assertTrue(deployed)
404
405
    @patch('napps.kytos.mef_eline.models.log')
406
    @patch('napps.kytos.mef_eline.models.EVC.discover_new_path',
407
           return_value=None)
408
    @patch('napps.kytos.mef_eline.models.Path.choose_vlans')
409
    @patch('napps.kytos.mef_eline.models.EVC._install_nni_flows')
410
    @patch('napps.kytos.mef_eline.models.EVC._install_uni_flows')
411
    @patch('napps.kytos.mef_eline.models.EVC.activate')
412
    @patch('napps.kytos.mef_eline.models.EVC.should_deploy',
413
           return_value=False)
414
    @patch('napps.kytos.mef_eline.models.EVC.sync')
415
    def test_deploy_fail(self, *args):
416
        """Test if all methods is ignored when the should_deploy is false."""
417
        # pylint: disable=too-many-locals
418
        (sync_mock, should_deploy_mock, activate_mock, install_uni_flows_mock,
419
         install_nni_flows, chose_vlans_mock,
420
         discover_new_path, log_mock) = args
421
422
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
423
                               switch_id="switch_uni_a",
424
                               switch_dpid="switch_dpid_uni_a",
425
                               is_valid=True)
426
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
427
                               switch_id="switch_uni_z",
428
                               switch_dpid="switch_dpid_uni_a",
429
                               is_valid=True)
430
431
        attributes = {
432
            "controller": get_controller_mock(),
433
            "name": "custom_name",
434
            "uni_a": uni_a,
435
            "uni_z": uni_z,
436
            "primary_links": [
437
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
438
                                metadata={"s_vlan": 5}),
439
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
440
                                metadata={"s_vlan": 6})
441
            ]
442
        }
443
444
        evc = EVC(**attributes)
445
        deployed = evc.deploy_to_path()
446
447
        self.assertEqual(discover_new_path.call_count, 1)
448
        self.assertEqual(should_deploy_mock.call_count, 1)
449
        self.assertEqual(activate_mock.call_count, 0)
450
        self.assertEqual(install_uni_flows_mock.call_count, 0)
451
        self.assertEqual(install_nni_flows.call_count, 0)
452
        self.assertEqual(chose_vlans_mock.call_count, 0)
453
        self.assertEqual(log_mock.info.call_count, 0)
454
        self.assertEqual(sync_mock.call_count, 1)
455
        self.assertFalse(deployed)
456
457
    @patch('napps.kytos.mef_eline.models.log')
458
    @patch('napps.kytos.mef_eline.models.Path.choose_vlans')
459
    @patch('napps.kytos.mef_eline.models.EVC._install_nni_flows')
460
    @patch('napps.kytos.mef_eline.models.EVC._install_uni_flows')
461
    @patch('napps.kytos.mef_eline.models.EVC.activate')
462
    @patch('napps.kytos.mef_eline.models.EVC.should_deploy')
463
    @patch('napps.kytos.mef_eline.models.EVC.discover_new_path')
464
    def test_deploy_without_path_case1(self, *args):
465
        """Test if not path is found a dynamic path is used."""
466
        # pylint: disable=too-many-locals
467
        (discover_new_path_mocked, should_deploy_mock, activate_mock,
468
         install_uni_flows_mock, install_nni_flows, chose_vlans_mock,
469
         log_mock) = args
470
471
        should_deploy_mock.return_value = False
472
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
473
                               switch_id="switch_uni_a", is_valid=True)
474
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
475
                               switch_id="switch_uni_z", is_valid=True)
476
477
        attributes = {
478
            "controller": get_controller_mock(),
479
            "name": "custom_name",
480
            "uni_a": uni_a,
481
            "uni_z": uni_z,
482
            "enabled": True,
483
            "dynamic_backup_path": True
484
        }
485
486
        dynamic_backup_path = Path([
487
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
488
                                metadata={"s_vlan": 5}),
489
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
490
                                metadata={"s_vlan": 6})
491
        ])
492
493
        evc = EVC(**attributes)
494
        discover_new_path_mocked.return_value = dynamic_backup_path
495
496
        # storehouse initialization mock
497
        evc._storehouse.box = Mock()  # pylint: disable=protected-access
498
        evc._storehouse.box.data = {}  # pylint: disable=protected-access
499
500
        deployed = evc.deploy_to_path()
501
502
        self.assertEqual(should_deploy_mock.call_count, 1)
503
        self.assertEqual(discover_new_path_mocked.call_count, 1)
504
        self.assertEqual(activate_mock.call_count, 1)
505
        self.assertEqual(install_uni_flows_mock.call_count, 1)
506
        self.assertEqual(install_nni_flows.call_count, 1)
507
        self.assertEqual(chose_vlans_mock.call_count, 1)
508
        log_mock.info.assert_called_with(f"{evc} was deployed.")
509
        self.assertTrue(deployed)
510
511
    @patch('napps.kytos.mef_eline.models.EVC._send_flow_mods')
512
    def test_remove_current_flows(self, send_flow_mods_mocked):
513
        """Test remove current flows."""
514
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
515
                               switch_id="switch_uni_a", is_valid=True)
516
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
517
                               switch_id="switch_uni_z", is_valid=True)
518
519
        switch_a = Switch('00:00:00:00:00:01')
520
        switch_b = Switch('00:00:00:00:00:02')
521
        switch_c = Switch('00:00:00:00:00:03')
522
523
        attributes = {
524
            "controller": get_controller_mock(),
525
            "name": "custom_name",
526
            "uni_a": uni_a,
527
            "uni_z": uni_z,
528
            "active": True,
529
            "enabled": True,
530
            "primary_links": [
531
                get_link_mocked(switch_a=switch_a,
532
                                switch_b=switch_b,
533
                                endpoint_a_port=9, endpoint_b_port=10,
534
                                metadata={"s_vlan": 5}),
535
                get_link_mocked(switch_a=switch_b,
536
                                switch_b=switch_c,
537
                                endpoint_a_port=11, endpoint_b_port=12,
538
                                metadata={"s_vlan": 6})
539
            ]
540
        }
541
542
        evc = EVC(**attributes)
543
544
        # storehouse initialization mock
545
        evc._storehouse.box = Mock()  # pylint: disable=protected-access
546
        evc._storehouse.box.data = {}  # pylint: disable=protected-access
547
548
        evc.current_path = evc.primary_links
549
        evc.remove_current_flows()
550
551
        self.assertEqual(send_flow_mods_mocked.call_count, 3)
552
        self.assertFalse(evc.is_active())
553
        flows = [{'cookie': evc.get_cookie(),
554
                 'cookie_mask': 18446744073709551615}]
555
        switch_1 = evc.primary_links[0].endpoint_a.switch
556
        switch_2 = evc.primary_links[0].endpoint_b.switch
557
        send_flow_mods_mocked.assert_any_call(switch_1, flows, 'delete')
558
        send_flow_mods_mocked.assert_any_call(switch_2, flows, 'delete')
559