|
@@ 90-107 (lines=18) @@
|
| 87 |
|
evc = EVC(**attributes) |
| 88 |
|
self.assertFalse(evc.should_deploy(attributes['primary_links'])) |
| 89 |
|
|
| 90 |
|
@patch('napps.kytos.mef_eline.models.requests') |
| 91 |
|
def test_send_flow_mods_case1(self, requests_mock): |
| 92 |
|
"""Test if you are sending flow_mods.""" |
| 93 |
|
flow_mods = {"id": 20} |
| 94 |
|
switch = Mock(spec=Switch, id=1) |
| 95 |
|
|
| 96 |
|
response = MagicMock() |
| 97 |
|
response.status_code = 201 |
| 98 |
|
requests_mock.post.return_value = response |
| 99 |
|
|
| 100 |
|
# pylint: disable=protected-access |
| 101 |
|
EVC._send_flow_mods(switch, flow_mods) |
| 102 |
|
|
| 103 |
|
expected_endpoint = f"{MANAGER_URL}/flows/{switch.id}" |
| 104 |
|
expected_data = {"flows": flow_mods} |
| 105 |
|
self.assertEqual(requests_mock.post.call_count, 1) |
| 106 |
|
requests_mock.post.assert_called_once_with(expected_endpoint, |
| 107 |
|
json=expected_data) |
| 108 |
|
|
| 109 |
|
@patch('napps.kytos.mef_eline.models.requests') |
| 110 |
|
def test_send_flow_mods_case2(self, requests_mock): |
|
@@ 109-125 (lines=17) @@
|
| 106 |
|
requests_mock.post.assert_called_once_with(expected_endpoint, |
| 107 |
|
json=expected_data) |
| 108 |
|
|
| 109 |
|
@patch('napps.kytos.mef_eline.models.requests') |
| 110 |
|
def test_send_flow_mods_case2(self, requests_mock): |
| 111 |
|
"""Test if you are sending flow_mods.""" |
| 112 |
|
flow_mods = {"id": 20} |
| 113 |
|
switch = Mock(spec=Switch, id=1) |
| 114 |
|
response = MagicMock() |
| 115 |
|
response.status_code = 201 |
| 116 |
|
requests_mock.post.return_value = response |
| 117 |
|
|
| 118 |
|
# pylint: disable=protected-access |
| 119 |
|
EVC._send_flow_mods(switch, flow_mods, command='delete') |
| 120 |
|
|
| 121 |
|
expected_endpoint = f"{MANAGER_URL}/delete/{switch.id}" |
| 122 |
|
expected_data = {"flows": flow_mods} |
| 123 |
|
self.assertEqual(requests_mock.post.call_count, 1) |
| 124 |
|
requests_mock.post.assert_called_once_with(expected_endpoint, |
| 125 |
|
json=expected_data) |
| 126 |
|
|
| 127 |
|
def test_prepare_flow_mod(self): |
| 128 |
|
"""Test prepare flow_mod method.""" |