diff --git a/gso/workflows/iptrunk/create_iptrunk.py b/gso/workflows/iptrunk/create_iptrunk.py index ee3234a2937f984bf03486faf251d0e4c98a0147..390c3e137db575b64f3b4a85748729a49537ef3f 100644 --- a/gso/workflows/iptrunk/create_iptrunk.py +++ b/gso/workflows/iptrunk/create_iptrunk.py @@ -497,7 +497,8 @@ def netbox_allocate_side_b_interfaces(subscription: IptrunkInactive) -> None: def create_new_sharepoint_checklist(subscription: IptrunkProvisioning, tt_number: str) -> State: """Create a new checklist item in SharePoint for approving this IPtrunk.""" new_list_item_url = SharePointClient().add_list_item( - "ip_trunk", {"Title": subscription.iptrunk.iptrunk_description, "TT_NUMBER": tt_number} + "ip_trunk", + {"Title": subscription.iptrunk.iptrunk_description or subscription.description, "TT_NUMBER": tt_number}, ) return {"checklist_url": new_list_item_url} diff --git a/test/services/conftest.py b/test/services/conftest.py index 9fc3d191369b863e151721b7eed5ced2c4ee8d7c..9aee570a13f12985576708e9bac7740e5670b103 100644 --- a/test/services/conftest.py +++ b/test/services/conftest.py @@ -46,3 +46,14 @@ class MockedNetboxClient: @staticmethod def delete_interface(): return None + + +class MockedSharePointClient: + class BaseMockObject: + def __init__(self, **kwargs): + for key, value in kwargs.items(): + setattr(self, key, value) + + @staticmethod + def add_list_item(list_name: str, fields: dict[str, str]) -> str: + return f"http://{list_name}/{fields.popitem()}" diff --git a/test/workflows/iptrunk/test_create_iptrunk.py b/test/workflows/iptrunk/test_create_iptrunk.py index 35afaf9b3eb5e669a641989027d1a4d47c35e273..ea82a5bf7254dd535201ecadf08a5b0e91af6091 100644 --- a/test/workflows/iptrunk/test_create_iptrunk.py +++ b/test/workflows/iptrunk/test_create_iptrunk.py @@ -8,7 +8,7 @@ from gso.products.product_blocks.iptrunk import IptrunkType, PhysicalPortCapacit from gso.services.subscriptions import get_product_id_by_name from gso.utils.shared_enums import Vendor from test import USER_CONFIRM_EMPTY_FORM -from test.services.conftest import MockedNetboxClient +from test.services.conftest import MockedNetboxClient, MockedSharePointClient from test.workflows import ( assert_complete, assert_lso_interaction_failure, @@ -102,7 +102,9 @@ def input_form_wizard_data(request, juniper_router_subscription_factory, nokia_r @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v6_network") @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v4_network") @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.create_host_by_ip") +@patch("gso.workflows.iptrunk.create_iptrunk.SharePointClient") def test_successful_iptrunk_creation_with_standard_lso_result( + mock_sharepoint_client, mock_create_host, mock_allocate_v4_network, mock_allocate_v6_network, @@ -117,6 +119,8 @@ def test_successful_iptrunk_creation_with_standard_lso_result( mock_create_host.return_value = None mock_allocate_v4_network.return_value = faker.ipv4_network(max_subnet=31) mock_allocate_v6_network.return_value = faker.ipv6_network(max_subnet=126) + mock_sharepoint_client.return_value = MockedSharePointClient + product_id = get_product_id_by_name(ProductName.IP_TRUNK) initial_site_data = [{"product": product_id}, *input_form_wizard_data] result, process_stat, step_log = run_workflow("create_iptrunk", initial_site_data) @@ -179,7 +183,9 @@ def test_iptrunk_creation_fails_when_lso_return_code_is_one( @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v6_network") @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v4_network") @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.create_host_by_ip") +@patch("gso.workflows.iptrunk.create_iptrunk.SharePointClient") def test_successful_iptrunk_creation_with_juniper_interface_names( + mock_sharepoint_client, mock_create_host, mock_allocate_v4_network, mock_allocate_v6_network, @@ -194,6 +200,7 @@ def test_successful_iptrunk_creation_with_juniper_interface_names( mock_create_host.return_value = None mock_allocate_v4_network.return_value = faker.ipv4_network(max_subnet=31) mock_allocate_v6_network.return_value = faker.ipv6_network(max_subnet=126) + mock_sharepoint_client.return_value = MockedSharePointClient product_id = get_product_id_by_name(ProductName.IP_TRUNK) initial_site_data = [{"product": product_id}, *input_form_wizard_data] result, process_stat, step_log = run_workflow("create_iptrunk", initial_site_data) @@ -205,3 +212,4 @@ def test_successful_iptrunk_creation_with_juniper_interface_names( result, step_log = resume_workflow(process_stat, step_log, input_data=USER_CONFIRM_EMPTY_FORM) assert_complete(result) + assert mock_execute_playbook.call_count == 6 diff --git a/test/workflows/router/test_create_router.py b/test/workflows/router/test_create_router.py index 05f1ffe50290d8d30f7ac022dadd8f07f5f217d2..5a96dbc702002b80890e7c059c4d32ef70b0b067 100644 --- a/test/workflows/router/test_create_router.py +++ b/test/workflows/router/test_create_router.py @@ -9,6 +9,7 @@ from gso.products.product_types.router import Router from gso.services.subscriptions import get_product_id_by_name from gso.utils.shared_enums import Vendor from test import USER_CONFIRM_EMPTY_FORM +from test.services.conftest import MockedSharePointClient from test.workflows import ( assert_complete, assert_lso_interaction_failure, @@ -63,6 +64,7 @@ def test_create_nokia_router_success( ) mock_hostname_available.return_value = True mock_allocate_host.return_value = str(mock_v4), str(mock_v6) + mock_sharepoint_client.return_value = MockedSharePointClient # Run workflow initial_router_data = [{"product": product_id}, router_creation_input_form_data]