@@ 2597-2620 (lines=24) @@ | ||
2594 | self.napp.handle_flow_delete(event) |
|
2595 | evc.set_flow_removed_at.assert_called_once() |
|
2596 | ||
2597 | async def test_add_bulk_metadata(self): |
|
2598 | """Test add_bulk_metadata method""" |
|
2599 | self.napp.controller.loop = asyncio.get_running_loop() |
|
2600 | evc_mock = create_autospec(EVC) |
|
2601 | evc_mock.id = 1234 |
|
2602 | self.napp.circuits = {"1234": evc_mock} |
|
2603 | payload = { |
|
2604 | "circuit_ids": ["1234"], |
|
2605 | "metadata1": 1, |
|
2606 | "metadata2": 2 |
|
2607 | } |
|
2608 | response = await self.api_client.post( |
|
2609 | f"{self.base_endpoint}/v2/evc/metadata", |
|
2610 | json=payload |
|
2611 | ) |
|
2612 | assert response.status_code == 201 |
|
2613 | args = self.napp.mongo_controller.update_evcs_metadata.call_args[0] |
|
2614 | ids = payload.pop("circuit_ids") |
|
2615 | assert args[0] == ids |
|
2616 | assert args[1] == payload |
|
2617 | assert args[2] == "add" |
|
2618 | calls = self.napp.mongo_controller.update_evcs_metadata.call_count |
|
2619 | assert calls == 1 |
|
2620 | evc_mock.extend_metadata.assert_called_with(payload) |
|
2621 | ||
2622 | async def test_add_bulk_metadata_empty_list(self): |
|
2623 | """Test add_bulk_metadata method empty list""" |
|
@@ 2670-2691 (lines=22) @@ | ||
2667 | ) |
|
2668 | assert response.status_code == 400 |
|
2669 | ||
2670 | async def test_delete_bulk_metadata(self): |
|
2671 | """Test delete_metadata method""" |
|
2672 | self.napp.controller.loop = asyncio.get_running_loop() |
|
2673 | evc_mock = create_autospec(EVC) |
|
2674 | evc_mock.id = 1234 |
|
2675 | self.napp.circuits = {"1234": evc_mock} |
|
2676 | payload = { |
|
2677 | "circuit_ids": ["1234"] |
|
2678 | } |
|
2679 | response = await self.api_client.request( |
|
2680 | "DELETE", |
|
2681 | f"{self.base_endpoint}/v2/evc/metadata/metadata1", |
|
2682 | json=payload |
|
2683 | ) |
|
2684 | assert response.status_code == 200 |
|
2685 | args = self.napp.mongo_controller.update_evcs_metadata.call_args[0] |
|
2686 | assert args[0] == payload["circuit_ids"] |
|
2687 | assert args[1] == {"metadata1": ""} |
|
2688 | assert args[2] == "del" |
|
2689 | calls = self.napp.mongo_controller.update_evcs_metadata.call_count |
|
2690 | assert calls == 1 |
|
2691 | assert evc_mock.remove_metadata.call_count == 1 |
|
2692 | ||
2693 | async def test_delete_bulk_metadata_error(self): |
|
2694 | """Test bulk_delete_metadata with ciruit erroring""" |