| @@ 160-208 (lines=49) @@ | ||
| 157 | actual_events = self.napp.listeners() |
|
| 158 | self.assertEqual(expected_events, actual_events) |
|
| 159 | ||
| 160 | def test_verify_api_urls(self): |
|
| 161 | """Verify all APIs registered.""" |
|
| 162 | expected_urls = [ |
|
| 163 | ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/interfaces'), |
|
| 164 | ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/switches'), |
|
| 165 | ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/links'), |
|
| 166 | ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/'), |
|
| 167 | ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'}, |
|
| 168 | '/api/kytos/topology/v3/interfaces/switch/<dpid>/disable'), |
|
| 169 | ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'}, |
|
| 170 | '/api/kytos/topology/v3/interfaces/switch/<dpid>/enable'), |
|
| 171 | ({'key': '[key]', 'interface_id': '[interface_id]'}, |
|
| 172 | {'OPTIONS', 'DELETE'}, |
|
| 173 | '/api/kytos/topology/v3/interfaces/<interface_id>/metadata/<key>'), |
|
| 174 | ({'interface_id': '[interface_id]'}, {'POST', 'OPTIONS'}, |
|
| 175 | '/api/kytos/topology/v3/interfaces/<interface_id>/metadata'), |
|
| 176 | ({'interface_id': '[interface_id]'}, {'GET', 'OPTIONS', 'HEAD'}, |
|
| 177 | '/api/kytos/topology/v3/interfaces/<interface_id>/metadata'), |
|
| 178 | ({'interface_disable_id': '[interface_disable_id]'}, |
|
| 179 | {'POST', 'OPTIONS'}, |
|
| 180 | '/api/kytos/topology/v3/interfaces/<interface_disable_id>/disable'), |
|
| 181 | ({'interface_enable_id': '[interface_enable_id]'}, |
|
| 182 | {'POST', 'OPTIONS'}, |
|
| 183 | '/api/kytos/topology/v3/interfaces/<interface_enable_id>/enable'), |
|
| 184 | ({'dpid': '[dpid]', 'key': '[key]'}, {'OPTIONS', 'DELETE'}, |
|
| 185 | '/api/kytos/topology/v3/switches/<dpid>/metadata/<key>'), |
|
| 186 | ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'}, |
|
| 187 | '/api/kytos/topology/v3/switches/<dpid>/metadata'), |
|
| 188 | ({'dpid': '[dpid]'}, {'GET', 'OPTIONS', 'HEAD'}, |
|
| 189 | '/api/kytos/topology/v3/switches/<dpid>/metadata'), |
|
| 190 | ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'}, |
|
| 191 | '/api/kytos/topology/v3/switches/<dpid>/disable'), |
|
| 192 | ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'}, |
|
| 193 | '/api/kytos/topology/v3/switches/<dpid>/enable'), |
|
| 194 | ({'link_id': '[link_id]', 'key': '[key]'}, {'OPTIONS', 'DELETE'}, |
|
| 195 | '/api/kytos/topology/v3/links/<link_id>/metadata/<key>'), |
|
| 196 | ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'}, |
|
| 197 | '/api/kytos/topology/v3/links/<link_id>/metadata'), |
|
| 198 | ({'link_id': '[link_id]'}, {'GET', 'OPTIONS', 'HEAD'}, |
|
| 199 | '/api/kytos/topology/v3/links/<link_id>/metadata'), |
|
| 200 | ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'}, |
|
| 201 | '/api/kytos/topology/v3/links/<link_id>/disable'), |
|
| 202 | ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'}, |
|
| 203 | '/api/kytos/topology/v3/links/<link_id>/enable')] |
|
| 204 | ||
| 205 | urls = self.get_napp_urls(self.napp) |
|
| 206 | self.assertEqual(expected_urls, urls) |
|
| 207 | ||
| 208 | @staticmethod |
|
| 209 | def get_napp_urls(napp): |
|
| 210 | """Return the kytos/topology urls. |
|
| 211 | ||
| @@ 48-96 (lines=49) @@ | ||
| 45 | actual_events = self.napp.listeners() |
|
| 46 | self.assertEqual(expected_events, actual_events) |
|
| 47 | ||
| 48 | def test_verify_api_urls(self): |
|
| 49 | """Verify all APIs registered.""" |
|
| 50 | expected_urls = [ |
|
| 51 | ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/interfaces'), |
|
| 52 | ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/switches'), |
|
| 53 | ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/links'), |
|
| 54 | ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/'), |
|
| 55 | ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'}, |
|
| 56 | '/api/kytos/topology/v3/interfaces/switch/<dpid>/disable'), |
|
| 57 | ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'}, |
|
| 58 | '/api/kytos/topology/v3/interfaces/switch/<dpid>/enable'), |
|
| 59 | ({'key': '[key]', 'interface_id': '[interface_id]'}, |
|
| 60 | {'OPTIONS', 'DELETE'}, |
|
| 61 | '/api/kytos/topology/v3/interfaces/<interface_id>/metadata/<key>'), |
|
| 62 | ({'interface_id': '[interface_id]'}, {'POST', 'OPTIONS'}, |
|
| 63 | '/api/kytos/topology/v3/interfaces/<interface_id>/metadata'), |
|
| 64 | ({'interface_id': '[interface_id]'}, {'GET', 'OPTIONS', 'HEAD'}, |
|
| 65 | '/api/kytos/topology/v3/interfaces/<interface_id>/metadata'), |
|
| 66 | ({'interface_disable_id': '[interface_disable_id]'}, |
|
| 67 | {'POST', 'OPTIONS'}, |
|
| 68 | '/api/kytos/topology/v3/interfaces/<interface_disable_id>/disable'), |
|
| 69 | ({'interface_enable_id': '[interface_enable_id]'}, |
|
| 70 | {'POST', 'OPTIONS'}, |
|
| 71 | '/api/kytos/topology/v3/interfaces/<interface_enable_id>/enable'), |
|
| 72 | ({'dpid': '[dpid]', 'key': '[key]'}, {'OPTIONS', 'DELETE'}, |
|
| 73 | '/api/kytos/topology/v3/switches/<dpid>/metadata/<key>'), |
|
| 74 | ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'}, |
|
| 75 | '/api/kytos/topology/v3/switches/<dpid>/metadata'), |
|
| 76 | ({'dpid': '[dpid]'}, {'GET', 'OPTIONS', 'HEAD'}, |
|
| 77 | '/api/kytos/topology/v3/switches/<dpid>/metadata'), |
|
| 78 | ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'}, |
|
| 79 | '/api/kytos/topology/v3/switches/<dpid>/disable'), |
|
| 80 | ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'}, |
|
| 81 | '/api/kytos/topology/v3/switches/<dpid>/enable'), |
|
| 82 | ({'link_id': '[link_id]', 'key': '[key]'}, {'OPTIONS', 'DELETE'}, |
|
| 83 | '/api/kytos/topology/v3/links/<link_id>/metadata/<key>'), |
|
| 84 | ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'}, |
|
| 85 | '/api/kytos/topology/v3/links/<link_id>/metadata'), |
|
| 86 | ({'link_id': '[link_id]'}, {'GET', 'OPTIONS', 'HEAD'}, |
|
| 87 | '/api/kytos/topology/v3/links/<link_id>/metadata'), |
|
| 88 | ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'}, |
|
| 89 | '/api/kytos/topology/v3/links/<link_id>/disable'), |
|
| 90 | ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'}, |
|
| 91 | '/api/kytos/topology/v3/links/<link_id>/enable')] |
|
| 92 | ||
| 93 | urls = get_napp_urls(self.napp) |
|
| 94 | self.assertEqual(expected_urls, urls) |
|
| 95 | ||
| 96 | def test_enable_switch(self): |
|
| 97 | """Test enable_swicth.""" |
|
| 98 | dpid = "00:00:00:00:00:00:00:01" |
|
| 99 | mock_switch = get_switch_mock(dpid) |
|