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

Update unit test for VRF router list modification workflow

parent e8614e72
No related branches found
No related tags found
1 merge request!327`modify_vrf_router_list`: Added LSO steps
Pipeline #90957 passed
......@@ -56,7 +56,7 @@ def update_subscription_model(subscription: VRF, router_list: list[dict[str, UUI
@step("[DRY RUN] Update VRF on list of routers")
def update_vrf_on_routers_dry(
subscription: dict[str, Any], process_id: UUIDstr, tt_number: str, router_list
subscription: dict[str, Any], process_id: UUIDstr, tt_number: str, router_list: list[dict[str, UUIDstr]]
) -> LSOState:
"""Deploy VRF on a list of routers - Dry run."""
vrf_new_router_list = [Router.from_subscription(router["router_id"]) for router in router_list]
......@@ -77,7 +77,7 @@ def update_vrf_on_routers_dry(
@step("[FOR REAL] Update VRF on list of routers")
def update_vrf_on_routers_real(
subscription: dict[str, Any], process_id: UUIDstr, tt_number: str, router_list
subscription: dict[str, Any], process_id: UUIDstr, tt_number: str, router_list: list[dict[str, UUIDstr]]
) -> LSOState:
"""Deploy VRF on a list of routers - with commit."""
vrf_new_router_list = [Router.from_subscription(router["router_id"]) for router in router_list]
......
import uuid
from unittest.mock import patch
import pytest
from pydantic_forms.exceptions import FormValidationError
from gso.products.product_types.vrf import VRF
from test.workflows import assert_complete, extract_state, run_workflow
from test.workflows import assert_complete, assert_lso_interaction_success, extract_state, run_workflow
@pytest.mark.workflow()
def test_modify_vrf_router_list(vrf_subscription_factory, router_subscription_factory, faker):
@patch("gso.services.lso_client._send_request")
def test_modify_vrf_router_list(mock_lso_call, vrf_subscription_factory, router_subscription_factory, faker):
subscription_id = vrf_subscription_factory()
initial_vrf_data = [
{"subscription_id": subscription_id},
{
"router_list": [{"router_id": router_subscription_factory()}, {"router_id": router_subscription_factory()}],
"tt_number": faker.tt_number(),
},
]
result, _, _ = run_workflow("modify_vrf_router_list", initial_vrf_data)
result, process_stat, step_log = run_workflow("modify_vrf_router_list", initial_vrf_data)
for _ in range(2):
result, step_log = assert_lso_interaction_success(result, process_stat, step_log)
assert_complete(result)
state = extract_state(result)
......@@ -24,6 +30,7 @@ def test_modify_vrf_router_list(vrf_subscription_factory, router_subscription_fa
subscription = VRF.from_subscription(subscription_id)
assert subscription.status == "active"
assert len(subscription.vrf.vrf_router_list) == 2
assert mock_lso_call.call_count == 2
@pytest.mark.workflow()
......@@ -31,9 +38,7 @@ def test_modify_vrf_router_list_with_invalid_router_id(vrf_subscription_factory,
subscription_id = vrf_subscription_factory()
initial_vrf_data = [
{"subscription_id": subscription_id},
{
"router_list": [{"router_id": uuid.uuid4()}],
},
{"router_list": [{"router_id": uuid.uuid4()}], "tt_number": faker.tt_number()},
]
with pytest.raises(FormValidationError, match="Input should be an instance of Select a router"):
......@@ -46,9 +51,7 @@ def test_modify_vrf_router_list_with_duplicate_router_id(vrf_subscription_factor
router_id = router_subscription_factory()
initial_vrf_data = [
{"subscription_id": subscription_id},
{
"router_list": [{"router_id": router_id}, {"router_id": router_id}],
},
{"router_list": [{"router_id": router_id}, {"router_id": router_id}], "tt_number": faker.tt_number()},
]
with pytest.raises(FormValidationError, match="List must be unique"):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment