diff --git a/gso/workflows/router/modify_kentik_license.py b/gso/workflows/router/modify_kentik_license.py index bd97b9c04605ed475fb7800a6cf965b5c3c895a1..e1a87021483bbf05017be50129064c7d4ed78894 100644 --- a/gso/workflows/router/modify_kentik_license.py +++ b/gso/workflows/router/modify_kentik_license.py @@ -33,7 +33,7 @@ def _initial_input_form(subscription_id: UUIDstr) -> FormGenerator: ) class ModifyKentikLicenseForm(FormPage): - new_plan_id: available_kentik_plans # type: ignore[valid-type] + new_plan_id: available_kentik_plans or str # type: ignore[valid-type] @model_validator(mode="before") def router_must_be_nokia_p(cls, data: Any) -> Any: diff --git a/test/services/conftest.py b/test/services/conftest.py index 046d0ca41a403889d3ea7c88598c9c1b61874d69..ee0c59e1ea76e0e12a1ee69365cbe9e71109d0d6 100644 --- a/test/services/conftest.py +++ b/test/services/conftest.py @@ -107,15 +107,18 @@ class MockedKentikClient: @staticmethod def get_plans() -> list[dict[str, Any]]: - return [{"id": 0, "plan_name": "kentik-plan-1"}, {"id": 1, "plan_name": "kentik-plan-2"}] + return [ + {"id": 0, "name": "kentik-plan-1", "active": True, "devices": [], "max_devices": 9999}, + {"id": 1, "name": "kentik-plan-2", "active": True, "devices": [], "max_devices": 9999}, + ] @staticmethod def get_plan(plan_id: int) -> dict[str, Any]: - return {"id": plan_id, "plan_name": "kentik-mocked-plan"} + return {"id": plan_id, "name": "kentik-mocked-plan", "active": True, "devices": [], "max_devices": 9999} @staticmethod def get_plan_by_name(plan_name: str) -> dict[str, Any]: - return {"id": 0, "plan_name": plan_name} + return {"id": 0, "name": plan_name, "active": True, "devices": [], "max_devices": 9999} @staticmethod def create_device(device: NewKentikDevice) -> dict[str, Any]: diff --git a/test/workflows/router/test_modify_router_kentik_license.py b/test/workflows/router/test_modify_router_kentik_license.py new file mode 100644 index 0000000000000000000000000000000000000000..9d5352c515b25cc921622d7e1e58a1726fe499a1 --- /dev/null +++ b/test/workflows/router/test_modify_router_kentik_license.py @@ -0,0 +1,31 @@ +from unittest.mock import patch + +import pytest + +from gso.products.product_blocks.router import RouterRole +from gso.products.product_types.router import Router +from test.services.conftest import MockedKentikClient +from test.workflows import assert_complete, extract_state, run_workflow + + +@pytest.mark.workflow() +@patch("gso.services.kentik_client.KentikClient") +def test_modify_router_kentik_license_success( + mock_kentik_client, + router_subscription_factory, + faker, +): + # Set up mock return values + product_id = router_subscription_factory(router_role=RouterRole.PE) + mock_kentik_client.return_value = MockedKentikClient + + # Run workflow + initial_input_data = [{"subscription_id": product_id}, {"new_plan_id": "0"}] + result, _, _ = run_workflow("modify_router_kentik_license", initial_input_data) + + assert_complete(result) + + state = extract_state(result) + subscription_id = state["subscription_id"] + subscription = Router.from_subscription(subscription_id) + assert subscription.status == "active"