diff --git a/test/workflows/router/test_create_imported_router.py b/test/workflows/router/test_create_imported_router.py new file mode 100644 index 0000000000000000000000000000000000000000..6831d0097c53957b3b069b6e541c3ff1a78aa689 --- /dev/null +++ b/test/workflows/router/test_create_imported_router.py @@ -0,0 +1,35 @@ +import pytest +from orchestrator.types import SubscriptionLifecycle + +from gso.products.product_blocks.router import RouterRole +from gso.products.product_types.router import ImportedRouter +from gso.products.product_types.site import Site +from gso.utils.helpers import iso_from_ipv4 +from gso.utils.shared_enums import Vendor +from test.workflows import assert_complete, extract_state, run_workflow + + +@pytest.fixture() +def imported_router_creation_input_form_data(site_subscription_factory, faker): + router_site = site_subscription_factory() + fake_v4 = faker.ipv4() + + return { + "partner": "GEANT", + "router_site": Site.from_subscription(router_site).site.site_name, + "hostname": faker.pystr(), + "ts_port": faker.pyint(), + "router_role": faker.random_choices(elements=(RouterRole.P, RouterRole.PE, RouterRole.AMT), length=1)[0], + "router_vendor": faker.random_choices(elements=(Vendor.NOKIA, Vendor.JUNIPER), length=1)[0], + "router_lo_ipv4_address": fake_v4, + "router_lo_ipv6_address": faker.ipv6(), + "router_lo_iso_address": iso_from_ipv4(fake_v4), + } + + +def test_create_imported_router_success(faker, imported_router_creation_input_form_data): + result, _, _ = run_workflow("create_imported_router", [imported_router_creation_input_form_data]) + state = extract_state(result) + subscription = ImportedRouter.from_subscription(state["subscription_id"]) + assert_complete(result) + assert subscription.status == SubscriptionLifecycle.ACTIVE diff --git a/test/workflows/router/test_import_router.py b/test/workflows/router/test_import_router.py new file mode 100644 index 0000000000000000000000000000000000000000..20938a7e9607fbc47bed95add3f08ccae1197ec4 --- /dev/null +++ b/test/workflows/router/test_import_router.py @@ -0,0 +1,18 @@ +import pytest +from orchestrator.types import SubscriptionLifecycle + +from gso.products import ProductName +from gso.products.product_types.router import Router +from test.workflows import assert_complete, run_workflow + + +@pytest.mark.workflow() +def test_import_site_success(nokia_router_subscription_factory): + imported_router = nokia_router_subscription_factory(is_imported=False) + result, _, _ = run_workflow("import_router", [{"subscription_id": imported_router}]) + subscription = Router.from_subscription(imported_router) + + assert_complete(result) + assert subscription.product.name == ProductName.ROUTER + assert subscription.status == SubscriptionLifecycle.ACTIVE + assert subscription.insync