diff --git a/test/workflows/vrf/test_terminate_vrf.py b/test/workflows/vrf/test_terminate_vrf.py new file mode 100644 index 0000000000000000000000000000000000000000..b06e72dbe3ddff964df0c9177a3e2fd0a74390d9 --- /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)