From 19084f34551ba9f3953a658d2b40ea8e4b48ed5e Mon Sep 17 00:00:00 2001 From: Neda Moeini <neda.moeini@geant.org> Date: Thu, 28 Nov 2024 13:24:05 +0100 Subject: [PATCH] Add unit test for VRF termination WF --- test/workflows/vrf/test_terminate_vrf.py | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/workflows/vrf/test_terminate_vrf.py diff --git a/test/workflows/vrf/test_terminate_vrf.py b/test/workflows/vrf/test_terminate_vrf.py new file mode 100644 index 00000000..b06e72db --- /dev/null +++ b/test/workflows/vrf/test_terminate_vrf.py @@ -0,0 +1,36 @@ +import pytest +from pydantic_forms.exceptions import FormValidationError + +from gso.products.product_types.router import Router +from gso.products.product_types.vrf import VRF +from test.workflows import assert_complete, extract_state, run_workflow + + +@pytest.mark.workflow() +def test_terminate_vrf_success(vrf_subscription_factory, faker): + subscription_id = vrf_subscription_factory() + initial_vrf_data = [{"subscription_id": subscription_id}, {"tt_number": faker.tt_number()}] + result, _, _ = run_workflow("terminate_vrf", initial_vrf_data) + assert_complete(result) + + state = extract_state(result) + subscription_id = state["subscription_id"] + subscription = VRF.from_subscription(subscription_id) + assert subscription.status == "terminated" + + +@pytest.mark.workflow() +def test_terminate_vrf_with_router_list(vrf_subscription_factory, faker, router_subscription_factory): + subscription_id = vrf_subscription_factory() + subscription = VRF.from_subscription(subscription_id) + router = Router.from_subscription(router_subscription_factory()) + subscription.vrf.vrf_router_list = [router.router] + subscription.save() + initial_vrf_data = [{"subscription_id": subscription_id}, {"tt_number": faker.tt_number()}] + + with pytest.raises( + FormValidationError, + match="VRF must not have any routers assigned to it before it can be " + "deleted. Please remove all routers from the VRF first.", + ): + run_workflow("terminate_vrf", initial_vrf_data) -- GitLab