diff --git a/srpcLib/stub_generator/python/server_python_stub_generator.py b/srpcLib/stub_generator/python/server_python_stub_generator.py index eab22ee..9fa7c40 100644 --- a/srpcLib/stub_generator/python/server_python_stub_generator.py +++ b/srpcLib/stub_generator/python/server_python_stub_generator.py @@ -3,7 +3,6 @@ from ...interface.srpc_stub_generator_interface import SrpcStubGeneratorInterface from ...utils.srpc_stub import ( - DEFAULT_CONNECTION_PORT, LIB_NAME, get_service_interface_class_name, get_service_name, @@ -89,14 +88,10 @@ def generate_stub(self, dest_path: str = None): from {service_name}.{service_name}_interface import {service_interface_class_name} class Srpc{service_name.capitalize()}ServerStub(SrpcServerStubInterface): - def __init__(self, tls_config: SrpcTLSConfig = None, host:str=None, num_threads = 8): + def __init__(self, tls_config: SrpcTLSConfig = None, host:str="127.0.0.1", port = 5000 ,num_threads = 8): - if host == None: - self.__host = srpcnetwork.get_lan_ip_or_localhost() - else: - self.__host = host - - self.__CONNECTION_PORT = {DEFAULT_CONNECTION_PORT} + self.__host = host + self.__CONNECTION_PORT = port self.__handler_threads_pool = ThreadPoolExecutor(max_workers=num_threads) diff --git a/tests/integration/project_with_tls/server.py b/tests/integration/project_with_tls/server.py index 2fd81f0..3b5cfca 100644 --- a/tests/integration/project_with_tls/server.py +++ b/tests/integration/project_with_tls/server.py @@ -1,5 +1,5 @@ from srpc_calc_server_stub import SrpcCalcServerStub, SrpcTLSConfig tls_config = SrpcTLSConfig(certfile="./server.crt", keyfile="./server.key") -srpc_server = SrpcCalcServerStub(tls_config, "127.0.0.1") +srpc_server = SrpcCalcServerStub(tls_config=tls_config, host="127.0.0.1") srpc_server.start() diff --git a/tests/integration/simple_project/client.py b/tests/integration/simple_project/client.py index 3f6f152..172e31b 100644 --- a/tests/integration/simple_project/client.py +++ b/tests/integration/simple_project/client.py @@ -1,8 +1,8 @@ from srpc_calc_client_stub import SrpcCalcClientStub -from srpcLib.utils.srpc_network import get_lan_ip_or_localhost +# from srpcLib.utils.srpc_network import get_lan_ip_or_localhost -SERVER_HOST = get_lan_ip_or_localhost() +SERVER_HOST = "127.0.0.1" calcStub = SrpcCalcClientStub(SERVER_HOST, 5000) a = 4 b = 2 diff --git a/tests/integration/simple_project/run_rpc_client_divizion_by_zero.py b/tests/integration/simple_project/run_rpc_client_divizion_by_zero.py index 43030d9..bd06590 100644 --- a/tests/integration/simple_project/run_rpc_client_divizion_by_zero.py +++ b/tests/integration/simple_project/run_rpc_client_divizion_by_zero.py @@ -1,8 +1,6 @@ from srpc_calc_client_stub import SrpcCalcClientStub -from srpcLib.utils.srpc_network import get_lan_ip_or_localhost - -SERVER_HOST = get_lan_ip_or_localhost() +SERVER_HOST = "127.0.0.1" calcStub = SrpcCalcClientStub(SERVER_HOST, 5000) a = 4 try: diff --git a/tests/integration/test_project_with_tls.py b/tests/integration/test_project_with_tls.py index 132c505..c3e2c2d 100644 --- a/tests/integration/test_project_with_tls.py +++ b/tests/integration/test_project_with_tls.py @@ -45,7 +45,7 @@ def install_lib(): ) -@pytest.fixture(scope="session", autouse=True) +@pytest.fixture(scope="function") def generate_stubs(): """ Run the stub generator as a CLI tool inside test_project. @@ -95,7 +95,7 @@ def generate_stubs(): return TEST_PROJECT -@pytest.fixture(scope="session") +@pytest.fixture(scope="function") def server_process(generate_stubs, request): """ Launch the server once for the entire test session. diff --git a/tests/integration/test_simple_project.py b/tests/integration/test_simple_project.py index f9fdaee..ae89027 100644 --- a/tests/integration/test_simple_project.py +++ b/tests/integration/test_simple_project.py @@ -6,8 +6,6 @@ import pytest -from srpcLib.utils.srpc_network import get_lan_ip_or_localhost - # Paths ROOT_DIR = Path(__file__).resolve().parents[2] # rpc-lib/ TEST_PROJECT = ROOT_DIR / "tests/integration/simple_project" @@ -22,7 +20,7 @@ CLIENT_SCRIPT_DIVISION_BY_ZERO = "run_rpc_client_divizion_by_zero.py" # Network -SERVER_HOST = get_lan_ip_or_localhost() +SERVER_HOST = "127.0.0.1" SERVER_PORT = 5000 @@ -49,7 +47,7 @@ def install_lib(): ) -@pytest.fixture(scope="session", autouse=True) +@pytest.fixture(scope="function") def generate_stubs(): """ Run the stub generator as a CLI tool inside test_project. @@ -99,7 +97,7 @@ def generate_stubs(): return TEST_PROJECT -@pytest.fixture(scope="session") +@pytest.fixture(scope="function") def server_process(generate_stubs, request): """ Launch the server once for the entire test session.