|
@@ 2064-2086 (lines=23) @@
|
| 2061 |
|
self.napp.handle_flow_delete(event) |
| 2062 |
|
evc.set_flow_removed_at.assert_called_once() |
| 2063 |
|
|
| 2064 |
|
async def test_add_bulk_metadata(self): |
| 2065 |
|
"""Test add_bulk_metadata method""" |
| 2066 |
|
evc_mock = create_autospec(EVC) |
| 2067 |
|
evc_mock.id = 1234 |
| 2068 |
|
self.napp.circuits = {"1234": evc_mock} |
| 2069 |
|
payload = { |
| 2070 |
|
"circuit_ids": ["1234"], |
| 2071 |
|
"metadata1": 1, |
| 2072 |
|
"metadata2": 2 |
| 2073 |
|
} |
| 2074 |
|
response = await self.api_client.post( |
| 2075 |
|
f"{self.base_endpoint}/v2/evc/metadata", |
| 2076 |
|
json=payload |
| 2077 |
|
) |
| 2078 |
|
assert response.status_code == 201 |
| 2079 |
|
args = self.napp.mongo_controller.update_evcs.call_args[0] |
| 2080 |
|
ids = payload.pop("circuit_ids") |
| 2081 |
|
assert args[0] == ids |
| 2082 |
|
assert args[1] == payload |
| 2083 |
|
assert args[2] == "add" |
| 2084 |
|
calls = self.napp.mongo_controller.update_evcs.call_count |
| 2085 |
|
assert calls == 1 |
| 2086 |
|
evc_mock.extend_metadata.assert_called_with(payload) |
| 2087 |
|
|
| 2088 |
|
async def test_add_bulk_metadata_no_id(self): |
| 2089 |
|
"""Test add_bulk_metadata with unknown evc id""" |
|
@@ 2116-2136 (lines=21) @@
|
| 2113 |
|
) |
| 2114 |
|
assert response.status_code == 400 |
| 2115 |
|
|
| 2116 |
|
async def test_delete_bulk_metadata(self): |
| 2117 |
|
"""Test delete_metadata method""" |
| 2118 |
|
evc_mock = create_autospec(EVC) |
| 2119 |
|
evc_mock.id = 1234 |
| 2120 |
|
self.napp.circuits = {"1234": evc_mock} |
| 2121 |
|
payload = { |
| 2122 |
|
"circuit_ids": ["1234"] |
| 2123 |
|
} |
| 2124 |
|
response = await self.api_client.request( |
| 2125 |
|
"DELETE", |
| 2126 |
|
f"{self.base_endpoint}/v2/evc/metadata/metadata1", |
| 2127 |
|
json=payload |
| 2128 |
|
) |
| 2129 |
|
assert response.status_code == 200 |
| 2130 |
|
args = self.napp.mongo_controller.update_evcs.call_args[0] |
| 2131 |
|
assert args[0] == payload["circuit_ids"] |
| 2132 |
|
assert args[1] == {"metadata1": ""} |
| 2133 |
|
assert args[2] == "del" |
| 2134 |
|
calls = self.napp.mongo_controller.update_evcs.call_count |
| 2135 |
|
assert calls == 1 |
| 2136 |
|
assert evc_mock.remove_metadata.call_count == 1 |
| 2137 |
|
|