Passed
Push — master ( 0d5b5f...2f9122 )
by
unknown
01:39 queued 12s
created

TestDeployer.test_mw_case_1()   C

Complexity

Conditions 7

Size

Total Lines 90
Code Lines 70

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 44
CRAP Score 7

Importance

Changes 0
Metric Value
cc 7
eloc 70
nop 1
dl 0
loc 90
ccs 44
cts 44
cp 1
crap 7
rs 6.5818
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
"""Tests for the deployer module."""
2
3 1
from unittest import TestCase
4 1
from unittest.mock import MagicMock
5
6 1
from collections import Counter
7
8 1
from datetime import datetime, timedelta
9 1
from threading import Lock
10 1
import pytz
11 1
from kytos.core.common import EntityStatus
12 1
from kytos.lib.helpers import get_controller_mock
13 1
from napps.kytos.maintenance.models import MaintenanceWindow as MW
14
15 1
from napps.kytos.maintenance.managers.deployer import (
16
    MaintenanceDeployer,
17
)
18
19 1
class TestDeployer(TestCase):
20
    """Test of the MaintenanceDeployer class."""
21 1
    def setUp(self):
22 1
        self.controller = get_controller_mock()
23 1
        self.start = datetime.now(pytz.utc)
24 1
        self.start += timedelta(days=1)
25 1
        self.end = self.start + timedelta(hours=6)
26 1
        self.switches = [
27
            "01:23:45:67:89:ab:cd:ef"
28
        ]
29 1
        self.maintenance = MW(
30
            start=self.start,
31
            end=self.end,
32
            switches=self.switches
33
        )
34
35 1
        self.deployer = MaintenanceDeployer(self.controller, Counter(), Counter(), Counter(), Lock())
36
        # Initialize Switches
37 1
        self.controller.switches = {
38
            '01:23:45:67:89:ab:cd:ef': MagicMock(
39
                id='01:23:45:67:89:ab:cd:ef',
40
                interfaces = {},
41
            ),
42
            '01:23:45:67:65:ab:cd:ef': MagicMock(
43
                id='01:23:45:67:65:ab:cd:ef',
44
                interfaces = {},
45
            ),
46
            '01:23:45:67:66:ab:cd:ef': MagicMock(
47
                id='01:23:45:67:66:ab:cd:ef',
48
                interfaces = {},
49
            ),
50
        }
51
        # Initialize Interfaces
52 1
        self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces = {
53
            0: MagicMock(
54
                id = '01:23:45:67:89:ab:cd:ef:0',
55
                switch = self.controller.switches['01:23:45:67:89:ab:cd:ef'],
56
                link = None,
57
            ),
58
            1: MagicMock(
59
                id = '01:23:45:67:89:ab:cd:ef:1',
60
                switch = self.controller.switches['01:23:45:67:89:ab:cd:ef'],
61
                link = None,
62
            ),
63
            2: MagicMock(
64
                id = '01:23:45:67:89:ab:cd:ef:2',
65
                switch = self.controller.switches['01:23:45:67:89:ab:cd:ef'],
66
                link = None,
67
            ),
68
        }
69
70 1
        self.controller.switches['01:23:45:67:65:ab:cd:ef'].interfaces = {
71
            0: MagicMock(
72
                id = '01:23:45:67:65:ab:cd:ef:0',
73
                switch = self.controller.switches['01:23:45:67:65:ab:cd:ef'],
74
                link = None,
75
            ),
76
            1: MagicMock(
77
                id = '01:23:45:67:65:ab:cd:ef:1',
78
                switch = self.controller.switches['01:23:45:67:65:ab:cd:ef'],
79
                link = None,
80
            ),
81
            2: MagicMock(
82
                id = '01:23:45:67:65:ab:cd:ef:2',
83
                switch = self.controller.switches['01:23:45:67:65:ab:cd:ef'],
84
                link = None,
85
            ),
86
        }
87
88 1
        self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces = {
89
            0: MagicMock(
90
                id = '01:23:45:67:66:ab:cd:ef:0',
91
                switch = self.controller.switches['01:23:45:67:66:ab:cd:ef'],
92
                link = None,
93
            ),
94
            1: MagicMock(
95
                id = '01:23:45:67:66:ab:cd:ef:1',
96
                switch = self.controller.switches['01:23:45:67:66:ab:cd:ef'],
97
                link = None,
98
            ),
99
            2: MagicMock(
100
                id = '01:23:45:67:66:ab:cd:ef:2',
101
                switch = self.controller.switches['01:23:45:67:66:ab:cd:ef'],
102
                link = None,
103
            ),
104
        }
105
106
        # Initialize Links
107 1
        self.link_1 = MagicMock(
108
            id = 'link_1',
109
            endpoint_a = self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces[0],
110
            endpoint_b = self.controller.switches['01:23:45:67:65:ab:cd:ef'].interfaces[0],
111
        )
112 1
        self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces[0].link = self.link_1
113 1
        self.controller.switches['01:23:45:67:65:ab:cd:ef'].interfaces[0].link = self.link_1
114
115 1
        self.link_2 = MagicMock(
116
            id = 'link_2',
117
            endpoint_a = self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces[1],
118
            endpoint_b = self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces[0],
119
        )
120 1
        self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces[1].link = self.link_2
121 1
        self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces[0].link = self.link_2
122
123 1
        self.link_3 = MagicMock(
124
            id = 'link_3',
125
            endpoint_a = self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces[1],
126
            endpoint_b = self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces[2],
127
        )
128 1
        self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces[1].link = self.link_3
129 1
        self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces[2].link = self.link_3
130
131
132 1
        self.controller.napps[('kytos', 'topology')] = MagicMock(
133
            links = {
134
                'link_1': self.link_1,
135
                'link_2': self.link_2,
136
                'link_3': self.link_3,
137
            }
138
        )
139
140 1
    def test_mw_case_1(self):
141
        """Test deploying a maintenance window to switches."""
142 1
        buffer_put_mock = MagicMock()
143 1
        self.controller.buffers.app.put = buffer_put_mock
144 1
        maintenance = self.maintenance.copy(
145
            update = {
146
                'switches': [
147
                    '01:23:45:67:89:ab:cd:ef',
148
                    '01:23:45:67:65:ab:cd:ef'
149
                ],
150
                'interfaces': [],
151
                'links': [],
152
            }
153
        )
154 1
        self.deployer.start_mw(maintenance)
155 1
        args, kwargs = buffer_put_mock.call_args
156 1
        event = args[0]
157 1
        assert event.name == 'topology.interruption.start'
158 1
        assert event.content['type'] == 'maintenance'
159 1
        assert sorted(event.content['switches']) == [
160
            '01:23:45:67:65:ab:cd:ef',
161
            '01:23:45:67:89:ab:cd:ef',
162
        ]
163 1
        assert sorted(event.content['interfaces']) == [
164
            '01:23:45:67:65:ab:cd:ef:0',
165
            '01:23:45:67:65:ab:cd:ef:1',
166
            '01:23:45:67:65:ab:cd:ef:2',
167
            '01:23:45:67:89:ab:cd:ef:0',
168
            '01:23:45:67:89:ab:cd:ef:1',
169
            '01:23:45:67:89:ab:cd:ef:2',
170
        ]
171 1
        assert sorted(event.content['links']) == [
172
            'link_1',
173
            'link_2',
174
        ]
175
176
        # Check whats in maintenance
177
        # Switches
178 1
        assert not self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:89:ab:cd:ef'])
179 1
        assert not self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:65:ab:cd:ef'])
180 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:66:ab:cd:ef'])
181
        # Interfaces
182 1
        for interface in self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces.values():
183 1
            assert not self.deployer.interface_not_in_maintenance(interface)
184 1
        for interface in self.controller.switches['01:23:45:67:65:ab:cd:ef'].interfaces.values():
185 1
            assert not self.deployer.interface_not_in_maintenance(interface)
186 1
        for interface in self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces.values():
187 1
            assert     self.deployer.interface_not_in_maintenance(interface)
188
        # Links
189 1
        assert not self.deployer.link_not_in_maintenance(self.link_1)
190 1
        assert not self.deployer.link_not_in_maintenance(self.link_2)
191 1
        assert     self.deployer.link_not_in_maintenance(self.link_3)
192
193 1
        self.deployer.end_mw(maintenance)
194 1
        args, kwargs = buffer_put_mock.call_args
195 1
        event = args[0]
196 1
        assert event.name == 'topology.interruption.end'
197 1
        assert event.content['type'] == 'maintenance'
198 1
        assert sorted(event.content['switches']) == [
199
            '01:23:45:67:65:ab:cd:ef',
200
            '01:23:45:67:89:ab:cd:ef',
201
        ]
202 1
        assert sorted(event.content['interfaces']) == [
203
            '01:23:45:67:65:ab:cd:ef:0',
204
            '01:23:45:67:65:ab:cd:ef:1',
205
            '01:23:45:67:65:ab:cd:ef:2',
206
            '01:23:45:67:89:ab:cd:ef:0',
207
            '01:23:45:67:89:ab:cd:ef:1',
208
            '01:23:45:67:89:ab:cd:ef:2',
209
        ]
210 1
        assert sorted(event.content['links']) == [
211
            'link_1',
212
            'link_2',
213
        ]
214
        # Check whats in maintenance
215
        # Switches
216 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:89:ab:cd:ef'])
217 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:65:ab:cd:ef'])
218 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:66:ab:cd:ef'])
219
        # Interfaces
220 1
        for interface in self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces.values():
221 1
            assert     self.deployer.interface_not_in_maintenance(interface)
222 1
        for interface in self.controller.switches['01:23:45:67:65:ab:cd:ef'].interfaces.values():
223 1
            assert     self.deployer.interface_not_in_maintenance(interface)
224 1
        for interface in self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces.values():
225 1
            assert     self.deployer.interface_not_in_maintenance(interface)
226
        # Links
227 1
        assert     self.deployer.link_not_in_maintenance(self.link_1)
228 1
        assert     self.deployer.link_not_in_maintenance(self.link_2)
229 1
        assert     self.deployer.link_not_in_maintenance(self.link_3)
230
231 1
    def test_mw_case_2(self):
232
        """Test deploying a maintenance window to interfaces."""
233 1
        buffer_put_mock = MagicMock()
234 1
        self.controller.buffers.app.put = buffer_put_mock
235
        
236 1
        maintenance = self.maintenance.copy(
237
            update = {
238
                'switches': [],
239
                'interfaces': [
240
                    '01:23:45:67:65:ab:cd:ef:0',
241
                    '01:23:45:67:89:ab:cd:ef:0',
242
                    '01:23:45:67:89:ab:cd:ef:1',
243
                ],
244
                'links': [],
245
            }
246
        )
247 1
        self.deployer.start_mw(maintenance)
248 1
        args, kwargs = buffer_put_mock.call_args
249 1
        event = args[0]
250 1
        assert event.name == 'topology.interruption.start'
251 1
        assert event.content['type'] == 'maintenance'
252 1
        assert sorted(event.content['switches']) == []
253 1
        assert sorted(event.content['interfaces']) == [
254
            '01:23:45:67:65:ab:cd:ef:0',
255
            '01:23:45:67:89:ab:cd:ef:0',
256
            '01:23:45:67:89:ab:cd:ef:1',
257
        ]
258 1
        assert sorted(event.content['links']) == [
259
            'link_1',
260
            'link_2',
261
        ]
262
263
        # Check whats in maintenance
264
        # Switches
265 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:89:ab:cd:ef'])
266 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:65:ab:cd:ef'])
267 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:66:ab:cd:ef'])
268
        # Interfaces
269
270 1
        assert not self.deployer.interface_not_in_maintenance(self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces[0])
271 1
        assert not self.deployer.interface_not_in_maintenance(self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces[1])
272 1
        assert     self.deployer.interface_not_in_maintenance(self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces[2])
273
274 1
        assert not self.deployer.interface_not_in_maintenance(self.controller.switches['01:23:45:67:65:ab:cd:ef'].interfaces[0])
275 1
        assert     self.deployer.interface_not_in_maintenance(self.controller.switches['01:23:45:67:65:ab:cd:ef'].interfaces[1])
276 1
        assert     self.deployer.interface_not_in_maintenance(self.controller.switches['01:23:45:67:65:ab:cd:ef'].interfaces[2])
277
278 1
        for interface in self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces.values():
279 1
            assert     self.deployer.interface_not_in_maintenance(interface)
280
281
        # Links
282 1
        assert not self.deployer.link_not_in_maintenance(self.link_1)
283 1
        assert not self.deployer.link_not_in_maintenance(self.link_2)
284 1
        assert     self.deployer.link_not_in_maintenance(self.link_3)
285
286 1
        self.deployer.end_mw(maintenance)
287 1
        args, kwargs = buffer_put_mock.call_args
288 1
        event = args[0]
289 1
        assert event.name == 'topology.interruption.end'
290 1
        assert event.content['type'] == 'maintenance'
291 1
        assert sorted(event.content['switches']) == []
292 1
        assert sorted(event.content['switches']) == []
293 1
        assert sorted(event.content['interfaces']) == [
294
            '01:23:45:67:65:ab:cd:ef:0',
295
            '01:23:45:67:89:ab:cd:ef:0',
296
            '01:23:45:67:89:ab:cd:ef:1',
297
        ]
298 1
        assert sorted(event.content['links']) == [
299
            'link_1',
300
            'link_2',
301
        ]
302
        # Check whats in maintenance
303
        # Switches
304 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:89:ab:cd:ef'])
305 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:65:ab:cd:ef'])
306 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:66:ab:cd:ef'])
307
        # Interfaces
308 1
        for interface in self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces.values():
309 1
            assert     self.deployer.interface_not_in_maintenance(interface)
310 1
        for interface in self.controller.switches['01:23:45:67:65:ab:cd:ef'].interfaces.values():
311 1
            assert     self.deployer.interface_not_in_maintenance(interface)
312 1
        for interface in self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces.values():
313 1
            assert     self.deployer.interface_not_in_maintenance(interface)
314
        # Links
315 1
        assert     self.deployer.link_not_in_maintenance(self.link_1)
316 1
        assert     self.deployer.link_not_in_maintenance(self.link_2)
317 1
        assert     self.deployer.link_not_in_maintenance(self.link_3)
318
319 1
    def test_mw_case_3(self):
320
        """Test deploying a maintenance window to links."""
321 1
        buffer_put_mock = MagicMock()
322 1
        self.controller.buffers.app.put = buffer_put_mock
323 1
        maintenance = self.maintenance.copy(
324
            update = {
325
                'switches': [],
326
                'interfaces': [],
327
                'links': ['link_1', 'link_2'],
328
            }
329
        )
330 1
        self.deployer.start_mw(maintenance)
331 1
        args, kwargs = buffer_put_mock.call_args
332 1
        event = args[0]
333 1
        assert event.name == 'topology.interruption.start'
334 1
        assert event.content['type'] == 'maintenance'
335 1
        assert sorted(event.content['switches']) == []
336 1
        assert sorted(event.content['interfaces']) == []
337 1
        assert sorted(event.content['links']) == [
338
            'link_1',
339
            'link_2',
340
        ]
341
342
        # Check whats in maintenance
343
        # Switches
344 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:89:ab:cd:ef'])
345 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:65:ab:cd:ef'])
346 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:66:ab:cd:ef'])
347
        # Interfaces
348 1
        for interface in self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces.values():
349 1
            assert     self.deployer.interface_not_in_maintenance(interface)
350 1
        for interface in self.controller.switches['01:23:45:67:65:ab:cd:ef'].interfaces.values():
351 1
            assert     self.deployer.interface_not_in_maintenance(interface)
352 1
        for interface in self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces.values():
353 1
            assert     self.deployer.interface_not_in_maintenance(interface)
354
        # Links
355 1
        assert not self.deployer.link_not_in_maintenance(self.link_1)
356 1
        assert not self.deployer.link_not_in_maintenance(self.link_2)
357 1
        assert     self.deployer.link_not_in_maintenance(self.link_3)
358
359 1
        self.deployer.end_mw(maintenance)
360 1
        args, kwargs = buffer_put_mock.call_args
361 1
        event = args[0]
362 1
        assert event.name == 'topology.interruption.end'
363 1
        assert event.content['type'] == 'maintenance'
364 1
        assert sorted(event.content['switches']) == []
365 1
        assert sorted(event.content['interfaces']) == []
366 1
        assert sorted(event.content['links']) == [
367
            'link_1',
368
            'link_2',
369
        ]
370
        # Check whats in maintenance
371
        # Switches
372 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:89:ab:cd:ef'])
373 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:65:ab:cd:ef'])
374 1
        assert     self.deployer.switch_not_in_maintenance(self.controller.switches['01:23:45:67:66:ab:cd:ef'])
375
        # Interfaces
376 1
        for interface in self.controller.switches['01:23:45:67:89:ab:cd:ef'].interfaces.values():
377 1
            assert     self.deployer.interface_not_in_maintenance(interface)
378 1
        for interface in self.controller.switches['01:23:45:67:65:ab:cd:ef'].interfaces.values():
379 1
            assert     self.deployer.interface_not_in_maintenance(interface)
380 1
        for interface in self.controller.switches['01:23:45:67:66:ab:cd:ef'].interfaces.values():
381 1
            assert     self.deployer.interface_not_in_maintenance(interface)
382
        # Links
383 1
        assert     self.deployer.link_not_in_maintenance(self.link_1)
384 1
        assert     self.deployer.link_not_in_maintenance(self.link_2)
385 1
        assert     self.deployer.link_not_in_maintenance(self.link_3)
386
387 1
    def test_dev_status(self):
388 1
        switch_1 = MagicMock(
389
            id = 'test-switch-1',
390
            interfaces = {},
391
        )
392 1
        switch_2 = MagicMock(
393
            id = 'test-switch-2',
394
            interfaces = {},
395
        )
396 1
        interface_1 = MagicMock(
397
            id = 'test-interface-1',
398
            switch = switch_1,
399
            link = None,
400
        )
401 1
        switch_1.interfaces[0] = interface_1
402 1
        interface_2 = MagicMock(
403
            id = 'test-interface-2',
404
            switch = switch_2,
405
            link = None,
406
        )
407 1
        switch_2.interfaces[0] = interface_2
408 1
        link = MagicMock(
409
            id = 'test-link',
410
            endpoint_a = interface_1,
411
            endpoint_b = interface_2,
412
        )
413
414
        # No active maintenances
415 1
        assert self.deployer.link_status_func(link) != EntityStatus.DOWN
416 1
        assert self.deployer.interface_status_func(interface_1) != EntityStatus.DOWN
417 1
        assert self.deployer.interface_status_func(interface_2) != EntityStatus.DOWN
418 1
        assert self.deployer.switch_status_func(switch_1) != EntityStatus.DOWN
419 1
        assert self.deployer.switch_status_func(switch_2) != EntityStatus.DOWN
420
421 1
        assert self.deployer.link_status_reason_func(link) == set()
422 1
        assert self.deployer.interface_status_reason_func(interface_1) == set()
423 1
        assert self.deployer.interface_status_reason_func(interface_2) == set()
424 1
        assert self.deployer.switch_status_reason_func(switch_1) == set()
425 1
        assert self.deployer.switch_status_reason_func(switch_2) == set()
426
427
        # Active switch maintenance
428 1
        self.deployer.maintenance_switches['test-switch-1'] = 1
429
430 1
        assert self.deployer.link_status_func(link) == EntityStatus.DOWN
431 1
        assert self.deployer.interface_status_func(interface_1) == EntityStatus.DOWN
432 1
        assert self.deployer.interface_status_func(interface_2) != EntityStatus.DOWN
433 1
        assert self.deployer.switch_status_func(switch_1) == EntityStatus.DOWN
434 1
        assert self.deployer.switch_status_func(switch_2) != EntityStatus.DOWN
435
436 1
        assert self.deployer.link_status_reason_func(link) == {'maintenance'}
437 1
        assert self.deployer.interface_status_reason_func(interface_1) == {'maintenance'}
438 1
        assert self.deployer.interface_status_reason_func(interface_2) == set()
439 1
        assert self.deployer.switch_status_reason_func(switch_1) == {'maintenance'}
440 1
        assert self.deployer.switch_status_reason_func(switch_2) == set()
441
442
        # Active interface maintenance
443 1
        self.deployer.maintenance_switches['test-switch-1'] = 0
444 1
        self.deployer.maintenance_interfaces['test-interface-1'] = 1
445
446 1
        assert self.deployer.link_status_func(link) == EntityStatus.DOWN
447 1
        assert self.deployer.interface_status_func(interface_1) == EntityStatus.DOWN
448 1
        assert self.deployer.interface_status_func(interface_2) != EntityStatus.DOWN
449 1
        assert self.deployer.switch_status_func(switch_1) != EntityStatus.DOWN
450 1
        assert self.deployer.switch_status_func(switch_2) != EntityStatus.DOWN
451
452 1
        assert self.deployer.link_status_reason_func(link) == {'maintenance'}
453 1
        assert self.deployer.interface_status_reason_func(interface_1) == {'maintenance'}
454 1
        assert self.deployer.interface_status_reason_func(interface_2) == set()
455 1
        assert self.deployer.switch_status_reason_func(switch_1) == set()
456 1
        assert self.deployer.switch_status_reason_func(switch_2) == set()
457
458
        # Active link maintenance
459 1
        self.deployer.maintenance_switches['test-switch-1'] = 0
460 1
        self.deployer.maintenance_interfaces['test-interface-1'] = 0
461 1
        self.deployer.maintenance_links['test-link'] = 1
462
463 1
        assert self.deployer.link_status_func(link) == EntityStatus.DOWN
464 1
        assert self.deployer.interface_status_func(interface_1) != EntityStatus.DOWN
465 1
        assert self.deployer.interface_status_func(interface_2) != EntityStatus.DOWN
466 1
        assert self.deployer.switch_status_func(switch_1) != EntityStatus.DOWN
467 1
        assert self.deployer.switch_status_func(switch_2) != EntityStatus.DOWN
468
469 1
        assert self.deployer.link_status_reason_func(link) == {'maintenance'}
470 1
        assert self.deployer.interface_status_reason_func(interface_1) == set()
471 1
        assert self.deployer.interface_status_reason_func(interface_2) == set()
472 1
        assert self.deployer.switch_status_reason_func(switch_1) == set()
473
        assert self.deployer.switch_status_reason_func(switch_2) == set()
474