From 1c6794dc400a5332714640c738dfc7b75712abad Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sat, 7 Aug 2021 11:21:30 +0200 Subject: [PATCH] Renamed cpl to cpl_core & added config and services as arguments to startup --- src/cpl_core/application/application_abc.py | 8 ++--- .../application/application_builder.py | 10 +++---- .../application/application_builder_abc.py | 6 ++-- src/cpl_core/application/startup_abc.py | 15 +++++++--- src/cpl_core/configuration/configuration.py | 2 +- .../configuration/configuration_abc.py | 10 +++---- .../configuration/console_argument.py | 2 +- src/cpl_core/console/console.py | 24 +++++++-------- src/cpl_core/console/spinner_thread.py | 4 +-- .../connection/database_connection.py | 2 +- .../connection/database_connection_abc.py | 2 +- .../database/context/database_context.py | 2 +- .../database/context/database_context_abc.py | 2 +- .../service_collection_abc.py | 8 ++--- .../service_descriptor.py | 2 +- .../dependency_injection/service_provider.py | 6 ++-- .../service_provider_abc.py | 2 +- .../environment/application_environment.py | 2 +- .../application_environment_abc.py | 2 +- src/cpl_core/logging/logger_abc.py | 2 +- src/cpl_core/logging/logger_service.py | 8 ++--- src/cpl_core/mailing/email_client_abc.py | 4 +-- src/cpl_core/mailing/email_client_service.py | 6 ++-- .../custom/general/src/general/startup.py | 30 +++++++++---------- 24 files changed, 83 insertions(+), 78 deletions(-) diff --git a/src/cpl_core/application/application_abc.py b/src/cpl_core/application/application_abc.py index e3215594..3c64d944 100644 --- a/src/cpl_core/application/application_abc.py +++ b/src/cpl_core/application/application_abc.py @@ -12,9 +12,9 @@ class ApplicationABC(ABC): Parameters ---------- - config: :class:`cpl.configuration.configuration_abc.ConfigurationABC` + config: :class:`cpl_core.configuration.configuration_abc.ConfigurationABC` Contains object loaded from appsettings - services: :class:`cpl.dependency_injection.service_provider_abc.ServiceProviderABC` + services: :class:`cpl_core.dependency_injection.service_provider_abc.ServiceProviderABC` Contains instances of prepared objects """ @@ -39,7 +39,7 @@ class ApplicationABC(ABC): def configure(self): r"""Configure the application - Called by :class:`cpl.application.application_abc.ApplicationABC.run` + Called by :class:`cpl_core.application.application_abc.ApplicationABC.run` """ pass @@ -47,6 +47,6 @@ class ApplicationABC(ABC): def main(self): r"""Custom entry point - Called by :class:`cpl.application.application_abc.ApplicationABC.run` + Called by :class:`cpl_core.application.application_abc.ApplicationABC.run` """ pass diff --git a/src/cpl_core/application/application_builder.py b/src/cpl_core/application/application_builder.py index 417b1256..ee3f52a6 100644 --- a/src/cpl_core/application/application_builder.py +++ b/src/cpl_core/application/application_builder.py @@ -8,11 +8,11 @@ from cpl_core.dependency_injection.service_collection import ServiceCollection class ApplicationBuilder(ApplicationBuilderABC): - r"""This is class is used to build a object of :class:`cpl.application.application_abc.ApplicationABC` + r"""This is class is used to build a object of :class:`cpl_core.application.application_abc.ApplicationABC` Parameter --------- - app: Type[:class:`cpl.application.application_abc.ApplicationABC`] + app: Type[:class:`cpl_core.application.application_abc.ApplicationABC`] Application to build """ @@ -26,11 +26,11 @@ class ApplicationBuilder(ApplicationBuilderABC): self._services = ServiceCollection(self._configuration) def use_startup(self, startup: Type[StartupABC]): - self._startup = startup(self._configuration, self._services) + self._startup = startup() def build(self) -> ApplicationABC: if self._startup is not None: - self._startup.configure_configuration() - self._startup.configure_services() + self._startup.configure_configuration(self._configuration, self._environment) + self._startup.configure_services(self._services, self._environment) return self._app(self._configuration, self._services.build_service_provider()) diff --git a/src/cpl_core/application/application_builder_abc.py b/src/cpl_core/application/application_builder_abc.py index 44c68fd7..dff8e6f8 100644 --- a/src/cpl_core/application/application_builder_abc.py +++ b/src/cpl_core/application/application_builder_abc.py @@ -6,7 +6,7 @@ from cpl_core.application.startup_abc import StartupABC class ApplicationBuilderABC(ABC): - r"""ABC for the :class:`cpl.application.application_builder.ApplicationBuilder`""" + r"""ABC for the :class:`cpl_core.application.application_builder.ApplicationBuilder`""" @abstractmethod def __init__(self, *args): @@ -18,7 +18,7 @@ class ApplicationBuilderABC(ABC): Parameter --------- - startup: Type[:class:`cpl.application.startup_abc.StartupABC`] + startup: Type[:class:`cpl_core.application.startup_abc.StartupABC`] Startup class to use """ pass @@ -29,6 +29,6 @@ class ApplicationBuilderABC(ABC): Returns ------- - Object of :class:`cpl.application.application_abc.ApplicationABC` + Object of :class:`cpl_core.application.application_abc.ApplicationABC` """ pass diff --git a/src/cpl_core/application/startup_abc.py b/src/cpl_core/application/startup_abc.py index fd48b644..0ace7711 100644 --- a/src/cpl_core/application/startup_abc.py +++ b/src/cpl_core/application/startup_abc.py @@ -1,7 +1,9 @@ from abc import ABC, abstractmethod from cpl_core.configuration.configuration_abc import ConfigurationABC +from cpl_core.dependency_injection.service_collection_abc import ServiceCollectionABC from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC +from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC class StartupABC(ABC): @@ -12,21 +14,26 @@ class StartupABC(ABC): pass @abstractmethod - def configure_configuration(self) -> ConfigurationABC: + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC) -> ConfigurationABC: r"""Creates configuration of application + Parameter + --------- + config: :class:`cpl_core.configuration.configuration_abc.ConfigurationABC` + env: :class:`cpl_core.environment.application_environment_abc` + Returns ------- - Object of :class:`cpl.configuration.configuration_abc.ConfigurationABC` + Object of :class:`cpl_core.configuration.configuration_abc.ConfigurationABC` """ pass @abstractmethod - def configure_services(self) -> ServiceProviderABC: + def configure_services(self, service: ServiceCollectionABC, env: ApplicationEnvironmentABC) -> ServiceProviderABC: r"""Creates service provider Returns ------- - Object of :class:`cpl.dependency_injection.service_provider_abc.ServiceProviderABC` + Object of :class:`cpl_core.dependency_injection.service_provider_abc.ServiceProviderABC` """ pass diff --git a/src/cpl_core/configuration/configuration.py b/src/cpl_core/configuration/configuration.py index 605c6bcc..a1fa351e 100644 --- a/src/cpl_core/configuration/configuration.py +++ b/src/cpl_core/configuration/configuration.py @@ -122,7 +122,7 @@ class Configuration(ConfigurationABC): --------- argument: :class:`str` Command as string - argument_type: :class:`cpl.configuration.console_argument.ConsoleArgument` + argument_type: :class:`cpl_core.configuration.console_argument.ConsoleArgument` Command type as ConsoleArgument next_arguments: list[:class:`str`] Following arguments of argument diff --git a/src/cpl_core/configuration/configuration_abc.py b/src/cpl_core/configuration/configuration_abc.py index 9bade832..3d332f65 100644 --- a/src/cpl_core/configuration/configuration_abc.py +++ b/src/cpl_core/configuration/configuration_abc.py @@ -11,7 +11,7 @@ class ConfigurationABC(ABC): @abstractmethod def __init__(self): - r"""ABC for the :class:`cpl.configuration.configuration.Configuration`""" + r"""ABC for the :class:`cpl_core.configuration.configuration.Configuration`""" pass @property @@ -47,7 +47,7 @@ class ConfigurationABC(ABC): Parameter --------- - argument: :class:`cpl.configuration.console_argument.ConsoleArgument` + argument: :class:`cpl_core.configuration.console_argument.ConsoleArgument` Specifies the console argument """ pass @@ -88,7 +88,7 @@ class ConfigurationABC(ABC): --------- key_type: Union[:class:`str`, :class:`type`] Type of the value - value: Union[:class:`str`, :class:`cpl.configuration.configuration_model_abc.ConfigurationModelABC`] + value: Union[:class:`str`, :class:`cpl_core.configuration.configuration_model_abc.ConfigurationModelABC`] Object of the value """ pass @@ -99,11 +99,11 @@ class ConfigurationABC(ABC): Parameter --------- - search_type: Union[:class:`str`, Type[:class:`cpl.configuration.configuration_model_abc.ConfigurationModelABC`]] + search_type: Union[:class:`str`, Type[:class:`cpl_core.configuration.configuration_model_abc.ConfigurationModelABC`]] Type to search for Returns ------- - Object of Union[:class:`str`, Callable[:class:`cpl.configuration.configuration_model_abc.ConfigurationModelABC`]] + Object of Union[:class:`str`, Callable[:class:`cpl_core.configuration.configuration_model_abc.ConfigurationModelABC`]] """ pass diff --git a/src/cpl_core/configuration/console_argument.py b/src/cpl_core/configuration/console_argument.py index 807f74ae..6407aa5f 100644 --- a/src/cpl_core/configuration/console_argument.py +++ b/src/cpl_core/configuration/console_argument.py @@ -17,7 +17,7 @@ class ConsoleArgument: aliases: list[:class:`str`] value_token: :class:`str` is_value_token_optional: :class:`bool` - console_arguments: List[:class:`cpl.configuration.console_argument.ConsoleArgument`] + console_arguments: List[:class:`cpl_core.configuration.console_argument.ConsoleArgument`] """ self._token = token self._name = name diff --git a/src/cpl_core/console/console.py b/src/cpl_core/console/console.py index aff76a8b..52ae7f41 100644 --- a/src/cpl_core/console/console.py +++ b/src/cpl_core/console/console.py @@ -64,7 +64,7 @@ class Console: Parameter --------- - color: Union[:class:`cpl.console.background_color_enum.BackgroundColorEnum`, :class:`str`] + color: Union[:class:`cpl_core.console.background_color_enum.BackgroundColorEnum`, :class:`str`] Background color of the console """ if type(color) is str: @@ -78,7 +78,7 @@ class Console: Parameter --------- - color: Union[:class:`cpl.console.background_color_enum.BackgroundColorEnum`, :class:`str`] + color: Union[:class:`cpl_core.console.background_color_enum.BackgroundColorEnum`, :class:`str`] Foreground color of the console """ if type(color) is str: @@ -365,17 +365,17 @@ class Console: Message or header of the selection options: List[:class:`str`] Selectable options - header_foreground_color: Union[:class:`str`, :class:`cpl.console.foreground_color_enum.ForegroundColorEnum`] + header_foreground_color: Union[:class:`str`, :class:`cpl_core.console.foreground_color_enum.ForegroundColorEnum`] Foreground color of the header - header_background_color: Union[:class:`str`, :class:`cpl.console.background_color_enum.BackgroundColorEnum`] + header_background_color: Union[:class:`str`, :class:`cpl_core.console.background_color_enum.BackgroundColorEnum`] Background color of the header - option_foreground_color: Union[:class:`str`, :class:`cpl.console.foreground_color_enum.ForegroundColorEnum`] + option_foreground_color: Union[:class:`str`, :class:`cpl_core.console.foreground_color_enum.ForegroundColorEnum`] Foreground color of the options - option_background_color: Union[:class:`str`, :class:`cpl.console.background_color_enum.BackgroundColorEnum`] + option_background_color: Union[:class:`str`, :class:`cpl_core.console.background_color_enum.BackgroundColorEnum`] Background color of the options - cursor_foreground_color: Union[:class:`str`, :class:`cpl.console.foreground_color_enum.ForegroundColorEnum`] + cursor_foreground_color: Union[:class:`str`, :class:`cpl_core.console.foreground_color_enum.ForegroundColorEnum`] Foreground color of the cursor - cursor_background_color: Union[:class:`str`, :class:`cpl.console.background_color_enum.BackgroundColorEnum`] + cursor_background_color: Union[:class:`str`, :class:`cpl_core.console.background_color_enum.BackgroundColorEnum`] Background color of the cursor Returns @@ -423,13 +423,13 @@ class Console: Function to call args: :class:`list` Arguments of the function - text_foreground_color: Union[:class:`str`, :class:`cpl.console.foreground_color_enum.ForegroundColorEnum`] + text_foreground_color: Union[:class:`str`, :class:`cpl_core.console.foreground_color_enum.ForegroundColorEnum`] Foreground color of the text - spinner_foreground_color: Union[:class:`str`, :class:`cpl.console.foreground_color_enum.ForegroundColorEnum`] + spinner_foreground_color: Union[:class:`str`, :class:`cpl_core.console.foreground_color_enum.ForegroundColorEnum`] Foreground color of the spinner - text_background_color: Union[:class:`str`, :class:`cpl.console.background_color_enum.BackgroundColorEnum`] + text_background_color: Union[:class:`str`, :class:`cpl_core.console.background_color_enum.BackgroundColorEnum`] Background color of the text - spinner_background_color: Union[:class:`str`, :class:`cpl.console.background_color_enum.BackgroundColorEnum`] + spinner_background_color: Union[:class:`str`, :class:`cpl_core.console.background_color_enum.BackgroundColorEnum`] Background color of the spinner kwargs: :class:`dict` Keyword arguments of the call diff --git a/src/cpl_core/console/spinner_thread.py b/src/cpl_core/console/spinner_thread.py index 43afcb25..681ba234 100644 --- a/src/cpl_core/console/spinner_thread.py +++ b/src/cpl_core/console/spinner_thread.py @@ -16,9 +16,9 @@ class SpinnerThread(threading.Thread): --------- msg_len: :class:`int` Length of the message - foreground_color: :class:`cpl.console.foreground_color.ForegroundColorEnum` + foreground_color: :class:`cpl_core.console.foreground_color.ForegroundColorEnum` Foreground color of the spinner - background_color: :class:`cpl.console.background_color.BackgroundColorEnum` + background_color: :class:`cpl_core.console.background_color.BackgroundColorEnum` Background color of the spinner """ diff --git a/src/cpl_core/database/connection/database_connection.py b/src/cpl_core/database/connection/database_connection.py index d889d240..6f73363c 100644 --- a/src/cpl_core/database/connection/database_connection.py +++ b/src/cpl_core/database/connection/database_connection.py @@ -14,7 +14,7 @@ class DatabaseConnection(DatabaseConnectionABC): Parameter --------- - database_settings: :class:`cpl.database.database_settings.DatabaseSettings` + database_settings: :class:`cpl_core.database.database_settings.DatabaseSettings` """ def __init__(self, database_settings: DatabaseSettings): diff --git a/src/cpl_core/database/connection/database_connection_abc.py b/src/cpl_core/database/connection/database_connection_abc.py index 637c1da7..976147e1 100644 --- a/src/cpl_core/database/connection/database_connection_abc.py +++ b/src/cpl_core/database/connection/database_connection_abc.py @@ -5,7 +5,7 @@ from sqlalchemy.orm import Session class DatabaseConnectionABC(ABC): - r"""ABC for the :class:`cpl.database.connection.database_connection.DatabaseConnection`""" + r"""ABC for the :class:`cpl_core.database.connection.database_connection.DatabaseConnection`""" @abstractmethod def __init__(self): pass diff --git a/src/cpl_core/database/context/database_context.py b/src/cpl_core/database/context/database_context.py index 922c07e7..f706cfc9 100644 --- a/src/cpl_core/database/context/database_context.py +++ b/src/cpl_core/database/context/database_context.py @@ -15,7 +15,7 @@ class DatabaseContext(DatabaseContextABC): Parameter --------- - database_settings: :class:`cpl.database.database_settings.DatabaseSettings` + database_settings: :class:`cpl_core.database.database_settings.DatabaseSettings` """ def __init__(self, database_settings: DatabaseSettings): diff --git a/src/cpl_core/database/context/database_context_abc.py b/src/cpl_core/database/context/database_context_abc.py index 0587560c..09903d86 100644 --- a/src/cpl_core/database/context/database_context_abc.py +++ b/src/cpl_core/database/context/database_context_abc.py @@ -5,7 +5,7 @@ from sqlalchemy.orm import Session class DatabaseContextABC(ABC): - r"""ABC for the :class:`cpl.database.context.database_context.DatabaseContext`""" + r"""ABC for the :class:`cpl_core.database.context.database_context.DatabaseContext`""" @abstractmethod def __init__(self, *args): diff --git a/src/cpl_core/dependency_injection/service_collection_abc.py b/src/cpl_core/dependency_injection/service_collection_abc.py index 5f05217e..e597ec40 100644 --- a/src/cpl_core/dependency_injection/service_collection_abc.py +++ b/src/cpl_core/dependency_injection/service_collection_abc.py @@ -8,7 +8,7 @@ from cpl_core.dependency_injection.service_provider_abc import ServiceProviderAB class ServiceCollectionABC(ABC): - r"""ABC for the class :class:`cpl.dependency_injection.service_collection.ServiceCollection`""" + r"""ABC for the class :class:`cpl_core.dependency_injection.service_collection.ServiceCollection`""" @abstractmethod def __init__(self): @@ -20,9 +20,9 @@ class ServiceCollectionABC(ABC): Parameter --------- - db_context: Type[:class:`cpl.database.context.database_context_abc.DatabaseContextABC`] + db_context: Type[:class:`cpl_core.database.context.database_context_abc.DatabaseContextABC`] Database context - db_settings: :class:`cpl.database.database_settings.DatabaseSettings` + db_settings: :class:`cpl_core.database.database_settings.DatabaseSettings` Database settings """ pass @@ -77,6 +77,6 @@ class ServiceCollectionABC(ABC): Returns ------- - Object of type :class:`cpl.dependency_injection.service_provider_abc.ServiceProviderABC` + Object of type :class:`cpl_core.dependency_injection.service_provider_abc.ServiceProviderABC` """ pass diff --git a/src/cpl_core/dependency_injection/service_descriptor.py b/src/cpl_core/dependency_injection/service_descriptor.py index 01eea5ce..2188ffd0 100644 --- a/src/cpl_core/dependency_injection/service_descriptor.py +++ b/src/cpl_core/dependency_injection/service_descriptor.py @@ -10,7 +10,7 @@ class ServiceDescriptor: --------- implementation: Union[:class:`type`, Optional[:class:`object`]] Object or type of service - lifetime: :class:`cpl.dependency_injection.service_lifetime_enum.ServiceLifetimeEnum` + lifetime: :class:`cpl_core.dependency_injection.service_lifetime_enum.ServiceLifetimeEnum` Lifetime of the service """ diff --git a/src/cpl_core/dependency_injection/service_provider.py b/src/cpl_core/dependency_injection/service_provider.py index 62769b9e..6357716d 100644 --- a/src/cpl_core/dependency_injection/service_provider.py +++ b/src/cpl_core/dependency_injection/service_provider.py @@ -16,11 +16,11 @@ class ServiceProvider(ServiceProviderABC): Parameter --------- - service_descriptors: list[:class:`cpl.dependency_injection.service_descriptor.ServiceDescriptor`] + service_descriptors: list[:class:`cpl_core.dependency_injection.service_descriptor.ServiceDescriptor`] Descriptor of the service - config: :class:`cpl.configuration.configuration_abc.ConfigurationABC` + config: :class:`cpl_core.configuration.configuration_abc.ConfigurationABC` CPL Configuration - db_context: Optional[:class:`cpl.database.context.database_context_abc.DatabaseContextABC`] + db_context: Optional[:class:`cpl_core.database.context.database_context_abc.DatabaseContextABC`] Database representation """ diff --git a/src/cpl_core/dependency_injection/service_provider_abc.py b/src/cpl_core/dependency_injection/service_provider_abc.py index 570035ad..507deb21 100644 --- a/src/cpl_core/dependency_injection/service_provider_abc.py +++ b/src/cpl_core/dependency_injection/service_provider_abc.py @@ -4,7 +4,7 @@ from typing import Type, Optional class ServiceProviderABC(ABC): - r"""ABC for the class :class:`cpl.dependency_injection.service_provider.ServiceProvider`""" + r"""ABC for the class :class:`cpl_core.dependency_injection.service_provider.ServiceProvider`""" @abstractmethod def __init__(self): diff --git a/src/cpl_core/environment/application_environment.py b/src/cpl_core/environment/application_environment.py index 1c783fbe..73f82571 100644 --- a/src/cpl_core/environment/application_environment.py +++ b/src/cpl_core/environment/application_environment.py @@ -12,7 +12,7 @@ class ApplicationEnvironment(ApplicationEnvironmentABC): Parameter --------- - name: :class:`cpl.environment.environment_name_enum.EnvironmentNameEnum` + name: :class:`cpl_core.environment.environment_name_enum.EnvironmentNameEnum` """ def __init__(self, name: EnvironmentNameEnum = EnvironmentNameEnum.production): diff --git a/src/cpl_core/environment/application_environment_abc.py b/src/cpl_core/environment/application_environment_abc.py index 7d0b82c7..f5b9bd43 100644 --- a/src/cpl_core/environment/application_environment_abc.py +++ b/src/cpl_core/environment/application_environment_abc.py @@ -3,7 +3,7 @@ from datetime import datetime class ApplicationEnvironmentABC(ABC): - r"""ABC of the class :class:`cpl.environment.application_environment.ApplicationEnvironment`""" + r"""ABC of the class :class:`cpl_core.environment.application_environment.ApplicationEnvironment`""" @abstractmethod def __init__(self): diff --git a/src/cpl_core/logging/logger_abc.py b/src/cpl_core/logging/logger_abc.py index a6bfa72f..60a878c9 100644 --- a/src/cpl_core/logging/logger_abc.py +++ b/src/cpl_core/logging/logger_abc.py @@ -2,7 +2,7 @@ from abc import abstractmethod, ABC class LoggerABC(ABC): - r"""ABC for :class:`cpl.logging.logger_service.Logger`""" + r"""ABC for :class:`cpl_core.logging.logger_service.Logger`""" @abstractmethod def __init__(self): diff --git a/src/cpl_core/logging/logger_service.py b/src/cpl_core/logging/logger_service.py index 6c8d352a..c7622364 100644 --- a/src/cpl_core/logging/logger_service.py +++ b/src/cpl_core/logging/logger_service.py @@ -17,11 +17,11 @@ class Logger(LoggerABC): Parameter --------- - logging_settings: :class:`cpl.logging.logging_settings.LoggingSettings` + logging_settings: :class:`cpl_core.logging.logging_settings.LoggingSettings` Settings for the logger - time_format: :class:`cpl.time.time_format_settings.TimeFormatSettings` + time_format: :class:`cpl_core.time.time_format_settings.TimeFormatSettings` Time format settings - env: :class:`cpl.environment.application_environment_abc.ApplicationEnvironmentABC` + env: :class:`cpl_core.environment.application_environment_abc.ApplicationEnvironmentABC` Environment of the application """ @@ -116,7 +116,7 @@ class Logger(LoggerABC): --------- name: :class:`str` Name of the message - level: :class:`cpl.logging.logging_level_enum.LoggingLevelEnum` + level: :class:`cpl_core.logging.logging_level_enum.LoggingLevelEnum` Logging level message: :class:`str` Log message diff --git a/src/cpl_core/mailing/email_client_abc.py b/src/cpl_core/mailing/email_client_abc.py index 9d60e35b..ae103e60 100644 --- a/src/cpl_core/mailing/email_client_abc.py +++ b/src/cpl_core/mailing/email_client_abc.py @@ -4,7 +4,7 @@ from cpl_core.mailing.email import EMail class EMailClientABC(ABC): - """ABC of :class:`cpl.mailing.email_client_service.EMailClient`""" + """ABC of :class:`cpl_core.mailing.email_client_service.EMailClient`""" @abstractmethod def __init__(self): @@ -21,7 +21,7 @@ class EMailClientABC(ABC): Parameter --------- - email: :class:`cpl.mailing.email.EMail` + email: :class:`cpl_core.mailing.email.EMail` Object of the E-Mail to send """ pass diff --git a/src/cpl_core/mailing/email_client_service.py b/src/cpl_core/mailing/email_client_service.py index 4d45248e..2a811e1b 100644 --- a/src/cpl_core/mailing/email_client_service.py +++ b/src/cpl_core/mailing/email_client_service.py @@ -15,11 +15,11 @@ class EMailClient(EMailClientABC): Parameter --------- - environment: :class:`cpl.environment.application_environment_abc.ApplicationEnvironmentABC` + environment: :class:`cpl_core.environment.application_environment_abc.ApplicationEnvironmentABC` Environment of the application - logger: :class:`cpl.logging.logger_abc.LoggerABC` + logger: :class:`cpl_core.logging.logger_abc.LoggerABC` The logger to use - mail_settings: :class:`cpl.mailing.email_client_settings.EMailClientSettings` + mail_settings: :class:`cpl_core.mailing.email_client_settings.EMailClientSettings` Settings for mailing """ diff --git a/src/tests/custom/general/src/general/startup.py b/src/tests/custom/general/src/general/startup.py index 3314b852..3882d130 100644 --- a/src/tests/custom/general/src/general/startup.py +++ b/src/tests/custom/general/src/general/startup.py @@ -2,6 +2,7 @@ from cpl_core.application.startup_abc import StartupABC from cpl_core.configuration.configuration_abc import ConfigurationABC from cpl_core.dependency_injection.service_collection_abc import ServiceCollectionABC from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC +from cpl_core.environment import ApplicationEnvironmentABC from cpl_core.logging.logger_service import Logger from cpl_core.logging.logger_abc import LoggerABC from cpl_core.mailing.email_client_service import EMailClient @@ -11,24 +12,21 @@ from test_service import TestService class Startup(StartupABC): - def __init__(self, config: ConfigurationABC, services: ServiceCollectionABC): + def __init__(self): StartupABC.__init__(self) - self._configuration = config - self._services = services + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC) -> ConfigurationABC: + config.add_environment_variables('PYTHON_') + config.add_environment_variables('CPL_') + config.add_json_file(f'appsettings.json') + config.add_json_file(f'appsettings.{config.environment.environment_name}.json') + config.add_json_file(f'appsettings.{config.environment.host_name}.json', optional=True) - def configure_configuration(self) -> ConfigurationABC: - self._configuration.add_environment_variables('PYTHON_') - self._configuration.add_environment_variables('CPL_') - self._configuration.add_json_file(f'appsettings.json') - self._configuration.add_json_file(f'appsettings.{self._configuration.environment.environment_name}.json') - self._configuration.add_json_file(f'appsettings.{self._configuration.environment.host_name}.json', optional=True) + return config - return self._configuration + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC) -> ServiceProviderABC: + services.add_singleton(LoggerABC, Logger) + services.add_singleton(EMailClientABC, EMailClient) + services.add_singleton(TestService) - def configure_services(self) -> ServiceProviderABC: - self._services.add_singleton(LoggerABC, Logger) - self._services.add_singleton(EMailClientABC, EMailClient) - self._services.add_singleton(TestService) - - return self._services.build_service_provider() + return services.build_service_provider()