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

Add unit test for router update Kentik license workflow

parent 2c046071
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !300. Comments created here will be created in the context of that merge request.
...@@ -33,7 +33,7 @@ def _initial_input_form(subscription_id: UUIDstr) -> FormGenerator: ...@@ -33,7 +33,7 @@ def _initial_input_form(subscription_id: UUIDstr) -> FormGenerator:
) )
class ModifyKentikLicenseForm(FormPage): 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") @model_validator(mode="before")
def router_must_be_nokia_p(cls, data: Any) -> Any: def router_must_be_nokia_p(cls, data: Any) -> Any:
......
...@@ -107,15 +107,18 @@ class MockedKentikClient: ...@@ -107,15 +107,18 @@ class MockedKentikClient:
@staticmethod @staticmethod
def get_plans() -> list[dict[str, Any]]: 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 @staticmethod
def get_plan(plan_id: int) -> dict[str, Any]: 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 @staticmethod
def get_plan_by_name(plan_name: str) -> dict[str, Any]: 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 @staticmethod
def create_device(device: NewKentikDevice) -> dict[str, Any]: def create_device(device: NewKentikDevice) -> dict[str, Any]:
......
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"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment