Skip to content
Snippets Groups Projects
Commit d0b08050 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Add unit tests for importing routers

parent 586f1a25
Branches
Tags
1 merge request!213Add unit tests for imported products
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment