Loading src/nbi/tests/test_dscm_restconf.py +23 −10 Original line number Diff line number Diff line Loading @@ -14,11 +14,12 @@ from typing import Union import logging import os, pytest import os, pytest, time import requests from .DSCM_MockWebServer import nbi_service_rest from .DSCM_MockWebServer import MockWebServer from .messages.dscm_messages import get_hub_payload, get_leaf_payload from common.Constants import ServiceNameEnum from nbi.service.NbiApplication import NbiApplication from common.proto.context_pb2_grpc import add_ContextServiceServicer_to_server from common.Settings import ( ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, Loading @@ -42,9 +43,9 @@ HEADERS = { "Accept" : "application/yang-data+json", LOCAL_HOST = '127.0.0.1' DSCMPLUGGABLE_SERVICE_PORT = get_service_port_grpc(ServiceNameEnum.DSCMPLUGGABLE) os.environ[get_env_var_name(ServiceNameEnum.DSCMPLUGGABLE, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) os.environ[get_env_var_name(ServiceNameEnum.DSCMPLUGGABLE, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(DSCMPLUGGABLE_SERVICE_PORT) DSCMPLUGGABLE_SERVICE_PORT = get_service_port_grpc(ServiceNameEnum.PLUGGABLES) os.environ[get_env_var_name(ServiceNameEnum.PLUGGABLES, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) os.environ[get_env_var_name(ServiceNameEnum.PLUGGABLES, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(DSCMPLUGGABLE_SERVICE_PORT) class MockContextService(GenericGrpcService): def __init__(self, bind_port: Union[str, int]) -> None: Loading @@ -55,6 +56,18 @@ class MockContextService(GenericGrpcService): add_ContextServiceServicer_to_server(self.context_servicer, self.server) @pytest.fixture(scope='session') def nbi_service_rest() -> NbiApplication: """Fixture to start the NBI REST service with DSCM plugin.""" mock_web_server = MockWebServer() mock_web_server.start() time.sleep(1) # give time for the server to start nbi_app = mock_web_server.nbi_app yield nbi_app # Cleanup: web server runs as daemon thread, so will terminate with main process @pytest.fixture(scope='session') def pluggables_service(): LOGGER.info('Initializing DscmPluggableService...') Loading src/pluggables/tests/test_pluggables.py +2 −2 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ def test_CreatePluggable(pluggables_client : PluggablesClient): LOGGER.info('Creating Pluggable for test...') _pluggable_request = create_pluggable_request( device_uuid=DEVICE_HUB_UUID, preferred_pluggable_index=-1) preferred_pluggable_index=1) _pluggable = pluggables_client.CreatePluggable(_pluggable_request) LOGGER.info('Created Pluggable for test: %s', _pluggable) assert isinstance(_pluggable, Pluggable) Loading Loading @@ -141,7 +141,7 @@ def test_GetPluggable(pluggables_client : PluggablesClient): # First create a pluggable to get it later _pluggable_request = create_pluggable_request( device_uuid=DEVICE_HUB_UUID, preferred_pluggable_index=1) preferred_pluggable_index=10) _created_pluggable = pluggables_client.CreatePluggable(_pluggable_request) LOGGER.info('Created Pluggable for GetPluggable test: %s', _created_pluggable) Loading Loading
src/nbi/tests/test_dscm_restconf.py +23 −10 Original line number Diff line number Diff line Loading @@ -14,11 +14,12 @@ from typing import Union import logging import os, pytest import os, pytest, time import requests from .DSCM_MockWebServer import nbi_service_rest from .DSCM_MockWebServer import MockWebServer from .messages.dscm_messages import get_hub_payload, get_leaf_payload from common.Constants import ServiceNameEnum from nbi.service.NbiApplication import NbiApplication from common.proto.context_pb2_grpc import add_ContextServiceServicer_to_server from common.Settings import ( ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, Loading @@ -42,9 +43,9 @@ HEADERS = { "Accept" : "application/yang-data+json", LOCAL_HOST = '127.0.0.1' DSCMPLUGGABLE_SERVICE_PORT = get_service_port_grpc(ServiceNameEnum.DSCMPLUGGABLE) os.environ[get_env_var_name(ServiceNameEnum.DSCMPLUGGABLE, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) os.environ[get_env_var_name(ServiceNameEnum.DSCMPLUGGABLE, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(DSCMPLUGGABLE_SERVICE_PORT) DSCMPLUGGABLE_SERVICE_PORT = get_service_port_grpc(ServiceNameEnum.PLUGGABLES) os.environ[get_env_var_name(ServiceNameEnum.PLUGGABLES, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) os.environ[get_env_var_name(ServiceNameEnum.PLUGGABLES, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(DSCMPLUGGABLE_SERVICE_PORT) class MockContextService(GenericGrpcService): def __init__(self, bind_port: Union[str, int]) -> None: Loading @@ -55,6 +56,18 @@ class MockContextService(GenericGrpcService): add_ContextServiceServicer_to_server(self.context_servicer, self.server) @pytest.fixture(scope='session') def nbi_service_rest() -> NbiApplication: """Fixture to start the NBI REST service with DSCM plugin.""" mock_web_server = MockWebServer() mock_web_server.start() time.sleep(1) # give time for the server to start nbi_app = mock_web_server.nbi_app yield nbi_app # Cleanup: web server runs as daemon thread, so will terminate with main process @pytest.fixture(scope='session') def pluggables_service(): LOGGER.info('Initializing DscmPluggableService...') Loading
src/pluggables/tests/test_pluggables.py +2 −2 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ def test_CreatePluggable(pluggables_client : PluggablesClient): LOGGER.info('Creating Pluggable for test...') _pluggable_request = create_pluggable_request( device_uuid=DEVICE_HUB_UUID, preferred_pluggable_index=-1) preferred_pluggable_index=1) _pluggable = pluggables_client.CreatePluggable(_pluggable_request) LOGGER.info('Created Pluggable for test: %s', _pluggable) assert isinstance(_pluggable, Pluggable) Loading Loading @@ -141,7 +141,7 @@ def test_GetPluggable(pluggables_client : PluggablesClient): # First create a pluggable to get it later _pluggable_request = create_pluggable_request( device_uuid=DEVICE_HUB_UUID, preferred_pluggable_index=1) preferred_pluggable_index=10) _created_pluggable = pluggables_client.CreatePluggable(_pluggable_request) LOGGER.info('Created Pluggable for GetPluggable test: %s', _created_pluggable) Loading