Test Failed
Pull Request — master (#225)
by Antonio
03:11
created

TestEVC.test_prepare_push_flow()   A

Complexity

Conditions 4

Size

Total Lines 37
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 27
nop 1
dl 0
loc 37
rs 9.232
c 0
b 0
f 0
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,
161
                                         None, in_vlan)
162
163
        expected_flow_mod = {
164
            'match': {'in_port': interface_a.port_number, 'dl_vlan': in_vlan},
165
            'cookie': evc.get_cookie(),
166
            'actions': [
167
                        {'action_type': 'pop_vlan'},
168
                        {'action_type': 'output',
169
                         'port': interface_z.port_number
170
                         }
171
            ]
172
        }
173
        self.assertEqual(expected_flow_mod, flow_mod)
174
175
    def test_prepare_push_flow(self):
176
        """Test prepare push flow method."""
177
        attributes = {
178
            "controller": get_controller_mock(),
179
            "name": "custom_name",
180
            "uni_a": get_uni_mocked(interface_port=1, is_valid=True),
181
            "uni_z": get_uni_mocked(interface_port=2, is_valid=True),
182
        }
183
        evc = EVC(**attributes)
184
        interface_a = evc.uni_a.interface
185
        interface_z = evc.uni_z.interface
186
        out_vlan_a = 20
187
188
        for in_vlan_a in (10, None):
189
            with self.subTest(in_vlan_a=in_vlan_a):
190
                # pylint: disable=protected-access
191
                flow_mod = evc._prepare_push_flow(interface_a, interface_z,
192
                                                  in_vlan_a, out_vlan_a)
193
194
                expected_flow_mod = {
195
                    'match': {'in_port': interface_a.port_number},
196
                    'cookie': evc.get_cookie(),
197
                    'actions': [
198
                        {'action_type': 'push_vlan', 'tag_type': 's'},
199
                        {'action_type': 'set_vlan', 'vlan_id': out_vlan_a},
200
                        {
201
                            'action_type': 'output',
202
                            'port': interface_z.port_number
203
                        }
204
                    ]
205
                }
206
                if in_vlan_a:
207
                    expected_flow_mod['match']['dl_vlan'] = in_vlan_a
208
                    expected_flow_mod['actions'].insert(0, {
209
                        'action_type': 'pop_vlan'
210
                    })
211
                self.assertEqual(expected_flow_mod, flow_mod)
212
213
    @staticmethod
214
    @patch('napps.kytos.mef_eline.models.EVC._send_flow_mods')
215
    def test_install_uni_flows(send_flow_mods_mock):
216
        """Test install uni flows method.
217
218
        This test will verify the flows send to the send_flow_mods method.
219
        """
220
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
221
                               switch_id="switch_uni_a", is_valid=True)
222
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
223
                               switch_id="switch_uni_z", is_valid=True)
224
225
        attributes = {
226
            "controller": get_controller_mock(),
227
            "name": "custom_name",
228
            "uni_a": uni_a,
229
            "uni_z": uni_z,
230
            "primary_links": [
231
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
232
                                metadata={"s_vlan": 5}),
233
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
234
                                metadata={"s_vlan": 6})
235
            ]
236
        }
237
        evc = EVC(**attributes)
238
239
        # pylint: disable=protected-access
240
        evc._install_uni_flows(attributes['primary_links'])
241
242
        expected_flow_mod_a = [
243
            {'match': {'in_port': uni_a.interface.port_number,
244
                       'dl_vlan': uni_a.user_tag.value},
245
             'cookie': evc.get_cookie(),
246
             'actions': [
247
                {'action_type': 'pop_vlan'},
248
                {'action_type': 'push_vlan', 'tag_type': 's'},
249
                {'action_type': 'set_vlan',
250
                 'vlan_id': evc.primary_links[0].get_metadata('s_vlan').value},
251
                {'action_type': 'output',
252
                 'port': evc.primary_links[0].endpoint_a.port_number}
253
             ]},
254
            {'match': {
255
                'in_port': evc.primary_links[0].endpoint_a.port_number,
256
                'dl_vlan': evc.primary_links[0].get_metadata('s_vlan').value
257
             },
258
             'cookie': evc.get_cookie(),
259
             'actions': [
260
                {'action_type': 'pop_vlan'},
261
                {'action_type': 'push_vlan', 'tag_type': 'c'},
262
                {'action_type': 'set_vlan', 'vlan_id': uni_a.user_tag.value},
263
                {'action_type': 'output', 'port': uni_a.interface.port_number}
264
             ]
265
             }
266
        ]
267
268
        send_flow_mods_mock.assert_any_call(uni_a.interface.switch,
269
                                            expected_flow_mod_a)
270
271
        expected_flow_mod_z = [
272
            {'match': {'in_port': uni_z.interface.port_number,
273
                       'dl_vlan': uni_z.user_tag.value},
274
             'cookie': evc.get_cookie(),
275
             'actions': [
276
                {'action_type': 'pop_vlan'},
277
                {'action_type': 'push_vlan', 'tag_type': 's'},
278
                {'action_type': 'set_vlan',
279
                 'vlan_id': evc.primary_links[-1].get_metadata('s_vlan').value
280
                 },
281
                {'action_type': 'output',
282
                 'port': evc.primary_links[-1].endpoint_b.port_number}
283
              ]
284
             },
285
            {'match': {
286
                 'in_port': evc.primary_links[-1].endpoint_b.port_number,
287
                 'dl_vlan': evc.primary_links[-1].get_metadata('s_vlan').value
288
             },
289
             'cookie': evc.get_cookie(),
290
             'actions': [
291
                {'action_type': 'pop_vlan'},
292
                {'action_type': 'push_vlan', 'tag_type': 'c'},
293
                {'action_type': 'set_vlan', 'vlan_id': uni_z.user_tag.value},
294
                {'action_type': 'output', 'port': uni_z.interface.port_number}
295
              ]
296
             }
297
        ]
298
299
        send_flow_mods_mock.assert_any_call(uni_z.interface.switch,
300
                                            expected_flow_mod_z)
301
302
    @staticmethod
303
    @patch('napps.kytos.mef_eline.models.EVC._send_flow_mods')
304
    def test_install_nni_flows(send_flow_mods_mock):
305
        """Test install nni flows method.
306
307
        This test will verify the flows send to the send_flow_mods method.
308
        """
309
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
310
                               switch_id="switch_uni_a", is_valid=True)
311
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
312
                               switch_id="switch_uni_z", is_valid=True)
313
314
        attributes = {
315
            "controller": get_controller_mock(),
316
            "name": "custom_name",
317
            "uni_a": uni_a,
318
            "uni_z": uni_z,
319
            "primary_links": [
320
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
321
                                metadata={"s_vlan": 5}),
322
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
323
                                metadata={"s_vlan": 6})
324
            ]
325
        }
326
        evc = EVC(**attributes)
327
328
        # pylint: disable=protected-access
329
        evc._install_nni_flows(attributes['primary_links'])
330
331
        in_vlan = evc.primary_links[0].get_metadata('s_vlan').value
332
        out_vlan = evc.primary_links[-1].get_metadata('s_vlan').value
333
334
        in_port = evc.primary_links[0].endpoint_b.port_number
335
        out_port = evc.primary_links[-1].endpoint_a.port_number
336
337
        expected_flow_mods = [
338
            {
339
             'match': {'in_port': in_port, 'dl_vlan': in_vlan},
340
             'cookie': evc.get_cookie(),
341
             'actions': [
342
                    {'action_type': 'set_vlan', 'vlan_id': out_vlan},
343
                    {'action_type': 'output', 'port': out_port}
344
                ]
345
             },
346
            {
347
             'match': {'in_port': out_port, 'dl_vlan': out_vlan},
348
             'cookie': evc.get_cookie(),
349
             'actions': [
350
                {'action_type': 'set_vlan', 'vlan_id': in_vlan},
351
                {'action_type': 'output', 'port': in_port}
352
              ]
353
             }
354
        ]
355
356
        switch = evc.primary_links[0].endpoint_b.switch
357
        send_flow_mods_mock.assert_called_once_with(switch, expected_flow_mods)
358
359
    @patch('requests.post')
360
    @patch('napps.kytos.mef_eline.models.log')
361
    @patch('napps.kytos.mef_eline.models.Path.choose_vlans')
362
    @patch('napps.kytos.mef_eline.models.EVC._install_nni_flows')
363
    @patch('napps.kytos.mef_eline.models.EVC._install_uni_flows')
364
    @patch('napps.kytos.mef_eline.models.EVC.activate')
365
    @patch('napps.kytos.mef_eline.models.EVC.should_deploy')
366
    def test_deploy_successfully(self, *args):
367
        """Test if all methods to deploy are called."""
368
        # pylint: disable=too-many-locals
369
        (should_deploy_mock, activate_mock,
370
         install_uni_flows_mock, install_nni_flows, chose_vlans_mock,
371
         log_mock, _) = args
372
373
        should_deploy_mock.return_value = True
374
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
375
                               switch_id="switch_uni_a", is_valid=True)
376
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
377
                               switch_id="switch_uni_z", is_valid=True)
378
379
        primary_links = [
380
            get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
381
                            metadata={"s_vlan": 5}),
382
            get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
383
                            metadata={"s_vlan": 6})
384
        ]
385
386
        attributes = {
387
            "controller": get_controller_mock(),
388
            "name": "custom_name",
389
            "uni_a": uni_a,
390
            "uni_z": uni_z,
391
            "primary_links": primary_links
392
        }
393
        # Setup path to deploy
394
        path = Path()
395
        path.append(primary_links[0])
396
        path.append(primary_links[1])
397
398
        evc = EVC(**attributes)
399
400
        # storehouse mock
401
        evc._storehouse.box = Mock()  # pylint: disable=protected-access
402
        evc._storehouse.box.data = {}  # pylint: disable=protected-access
403
404
        deployed = evc.deploy_to_path(path)
405
406
        self.assertEqual(should_deploy_mock.call_count, 1)
407
        self.assertEqual(activate_mock.call_count, 1)
408
        self.assertEqual(install_uni_flows_mock.call_count, 1)
409
        self.assertEqual(install_nni_flows.call_count, 1)
410
        self.assertEqual(chose_vlans_mock.call_count, 1)
411
        log_mock.info.assert_called_with(f"{evc} was deployed.")
412
        self.assertTrue(deployed)
413
414
    @patch('requests.post')
415
    @patch('napps.kytos.mef_eline.models.log')
416
    @patch('napps.kytos.mef_eline.models.EVC.discover_new_paths',
417
           return_value=[])
418
    @patch('napps.kytos.mef_eline.models.Path.choose_vlans')
419
    @patch('napps.kytos.mef_eline.models.EVC._install_nni_flows')
420
    @patch('napps.kytos.mef_eline.models.EVC._install_uni_flows')
421
    @patch('napps.kytos.mef_eline.models.EVC.activate')
422
    @patch('napps.kytos.mef_eline.models.EVC.should_deploy',
423
           return_value=False)
424
    @patch('napps.kytos.mef_eline.models.EVC.sync')
425
    def test_deploy_fail(self, *args):
426
        """Test if all methods is ignored when the should_deploy is false."""
427
        # pylint: disable=too-many-locals
428
        (sync_mock, should_deploy_mock, activate_mock, install_uni_flows_mock,
429
         install_nni_flows, choose_vlans_mock,
430
         discover_new_paths, log_mock, _) = args
431
432
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
433
                               switch_id="switch_uni_a",
434
                               switch_dpid="switch_dpid_uni_a",
435
                               is_valid=True)
436
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
437
                               switch_id="switch_uni_z",
438
                               switch_dpid="switch_dpid_uni_a",
439
                               is_valid=True)
440
441
        attributes = {
442
            "controller": get_controller_mock(),
443
            "name": "custom_name",
444
            "uni_a": uni_a,
445
            "uni_z": uni_z,
446
            "primary_links": [
447
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
448
                                metadata={"s_vlan": 5}),
449
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
450
                                metadata={"s_vlan": 6})
451
            ]
452
        }
453
454
        evc = EVC(**attributes)
455
        deployed = evc.deploy_to_path()
456
457
        self.assertEqual(discover_new_paths.call_count, 1)
458
        self.assertEqual(should_deploy_mock.call_count, 1)
459
        self.assertEqual(activate_mock.call_count, 0)
460
        self.assertEqual(install_uni_flows_mock.call_count, 0)
461
        self.assertEqual(install_nni_flows.call_count, 0)
462
        self.assertEqual(choose_vlans_mock.call_count, 0)
463
        self.assertEqual(log_mock.info.call_count, 0)
464
        self.assertEqual(sync_mock.call_count, 1)
465
        self.assertFalse(deployed)
466
467
    @patch('requests.post')
468
    @patch('napps.kytos.mef_eline.models.log')
469
    @patch('napps.kytos.mef_eline.models.Path.choose_vlans')
470
    @patch('napps.kytos.mef_eline.models.EVC._install_nni_flows')
471
    @patch('napps.kytos.mef_eline.models.EVC._install_uni_flows')
472
    @patch('napps.kytos.mef_eline.models.EVC.activate')
473
    @patch('napps.kytos.mef_eline.models.EVC.should_deploy')
474
    @patch('napps.kytos.mef_eline.models.EVC.discover_new_paths')
475
    def test_deploy_without_path_case1(self, *args):
476
        """Test if not path is found a dynamic path is used."""
477
        # pylint: disable=too-many-locals
478
        (discover_new_paths_mocked, should_deploy_mock, activate_mock,
479
         install_uni_flows_mock, install_nni_flows, chose_vlans_mock,
480
         log_mock, _) = args
481
482
        should_deploy_mock.return_value = False
483
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
484
                               switch_id="switch_uni_a", is_valid=True)
485
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
486
                               switch_id="switch_uni_z", is_valid=True)
487
488
        attributes = {
489
            "controller": get_controller_mock(),
490
            "name": "custom_name",
491
            "uni_a": uni_a,
492
            "uni_z": uni_z,
493
            "enabled": True,
494
            "dynamic_backup_path": True
495
        }
496
497
        dynamic_backup_path = Path([
498
                get_link_mocked(endpoint_a_port=9, endpoint_b_port=10,
499
                                metadata={"s_vlan": 5}),
500
                get_link_mocked(endpoint_a_port=11, endpoint_b_port=12,
501
                                metadata={"s_vlan": 6})
502
        ])
503
504
        evc = EVC(**attributes)
505
        discover_new_paths_mocked.return_value = [dynamic_backup_path]
506
507
        # storehouse initialization mock
508
        evc._storehouse.box = Mock()  # pylint: disable=protected-access
509
        evc._storehouse.box.data = {}  # pylint: disable=protected-access
510
511
        deployed = evc.deploy_to_path()
512
513
        self.assertEqual(should_deploy_mock.call_count, 1)
514
        self.assertEqual(discover_new_paths_mocked.call_count, 1)
515
        self.assertEqual(activate_mock.call_count, 1)
516
        self.assertEqual(install_uni_flows_mock.call_count, 1)
517
        self.assertEqual(install_nni_flows.call_count, 1)
518
        self.assertEqual(chose_vlans_mock.call_count, 1)
519
        log_mock.info.assert_called_with(f"{evc} was deployed.")
520
        self.assertTrue(deployed)
521
522
    @patch('napps.kytos.mef_eline.models.EVC._send_flow_mods')
523
    def test_remove_current_flows(self, send_flow_mods_mocked):
524
        """Test remove current flows."""
525
        uni_a = get_uni_mocked(interface_port=2, tag_value=82,
526
                               switch_id="switch_uni_a", is_valid=True)
527
        uni_z = get_uni_mocked(interface_port=3, tag_value=83,
528
                               switch_id="switch_uni_z", is_valid=True)
529
530
        switch_a = Switch('00:00:00:00:00:01')
531
        switch_b = Switch('00:00:00:00:00:02')
532
        switch_c = Switch('00:00:00:00:00:03')
533
534
        attributes = {
535
            "controller": get_controller_mock(),
536
            "name": "custom_name",
537
            "uni_a": uni_a,
538
            "uni_z": uni_z,
539
            "active": True,
540
            "enabled": True,
541
            "primary_links": [
542
                get_link_mocked(switch_a=switch_a,
543
                                switch_b=switch_b,
544
                                endpoint_a_port=9, endpoint_b_port=10,
545
                                metadata={"s_vlan": 5}),
546
                get_link_mocked(switch_a=switch_b,
547
                                switch_b=switch_c,
548
                                endpoint_a_port=11, endpoint_b_port=12,
549
                                metadata={"s_vlan": 6})
550
            ]
551
        }
552
553
        evc = EVC(**attributes)
554
555
        # storehouse initialization mock
556
        evc._storehouse.box = Mock()  # pylint: disable=protected-access
557
        evc._storehouse.box.data = {}  # pylint: disable=protected-access
558
559
        evc.current_path = evc.primary_links
560
        evc.remove_current_flows()
561
562
        self.assertEqual(send_flow_mods_mocked.call_count, 5)
563
        self.assertFalse(evc.is_active())
564
        flows = [{'cookie': evc.get_cookie(),
565
                 'cookie_mask': 18446744073709551615}]
566
        switch_1 = evc.primary_links[0].endpoint_a.switch
567
        switch_2 = evc.primary_links[0].endpoint_b.switch
568
        send_flow_mods_mocked.assert_any_call(switch_1, flows, 'delete')
569
        send_flow_mods_mocked.assert_any_call(switch_2, flows, 'delete')
570