From 878fd837d2da36d7eec71d988d0a8e7f0b2dc61e Mon Sep 17 00:00:00 2001 From: Grigory Statsenko Date: Tue, 14 Nov 2023 13:48:59 +0100 Subject: [PATCH] Refactored service registry creation in core tests --- .../db/base/core/base.py | 4 +- .../dl_core_testing/testcases/service_base.py | 37 +++++++++++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/lib/dl_connector_bundle_chs3/dl_connector_bundle_chs3_tests/db/base/core/base.py b/lib/dl_connector_bundle_chs3/dl_connector_bundle_chs3_tests/db/base/core/base.py index db5506f3c..53a09ef4d 100644 --- a/lib/dl_connector_bundle_chs3/dl_connector_bundle_chs3_tests/db/base/core/base.py +++ b/lib/dl_connector_bundle_chs3/dl_connector_bundle_chs3_tests/db/base/core/base.py @@ -110,7 +110,7 @@ def conn_sync_service_registry( conn_bi_context: RequestContextInfo, task_processor_factory: TaskProcessorFactory, ) -> ServicesRegistry: - return self.service_registry_factory( + return self.make_service_registry( conn_exec_factory_async_env=False, conn_bi_context=conn_bi_context, task_processor_factory=task_processor_factory, @@ -122,7 +122,7 @@ def conn_async_service_registry( conn_bi_context: RequestContextInfo, task_processor_factory: TaskProcessorFactory, ) -> ServicesRegistry: - return self.service_registry_factory( + return self.make_service_registry( conn_exec_factory_async_env=True, conn_bi_context=conn_bi_context, task_processor_factory=task_processor_factory, diff --git a/lib/dl_core_testing/dl_core_testing/testcases/service_base.py b/lib/dl_core_testing/dl_core_testing/testcases/service_base.py index 229c2b5ba..695813f0c 100644 --- a/lib/dl_core_testing/dl_core_testing/testcases/service_base.py +++ b/lib/dl_core_testing/dl_core_testing/testcases/service_base.py @@ -18,7 +18,12 @@ from dl_constants.enums import ConnectionType from dl_core.connections_security.base import InsecureConnectionSecurityManager from dl_core.services_registry.conn_executor_factory import DefaultConnExecutorFactory +from dl_core.services_registry.env_manager_factory import InsecureEnvManagerFactory from dl_core.services_registry.inst_specific_sr import InstallationSpecificServiceRegistryFactory +from dl_core.services_registry.sr_factories import ( + DefaultSRFactory, + SRFactory, +) from dl_core.services_registry.top_level import ( DefaultServicesRegistry, ServicesRegistry, @@ -69,7 +74,33 @@ def conn_bi_context(self) -> RequestContextInfo: def conn_exec_factory_async_env(self) -> bool: return False - def service_registry_factory( + def make_service_registry_factory(self, async_env: bool) -> SRFactory: + return DefaultSRFactory( + async_env=async_env, + rqe_config=RQEConfig.get_default(), # Not used because RQE is disabled + connectors_settings={self.conn_type: self.connection_settings} if self.connection_settings else {}, + inst_specific_sr_factory=self.inst_specific_sr_factory, + env_manager_factory=InsecureEnvManagerFactory(), + force_non_rqe_mode=True, + ) + + def make_service_registry( + self, + conn_exec_factory_async_env: bool, + conn_bi_context: RequestContextInfo, + **kwargs: Any, + ) -> ServicesRegistry: + sr_factory = self.make_service_registry_factory(async_env=conn_exec_factory_async_env) + return sr_factory.make_service_registry( + request_context_info=conn_bi_context, + mutations_cache_factory=DefaultUSEntryMutationCacheFactory(), + reporting_registry=DefaultReportingRegistry( + rci=conn_bi_context, + ), + **kwargs, + ) + + def make_service_registry_legacy( self, conn_exec_factory_async_env: bool, conn_bi_context: RequestContextInfo, @@ -106,7 +137,7 @@ def conn_sync_service_registry( self, conn_bi_context: RequestContextInfo, ) -> ServicesRegistry: - return self.service_registry_factory( + return self.make_service_registry( conn_exec_factory_async_env=False, conn_bi_context=conn_bi_context, ) @@ -116,7 +147,7 @@ def conn_async_service_registry( self, conn_bi_context: RequestContextInfo, ) -> ServicesRegistry: - return self.service_registry_factory( + return self.make_service_registry( conn_exec_factory_async_env=True, conn_bi_context=conn_bi_context, )