|
@@ 274-300 (lines=27) @@
|
| 271 |
|
self.napp.check_switch_consistency(switch) |
| 272 |
|
mock_install_flows.assert_called() |
| 273 |
|
|
| 274 |
|
@patch('napps.kytos.flow_manager.main.Main._install_flows') |
| 275 |
|
@patch('napps.kytos.flow_manager.main.FlowFactory.get_class') |
| 276 |
|
def test_check_switch_consistency_delete(self, *args): |
| 277 |
|
"""Test check_switch_consistency method. |
| 278 |
|
|
| 279 |
|
This test checks the case when a flow is missing in switch and have the |
| 280 |
|
DELETE command. |
| 281 |
|
""" |
| 282 |
|
(mock_flow_factory, mock_install_flows) = args |
| 283 |
|
dpid = "00:00:00:00:00:00:00:01" |
| 284 |
|
switch = get_switch_mock(dpid, 0x04) |
| 285 |
|
|
| 286 |
|
flow_1 = MagicMock() |
| 287 |
|
flow_1.as_dict.return_value = {'flow_1': 'data'} |
| 288 |
|
|
| 289 |
|
flow_list = [{"command": "delete", |
| 290 |
|
"flow": {'flow_1': 'data'} |
| 291 |
|
}] |
| 292 |
|
serializer = MagicMock() |
| 293 |
|
serializer.from_dict.return_value = flow_1 |
| 294 |
|
|
| 295 |
|
switch.flows = [flow_1] |
| 296 |
|
|
| 297 |
|
mock_flow_factory.return_value = serializer |
| 298 |
|
self.napp.stored_flows = {dpid: {"flow_list": flow_list}} |
| 299 |
|
self.napp.check_switch_consistency(switch) |
| 300 |
|
mock_install_flows.assert_called() |
| 301 |
|
|
| 302 |
|
@patch('napps.kytos.flow_manager.main.Main._install_flows') |
| 303 |
|
@patch('napps.kytos.flow_manager.main.FlowFactory.get_class') |
|
@@ 302-326 (lines=25) @@
|
| 299 |
|
self.napp.check_switch_consistency(switch) |
| 300 |
|
mock_install_flows.assert_called() |
| 301 |
|
|
| 302 |
|
@patch('napps.kytos.flow_manager.main.Main._install_flows') |
| 303 |
|
@patch('napps.kytos.flow_manager.main.FlowFactory.get_class') |
| 304 |
|
def test_check_storehouse_consistency(self, *args): |
| 305 |
|
"""Test check_storehouse_consistency method. |
| 306 |
|
|
| 307 |
|
This test checks the case when a flow is missing in storehouse. |
| 308 |
|
""" |
| 309 |
|
(mock_flow_factory, mock_install_flows) = args |
| 310 |
|
dpid = "00:00:00:00:00:00:00:01" |
| 311 |
|
switch = get_switch_mock(dpid, 0x04) |
| 312 |
|
|
| 313 |
|
flow_1 = MagicMock() |
| 314 |
|
flow_1.as_dict.return_value = {'flow_1': 'data'} |
| 315 |
|
|
| 316 |
|
switch.flows = [flow_1] |
| 317 |
|
|
| 318 |
|
flow_list = [{"command": "add", |
| 319 |
|
"flow": {'flow_2': 'data'} |
| 320 |
|
}] |
| 321 |
|
serializer = MagicMock() |
| 322 |
|
|
| 323 |
|
mock_flow_factory.return_value = serializer |
| 324 |
|
self.napp.stored_flows = {dpid: {"flow_list": flow_list}} |
| 325 |
|
self.napp.check_storehouse_consistency(switch) |
| 326 |
|
mock_install_flows.assert_called() |
| 327 |
|
|
|
@@ 248-272 (lines=25) @@
|
| 245 |
|
self.napp._store_changed_flows(command, flows, switch) |
| 246 |
|
mock_save_flow.assert_called() |
| 247 |
|
|
| 248 |
|
@patch('napps.kytos.flow_manager.main.Main._install_flows') |
| 249 |
|
@patch('napps.kytos.flow_manager.main.FlowFactory.get_class') |
| 250 |
|
def test_check_switch_consistency_add(self, *args): |
| 251 |
|
"""Test check_switch_consistency method. |
| 252 |
|
|
| 253 |
|
This test checks the case when a flow is missing in switch and have the |
| 254 |
|
ADD command. |
| 255 |
|
""" |
| 256 |
|
(mock_flow_factory, mock_install_flows) = args |
| 257 |
|
dpid = "00:00:00:00:00:00:00:01" |
| 258 |
|
switch = get_switch_mock(dpid, 0x04) |
| 259 |
|
switch.flows = [] |
| 260 |
|
|
| 261 |
|
flow_1 = MagicMock() |
| 262 |
|
flow_1.as_dict.return_value = {'flow_1': 'data'} |
| 263 |
|
|
| 264 |
|
flow_list = [{"command": "add", |
| 265 |
|
"flow": {'flow_1': 'data'} |
| 266 |
|
}] |
| 267 |
|
serializer = MagicMock() |
| 268 |
|
|
| 269 |
|
mock_flow_factory.return_value = serializer |
| 270 |
|
self.napp.stored_flows = {dpid: {"flow_list": flow_list}} |
| 271 |
|
self.napp.check_switch_consistency(switch) |
| 272 |
|
mock_install_flows.assert_called() |
| 273 |
|
|
| 274 |
|
@patch('napps.kytos.flow_manager.main.Main._install_flows') |
| 275 |
|
@patch('napps.kytos.flow_manager.main.FlowFactory.get_class') |