Passed
Push — master ( 9f6c62...1a0953 )
by Vinicius
01:57 queued 16s
created

TestDeployer.setup_method()   B

Complexity

Conditions 1

Size

Total Lines 116
Code Lines 84

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 1

Importance

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