|
@@ 2113-2136 (lines=24) @@
|
| 2110 |
|
self.napp.handle_flow_delete(event) |
| 2111 |
|
evc.set_flow_removed_at.assert_called_once() |
| 2112 |
|
|
| 2113 |
|
async def test_add_bulk_metadata(self, event_loop): |
| 2114 |
|
"""Test add_bulk_metadata method""" |
| 2115 |
|
self.napp.controller.loop = event_loop |
| 2116 |
|
evc_mock = create_autospec(EVC) |
| 2117 |
|
evc_mock.id = 1234 |
| 2118 |
|
self.napp.circuits = {"1234": evc_mock} |
| 2119 |
|
payload = { |
| 2120 |
|
"circuit_ids": ["1234"], |
| 2121 |
|
"metadata1": 1, |
| 2122 |
|
"metadata2": 2 |
| 2123 |
|
} |
| 2124 |
|
response = await self.api_client.post( |
| 2125 |
|
f"{self.base_endpoint}/v2/evc/metadata", |
| 2126 |
|
json=payload |
| 2127 |
|
) |
| 2128 |
|
assert response.status_code == 201 |
| 2129 |
|
args = self.napp.mongo_controller.update_evcs.call_args[0] |
| 2130 |
|
ids = payload.pop("circuit_ids") |
| 2131 |
|
assert args[0] == ids |
| 2132 |
|
assert args[1] == payload |
| 2133 |
|
assert args[2] == "add" |
| 2134 |
|
calls = self.napp.mongo_controller.update_evcs.call_count |
| 2135 |
|
assert calls == 1 |
| 2136 |
|
evc_mock.extend_metadata.assert_called_with(payload) |
| 2137 |
|
|
| 2138 |
|
async def test_add_bulk_metadata_no_id(self, event_loop): |
| 2139 |
|
"""Test add_bulk_metadata with unknown evc id""" |
|
@@ 2168-2189 (lines=22) @@
|
| 2165 |
|
) |
| 2166 |
|
assert response.status_code == 400 |
| 2167 |
|
|
| 2168 |
|
async def test_delete_bulk_metadata(self, event_loop): |
| 2169 |
|
"""Test delete_metadata method""" |
| 2170 |
|
self.napp.controller.loop = event_loop |
| 2171 |
|
evc_mock = create_autospec(EVC) |
| 2172 |
|
evc_mock.id = 1234 |
| 2173 |
|
self.napp.circuits = {"1234": evc_mock} |
| 2174 |
|
payload = { |
| 2175 |
|
"circuit_ids": ["1234"] |
| 2176 |
|
} |
| 2177 |
|
response = await self.api_client.request( |
| 2178 |
|
"DELETE", |
| 2179 |
|
f"{self.base_endpoint}/v2/evc/metadata/metadata1", |
| 2180 |
|
json=payload |
| 2181 |
|
) |
| 2182 |
|
assert response.status_code == 200 |
| 2183 |
|
args = self.napp.mongo_controller.update_evcs.call_args[0] |
| 2184 |
|
assert args[0] == payload["circuit_ids"] |
| 2185 |
|
assert args[1] == {"metadata1": ""} |
| 2186 |
|
assert args[2] == "del" |
| 2187 |
|
calls = self.napp.mongo_controller.update_evcs.call_count |
| 2188 |
|
assert calls == 1 |
| 2189 |
|
assert evc_mock.remove_metadata.call_count == 1 |
| 2190 |
|
|