From 3ac53a392f39cb9c5846c811e038d3fa3a3b9f8d Mon Sep 17 00:00:00 2001 From: Ng Tek In Date: Thu, 3 Sep 2026 12:19:57 +0800 Subject: [PATCH] Add OMC test --- tests/services/fabricv4/helpers/apis.py | 2 +- tests/services/fabricv4/helpers/users.py | 1 + tests/services/fabricv4/test_mc_api.py | 132 +++++++++++++++++++++++ 3 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 tests/services/fabricv4/test_mc_api.py diff --git a/tests/services/fabricv4/helpers/apis.py b/tests/services/fabricv4/helpers/apis.py index 49c23391..a2656023 100644 --- a/tests/services/fabricv4/helpers/apis.py +++ b/tests/services/fabricv4/helpers/apis.py @@ -27,7 +27,7 @@ def __init__(self, api_client: fabricv4.ApiClient) -> None: self.ip_blocks = fabricv4.IPBlocksApi(api_client) self.loa = fabricv4.LoasApi(api_client) self.ix = fabricv4.InternetExchangeServicesApi(api_client) - + self.omc = fabricv4.OpticalMetroConnectsApi(api_client) def for_user(user_name: UserName) -> Apis: return Apis(token_generator.get_api_client(user_name)) diff --git a/tests/services/fabricv4/helpers/users.py b/tests/services/fabricv4/helpers/users.py index b639ce46..5e877f11 100644 --- a/tests/services/fabricv4/helpers/users.py +++ b/tests/services/fabricv4/helpers/users.py @@ -8,6 +8,7 @@ class UserName(str, Enum): PANTHERS_FCR = "fcr" PANTHERS_FNV = "fnv" + PANTHERS_OMC = "omc" @dataclass diff --git a/tests/services/fabricv4/test_mc_api.py b/tests/services/fabricv4/test_mc_api.py new file mode 100644 index 00000000..f0cf567d --- /dev/null +++ b/tests/services/fabricv4/test_mc_api.py @@ -0,0 +1,132 @@ +from __future__ import annotations + +import time +import pytest + +from equinix.services import fabricv4 +from .helpers import utils +from .helpers.apis import Apis, for_user +from .helpers.users import UserName + +USER_NAME = UserName.PANTHERS_OMC + + +@pytest.mark.integration +class TestOMC: + apis: Apis + + @classmethod + def setup_class(cls) -> None: + cls.apis = for_user(USER_NAME) + + def test_create_omc_bulk(self) -> None: + response = self.apis.omc.create_bulk_optical_connect( + fabricv4.BulkOpticalConnectRequest( + data=[ + fabricv4.OpticalConnectPostRequest( + type=fabricv4.OpticalConnectPostRequestType.OC, + pathType=fabricv4.OpticalConnectPostRequestPathType.UNPROTECTED, + bandwidth=10000, + connectionDestinationType=fabricv4.OpticalConnectPostRequestConnectionDestinationType.REMOTE, + aSide=fabricv4.OpticalConnectASideRequest( + patchPanelId="PP:0000:1257117", + connectorType=fabricv4.OpticalConnectPatchPanelFieldsConnectorType.SC, + ), + zSide=fabricv4.OpticalConnectZSideRequest( + location=fabricv4.OpticalConnectLocation(ibxCode="SV2"), + loa=fabricv4.OpticalConnectLOA( + uuid="f9605007-6029-46f8-9efd-c7e689be6f7c" + ), + ), + account=fabricv4.SimplifiedAccount( + accountNumber=112860, + accountName="Fastly, Inc", + ), + redundancy=fabricv4.OpticalConnectRedundancy( + priority=fabricv4.OpticalConnectRedundancyPriority.PRIMARY + ), + ), + fabricv4.OpticalConnectPostRequest( + type=fabricv4.OpticalConnectPostRequestType.OC, + pathType=fabricv4.OpticalConnectPostRequestPathType.UNPROTECTED, + bandwidth=10000, + connectionDestinationType=fabricv4.OpticalConnectPostRequestConnectionDestinationType.REMOTE, + aSide=fabricv4.OpticalConnectASideRequest( + patchPanelId="PP:0001:1213749", + connectorType=fabricv4.OpticalConnectPatchPanelFieldsConnectorType.SC, + ), + zSide=fabricv4.OpticalConnectZSideRequest( + location=fabricv4.OpticalConnectLocation(ibxCode="SV2"), + loa=fabricv4.OpticalConnectLOA( + uuid="f9605007-6029-46f8-9efd-c7e689be6f7c" + ), + ), + account=fabricv4.SimplifiedAccount( + accountNumber=112860, + accountName="Fastly, Inc", + ), + redundancy=fabricv4.OpticalConnectRedundancy( + priority=fabricv4.OpticalConnectRedundancyPriority.SECONDARY + ), + ), + ] + ) + ) + assert response.data[0].uuid is not None + + def test_create_omc(self) -> None: + response = self.apis.omc.create_optical_connect( + fabricv4.OpticalConnectPostRequest( + type=fabricv4.OpticalConnectPostRequestType.OC, + pathType=fabricv4.OpticalConnectPostRequestPathType.UNPROTECTED, + bandwidth=10000, + connectionDestinationType=fabricv4.OpticalConnectPostRequestConnectionDestinationType.REMOTE, + aSide=fabricv4.OpticalConnectASideRequest( + patchPanelId="PP:0000:1257117", + connectorType=fabricv4.OpticalConnectPatchPanelFieldsConnectorType.SC, + ), + zSide=fabricv4.OpticalConnectZSideRequest( + location=fabricv4.OpticalConnectLocation(ibxCode="SV2"), + loa=fabricv4.OpticalConnectLOA( + uuid="f9605007-6029-46f8-9efd-c7e689be6f7c" + ), + ), + account=fabricv4.SimplifiedAccount( + accountNumber=112860, + accountName="Fastly, Inc", + ), + ), + ) + assert response.uuid is not None + + def test_get_omc(self) -> None: + response = self.apis.omc.get_optical_connect_by_uuid( + optical_connect_id="cd1eee2a-ec46-47f4-a313-d18e6d21fa88" + ) + assert response.uuid == "cd1eee2a-ec46-47f4-a313-d18e6d21fa88" + + def test_search_omc(self) -> None: + response = self.apis.omc.search_optical_connect( + fabricv4.OpticalConnectSearchRequest( + filter=fabricv4.OpticalConnectFilters( + var_and=[ + fabricv4.OpticalConnectFilter( + fabricv4.OpticalConnectSimpleExpression( + property="/uuid", + operator="=", + values=["cd1eee2a-ec46-47f4-a313-d18e6d21fa88"], + ) + ) + ], + ), + pagination=fabricv4.PaginationRequest(offset=0, limit=100), + ) + ) + + services = response.data + assert services, "Search returned no OMC" + + assert len(services) == 1, "More than 1 OMC returned" + assert ( + services[0].uuid == "cd1eee2a-ec46-47f4-a313-d18e6d21fa88" + ), "Wrong OMC returned"