Compare commits
5 Commits
2025.09.17
...
2025.09.17
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c6078f4fd | |||
| dfdc31512d | |||
| ab7ff7da93 | |||
| 41087a838b | |||
| 836b92ccbf |
@@ -1,10 +1,17 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Callable, Self
|
||||
|
||||
from cpl.application.host import Host
|
||||
from cpl.core.console.console import Console
|
||||
from cpl.core.environment import Environment
|
||||
from cpl.core.log import LoggerABC, LogLevel
|
||||
from cpl.dependency.service_provider_abc import ServiceProviderABC
|
||||
|
||||
|
||||
def __not_implemented__(package: str, func: Callable):
|
||||
raise NotImplementedError(f"Package {package} is required to use {func.__name__} method")
|
||||
|
||||
|
||||
class ApplicationABC(ABC):
|
||||
r"""ABC for the Application class
|
||||
|
||||
@@ -17,6 +24,50 @@ class ApplicationABC(ABC):
|
||||
def __init__(self, services: ServiceProviderABC):
|
||||
self._services = services
|
||||
|
||||
@classmethod
|
||||
def extend(cls, name: str | Callable, func: Callable[[Self], Self]):
|
||||
r"""Extend the Application with a custom method
|
||||
|
||||
Parameters:
|
||||
name: :class:`str`
|
||||
Name of the method
|
||||
func: :class:`Callable[[Self], Self]`
|
||||
Function that takes the Application as a parameter and returns it
|
||||
"""
|
||||
if callable(name):
|
||||
name = name.__name__
|
||||
|
||||
setattr(cls, name, func)
|
||||
return cls
|
||||
|
||||
def with_logging(self, level: LogLevel = None):
|
||||
if level is None:
|
||||
level = Environment.get("LOG_LEVEL", LogLevel, LogLevel.info)
|
||||
|
||||
logger = self._services.get_service(LoggerABC)
|
||||
logger.set_level(level)
|
||||
|
||||
def with_permissions(self, *args, **kwargs):
|
||||
__not_implemented__("cpl-auth", self.with_permissions)
|
||||
|
||||
def with_migrations(self, *args, **kwargs):
|
||||
__not_implemented__("cpl-database", self.with_migrations)
|
||||
|
||||
def with_seeders(self, *args, **kwargs):
|
||||
__not_implemented__("cpl-database", self.with_seeders)
|
||||
|
||||
def with_extension(self, func: Callable[[Self, ...], None], *args, **kwargs):
|
||||
r"""Extend the Application with a custom method
|
||||
|
||||
Parameters:
|
||||
func: :class:`Callable[[Self], Self]`
|
||||
Function that takes the Application as a parameter and returns it
|
||||
"""
|
||||
assert func is not None, "func must not be None"
|
||||
assert callable(func), "func must be callable"
|
||||
|
||||
func(self, *args, **kwargs)
|
||||
|
||||
def run(self):
|
||||
r"""Entry point
|
||||
|
||||
@@ -28,6 +79,4 @@ class ApplicationABC(ABC):
|
||||
Console.close()
|
||||
|
||||
@abstractmethod
|
||||
def main(self):
|
||||
r"""Main method of application"""
|
||||
pass
|
||||
def main(self): ...
|
||||
|
||||
@@ -4,10 +4,7 @@ from cpl.dependency import ServiceProviderABC
|
||||
|
||||
|
||||
class ApplicationExtensionABC(ABC):
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def run(self, services: ServiceProviderABC):
|
||||
pass
|
||||
def run(services: ServiceProviderABC): ...
|
||||
|
||||
@@ -6,17 +6,14 @@ from cpl.dependency.service_collection import ServiceCollection
|
||||
class StartupABC(ABC):
|
||||
r"""ABC for the startup class"""
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
def configure_configuration():
|
||||
r"""Creates configuration of application"""
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def configure_configuration(self):
|
||||
r"""Creates configuration of application
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def configure_services(self, service: ServiceCollection):
|
||||
def configure_services(service: ServiceCollection):
|
||||
r"""Creates service provider
|
||||
|
||||
Parameter:
|
||||
|
||||
@@ -6,18 +6,14 @@ from cpl.dependency import ServiceCollection
|
||||
class StartupExtensionABC(ABC):
|
||||
r"""ABC for startup extension classes"""
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
def configure_configuration():
|
||||
r"""Creates configuration of application"""
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def configure_configuration(self):
|
||||
r"""Creates configuration of application
|
||||
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def configure_services(self, services: ServiceCollection):
|
||||
def configure_services(services: ServiceCollection):
|
||||
r"""Creates service provider
|
||||
Parameter:
|
||||
services: :class:`cpl.dependency.service_collection`
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import asyncio
|
||||
from typing import Type, Optional, Callable
|
||||
from typing import Type, Optional
|
||||
|
||||
from cpl.application.abc.application_abc import ApplicationABC
|
||||
from cpl.application.abc.application_extension_abc import ApplicationExtensionABC
|
||||
@@ -34,11 +34,11 @@ class ApplicationBuilder:
|
||||
def service_provider(self):
|
||||
return self._services.build()
|
||||
|
||||
def use_startup(self, startup: Type[StartupABC]) -> "ApplicationBuilder":
|
||||
self._startup = startup()
|
||||
def with_startup(self, startup: Type[StartupABC]) -> "ApplicationBuilder":
|
||||
self._startup = startup
|
||||
return self
|
||||
|
||||
def use_extension(
|
||||
def with_extension(
|
||||
self,
|
||||
extension: Type[ApplicationExtensionABC | StartupExtensionABC],
|
||||
) -> "ApplicationBuilder":
|
||||
@@ -50,8 +50,7 @@ class ApplicationBuilder:
|
||||
return self
|
||||
|
||||
def build(self) -> ApplicationABC:
|
||||
for ex in self._startup_extensions:
|
||||
extension = ex()
|
||||
for extension in self._startup_extensions:
|
||||
Host.run(extension.configure_configuration)
|
||||
Host.run(extension.configure_services, self._services)
|
||||
|
||||
@@ -59,8 +58,7 @@ class ApplicationBuilder:
|
||||
Host.run(self._startup.configure_configuration)
|
||||
Host.run(self._startup.configure_services, self._services)
|
||||
|
||||
for ex in self._app_extensions:
|
||||
extension = ex()
|
||||
for extension in self._app_extensions:
|
||||
Host.run(extension.run, self.service_provider)
|
||||
|
||||
return self._app(self.service_provider)
|
||||
|
||||
@@ -14,4 +14,4 @@ class Host:
|
||||
if asyncio.iscoroutinefunction(func):
|
||||
return cls._loop.run_until_complete(func(*args, **kwargs))
|
||||
|
||||
return func(*args, **kwargs)
|
||||
return func(*args, **kwargs)
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
from cpl.auth import permission as _permission
|
||||
from cpl.auth.keycloak.keycloak_admin import KeycloakAdmin
|
||||
from cpl.auth.keycloak.keycloak_client import KeycloakClient
|
||||
from cpl.dependency import ServiceCollection as _ServiceCollection
|
||||
from enum import Enum
|
||||
from typing import Type
|
||||
|
||||
from cpl.application.abc import ApplicationABC as _ApplicationABC
|
||||
from cpl.auth import permission as _permission
|
||||
from cpl.auth.keycloak.keycloak_admin import KeycloakAdmin as _KeycloakAdmin
|
||||
from cpl.auth.keycloak.keycloak_client import KeycloakClient as _KeycloakClient
|
||||
from cpl.dependency.service_collection import ServiceCollection as _ServiceCollection
|
||||
from .auth_logger import AuthLogger
|
||||
from .keycloak_settings import KeycloakSettings
|
||||
from .permission_seeder import PermissionSeeder
|
||||
|
||||
|
||||
def _with_permissions(self: _ApplicationABC, *permissions: Type[Enum]) -> _ApplicationABC:
|
||||
from cpl.auth.permission.permissions_registry import PermissionsRegistry
|
||||
|
||||
for perm in permissions:
|
||||
PermissionsRegistry.with_enum(perm)
|
||||
return self
|
||||
|
||||
|
||||
def _add_daos(collection: _ServiceCollection):
|
||||
from .schema._administration.auth_user_dao import AuthUserDao
|
||||
from .schema._administration.api_key_dao import ApiKeyDao
|
||||
@@ -34,8 +45,8 @@ def add_auth(collection: _ServiceCollection):
|
||||
from cpl.database.model.server_type import ServerType, ServerTypes
|
||||
|
||||
try:
|
||||
collection.add_singleton(KeycloakClient)
|
||||
collection.add_singleton(KeycloakAdmin)
|
||||
collection.add_singleton(_KeycloakClient)
|
||||
collection.add_singleton(_KeycloakAdmin)
|
||||
|
||||
_add_daos(collection)
|
||||
|
||||
@@ -68,3 +79,4 @@ def add_permission(collection: _ServiceCollection):
|
||||
|
||||
_ServiceCollection.with_module(add_auth, __name__)
|
||||
_ServiceCollection.with_module(add_permission, _permission.__name__)
|
||||
_ApplicationABC.extend(_ApplicationABC.with_permissions, _with_permissions)
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing import Optional
|
||||
from async_property import async_property
|
||||
from keycloak import KeycloakGetError
|
||||
|
||||
from cpl.auth import KeycloakAdmin
|
||||
from cpl.auth.keycloak import KeycloakAdmin
|
||||
from cpl.auth.auth_logger import AuthLogger
|
||||
from cpl.auth.permission.permissions import Permissions
|
||||
from cpl.core.typing import SerialId
|
||||
|
||||
@@ -2,4 +2,6 @@ from abc import ABC
|
||||
|
||||
|
||||
class ConfigurationModelABC(ABC):
|
||||
pass
|
||||
r"""
|
||||
ABC for configuration model classes
|
||||
"""
|
||||
|
||||
@@ -3,7 +3,7 @@ from socket import gethostname
|
||||
from typing import Optional, Type
|
||||
|
||||
from cpl.core.environment.environment_enum import EnvironmentEnum
|
||||
from cpl.core.typing import T
|
||||
from cpl.core.typing import T, D
|
||||
from cpl.core.utils.get_value import get_value
|
||||
|
||||
|
||||
@@ -55,14 +55,14 @@ class Environment:
|
||||
os.environ[key] = str(value)
|
||||
|
||||
@staticmethod
|
||||
def get(key: str, cast_type: Type[T], default: Optional[T] = None) -> Optional[T]:
|
||||
def get(key: str, cast_type: Type[T], default: D = None) -> T | D:
|
||||
"""
|
||||
Get an environment variable and cast it to a specified type.
|
||||
:param str key: The name of the environment variable.
|
||||
:param Type[T] cast_type: A callable to cast the variable's value.
|
||||
:param Optional[T] default: The default value to return if the variable is not found. Defaults to None.The default value to return if the variable is not found. Defaults to None.
|
||||
:param T default: The default value to return if the variable is not found. Defaults to None.The default value to return if the variable is not found. Defaults to None.
|
||||
:return: The casted value, or None if the variable is not found.
|
||||
:rtype: Optional[T]
|
||||
:rtype: T | D
|
||||
"""
|
||||
|
||||
return get_value(dict(os.environ), key, cast_type, default)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from .logger import Logger
|
||||
from .logger_abc import LoggerABC
|
||||
from .log_level_enum import LogLevelEnum
|
||||
from .log_level_enum import LogLevel
|
||||
from .logging_settings import LogSettings
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class LogLevelEnum(Enum):
|
||||
class LogLevel(Enum):
|
||||
off = "OFF" # Nothing
|
||||
trace = "TRC" # Detailed app information's
|
||||
debug = "DEB" # Detailed app state
|
||||
|
||||
@@ -3,28 +3,31 @@ import traceback
|
||||
from datetime import datetime
|
||||
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.log.log_level_enum import LogLevelEnum
|
||||
from cpl.core.log.log_level_enum import LogLevel
|
||||
from cpl.core.log.logger_abc import LoggerABC
|
||||
from cpl.core.typing import Messages, Source
|
||||
|
||||
|
||||
class Logger(LoggerABC):
|
||||
_level = LogLevelEnum.info
|
||||
_levels = [x for x in LogLevelEnum]
|
||||
_level = LogLevel.info
|
||||
_levels = [x for x in LogLevel]
|
||||
|
||||
# ANSI color codes for different log levels
|
||||
_COLORS = {
|
||||
LogLevelEnum.trace: "\033[37m", # Light Gray
|
||||
LogLevelEnum.debug: "\033[94m", # Blue
|
||||
LogLevelEnum.info: "\033[92m", # Green
|
||||
LogLevelEnum.warning: "\033[93m", # Yellow
|
||||
LogLevelEnum.error: "\033[91m", # Red
|
||||
LogLevelEnum.fatal: "\033[95m", # Magenta
|
||||
LogLevel.trace: "\033[37m", # Light Gray
|
||||
LogLevel.debug: "\033[94m", # Blue
|
||||
LogLevel.info: "\033[92m", # Green
|
||||
LogLevel.warning: "\033[93m", # Yellow
|
||||
LogLevel.error: "\033[91m", # Red
|
||||
LogLevel.fatal: "\033[95m", # Magenta
|
||||
}
|
||||
|
||||
def __init__(self, source: Source, file_prefix: str = None):
|
||||
LoggerABC.__init__(self)
|
||||
assert source is not None and source != "", "Source cannot be None or empty"
|
||||
|
||||
if source == LoggerABC.__name__:
|
||||
source = None
|
||||
|
||||
self._source = source
|
||||
|
||||
if file_prefix is None:
|
||||
@@ -45,7 +48,7 @@ class Logger(LoggerABC):
|
||||
os.makedirs("logs")
|
||||
|
||||
@classmethod
|
||||
def set_level(cls, level: LogLevelEnum):
|
||||
def set_level(cls, level: LogLevel):
|
||||
if level in cls._levels:
|
||||
cls._level = level
|
||||
else:
|
||||
@@ -69,7 +72,7 @@ class Logger(LoggerABC):
|
||||
log_file.write(content + "\n")
|
||||
log_file.close()
|
||||
|
||||
def _log(self, level: LogLevelEnum, *messages: Messages):
|
||||
def _log(self, level: LogLevel, *messages: Messages):
|
||||
try:
|
||||
if self._levels.index(level) < self._levels.index(self._level):
|
||||
return
|
||||
@@ -78,7 +81,7 @@ class Logger(LoggerABC):
|
||||
formatted_message = self._format_message(level.value, timestamp, *messages)
|
||||
|
||||
self._write_log_to_file(formatted_message)
|
||||
Console.write_line(f"{self._COLORS.get(self._level, '\033[0m')}{formatted_message}\033[0m")
|
||||
Console.write_line(f"{self._COLORS.get(level, '\033[0m')}{formatted_message}\033[0m")
|
||||
except Exception as e:
|
||||
print(f"Error while logging: {e} -> {traceback.format_exc()}")
|
||||
|
||||
@@ -91,27 +94,35 @@ class Logger(LoggerABC):
|
||||
|
||||
messages = [str(message) for message in messages if message is not None]
|
||||
|
||||
return f"<{timestamp}> [{level.upper():^3}] [{self._file_prefix}] - [{self._source}]: {' '.join(messages)}"
|
||||
message = f"<{timestamp}>"
|
||||
message += f" [{level.upper():^3}]"
|
||||
message += f" [{self._file_prefix}]"
|
||||
if self._source is not None:
|
||||
message += f" - [{self._source}]"
|
||||
|
||||
message += f": {' '.join(messages)}"
|
||||
|
||||
return message
|
||||
|
||||
def header(self, string: str):
|
||||
self._log(LogLevelEnum.info, string)
|
||||
self._log(LogLevel.info, string)
|
||||
|
||||
def trace(self, *messages: Messages):
|
||||
self._log(LogLevelEnum.trace, *messages)
|
||||
self._log(LogLevel.trace, *messages)
|
||||
|
||||
def debug(self, *messages: Messages):
|
||||
self._log(LogLevelEnum.debug, *messages)
|
||||
self._log(LogLevel.debug, *messages)
|
||||
|
||||
def info(self, *messages: Messages):
|
||||
self._log(LogLevelEnum.info, *messages)
|
||||
self._log(LogLevel.info, *messages)
|
||||
|
||||
def warning(self, *messages: Messages):
|
||||
self._log(LogLevelEnum.warning, *messages)
|
||||
self._log(LogLevel.warning, *messages)
|
||||
|
||||
def error(self, message, e: Exception = None):
|
||||
self._log(LogLevelEnum.error, message, f"{e} -> {traceback.format_exc()}" if e else None)
|
||||
self._log(LogLevel.error, message, f"{e} -> {traceback.format_exc()}" if e else None)
|
||||
|
||||
def fatal(self, message, e: Exception = None, prevent_quit: bool = False):
|
||||
self._log(LogLevelEnum.fatal, message, f"{e} -> {traceback.format_exc()}" if e else None)
|
||||
self._log(LogLevel.fatal, message, f"{e} -> {traceback.format_exc()}" if e else None)
|
||||
if not prevent_quit:
|
||||
exit(-1)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from abc import abstractmethod, ABC
|
||||
|
||||
from cpl.core.log.log_level_enum import LogLevel
|
||||
from cpl.core.typing import Messages
|
||||
|
||||
|
||||
@@ -7,12 +8,10 @@ class LoggerABC(ABC):
|
||||
r"""ABC for :class:`cpl.core.log.logger_service.Logger`"""
|
||||
|
||||
@abstractmethod
|
||||
def set_level(self, level: str):
|
||||
pass
|
||||
def set_level(self, level: LogLevel): ...
|
||||
|
||||
@abstractmethod
|
||||
def _format_message(self, level: str, timestamp, *messages: Messages) -> str:
|
||||
pass
|
||||
def _format_message(self, level: str, timestamp, *messages: Messages) -> str: ...
|
||||
|
||||
@abstractmethod
|
||||
def header(self, string: str):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from typing import Optional
|
||||
|
||||
from cpl.core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
from cpl.core.log.log_level_enum import LogLevelEnum
|
||||
from cpl.core.log.log_level_enum import LogLevel
|
||||
|
||||
|
||||
class LogSettings(ConfigurationModelABC):
|
||||
@@ -11,14 +11,14 @@ class LogSettings(ConfigurationModelABC):
|
||||
self,
|
||||
path: str = None,
|
||||
filename: str = None,
|
||||
console_log_level: LogLevelEnum = None,
|
||||
file_log_level: LogLevelEnum = None,
|
||||
console_log_level: LogLevel = None,
|
||||
file_log_level: LogLevel = None,
|
||||
):
|
||||
ConfigurationModelABC.__init__(self)
|
||||
self._path: Optional[str] = path
|
||||
self._filename: Optional[str] = filename
|
||||
self._console: Optional[LogLevelEnum] = console_log_level
|
||||
self._level: Optional[LogLevelEnum] = file_log_level
|
||||
self._console: Optional[LogLevel] = console_log_level
|
||||
self._level: Optional[LogLevel] = file_log_level
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
@@ -37,17 +37,17 @@ class LogSettings(ConfigurationModelABC):
|
||||
self._filename = filename
|
||||
|
||||
@property
|
||||
def console(self) -> LogLevelEnum:
|
||||
def console(self) -> LogLevel:
|
||||
return self._console
|
||||
|
||||
@console.setter
|
||||
def console(self, console: LogLevelEnum) -> None:
|
||||
def console(self, console: LogLevel) -> None:
|
||||
self._console = console
|
||||
|
||||
@property
|
||||
def level(self) -> LogLevelEnum:
|
||||
def level(self) -> LogLevel:
|
||||
return self._level
|
||||
|
||||
@level.setter
|
||||
def level(self, level: LogLevelEnum) -> None:
|
||||
def level(self, level: LogLevel) -> None:
|
||||
self._level = level
|
||||
|
||||
@@ -7,10 +7,8 @@ from cpl.core.typing import T
|
||||
class PipeABC(ABC, Generic[T]):
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def to_str(value: T, *args) -> str:
|
||||
pass
|
||||
def to_str(value: T, *args) -> str: ...
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def from_str(value: str, *args) -> T:
|
||||
pass
|
||||
def from_str(value: str, *args) -> T: ...
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from enum import Enum
|
||||
from typing import Type, Optional
|
||||
|
||||
from cpl.core.typing import T
|
||||
@@ -40,6 +41,19 @@ def get_value(
|
||||
if cast_type == bool:
|
||||
return value.lower() in ["true", "1"]
|
||||
|
||||
if issubclass(cast_type, Enum):
|
||||
try:
|
||||
return cast_type(value)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
try:
|
||||
return cast_type[value]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return default
|
||||
|
||||
if (cast_type if not hasattr(cast_type, "__origin__") else cast_type.__origin__) == list:
|
||||
if not (value.startswith("[") and value.endswith("]")) and list_delimiter not in value:
|
||||
raise ValueError("List values must be enclosed in square brackets or use a delimiter.")
|
||||
|
||||
@@ -1,11 +1,31 @@
|
||||
from typing import Type
|
||||
|
||||
from cpl.application.abc import ApplicationABC as _ApplicationABC
|
||||
from cpl.dependency import ServiceCollection as _ServiceCollection
|
||||
from . import mysql as _mysql
|
||||
from . import postgres as _postgres
|
||||
from .table_manager import TableManager
|
||||
|
||||
|
||||
def _with_migrations(self: _ApplicationABC, *paths: list[str]) -> _ApplicationABC:
|
||||
from cpl.application.host import Host
|
||||
|
||||
from cpl.database.service.migration_service import MigrationService
|
||||
migration_service = self._services.get_service(MigrationService)
|
||||
migration_service.with_directory("./scripts")
|
||||
Host.run(migration_service.migrate)
|
||||
|
||||
return self
|
||||
|
||||
def _with_seeders(self: _ApplicationABC) -> _ApplicationABC:
|
||||
from cpl.database.service.seeder_service import SeederService
|
||||
from cpl.application.host import Host
|
||||
|
||||
seeder_service: SeederService = self._services.get_service(SeederService)
|
||||
Host.run(seeder_service.seed)
|
||||
return self
|
||||
|
||||
|
||||
def _add(collection: _ServiceCollection, db_context: Type, default_port: int, server_type: str):
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.configuration import Configuration
|
||||
@@ -42,6 +62,7 @@ def add_postgres(collection: _ServiceCollection):
|
||||
_add(collection, DBContext, 5432, ServerTypes.POSTGRES.value)
|
||||
|
||||
|
||||
|
||||
_ServiceCollection.with_module(add_mysql, _mysql.__name__)
|
||||
_ServiceCollection.with_module(add_postgres, _postgres.__name__)
|
||||
_ApplicationABC.extend(_ApplicationABC.with_migrations, _with_migrations)
|
||||
_ApplicationABC.extend(_ApplicationABC.with_seeders, _with_seeders)
|
||||
|
||||
@@ -9,18 +9,15 @@ class ConnectionABC(ABC):
|
||||
r"""ABC for the :class:`cpl.database.connection.database_connection.DatabaseConnection`"""
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self): ...
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def server(self) -> MySQLConnectionAbstract:
|
||||
pass
|
||||
def server(self) -> MySQLConnectionAbstract: ...
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def cursor(self) -> MySQLCursorBuffered:
|
||||
pass
|
||||
def cursor(self) -> MySQLCursorBuffered: ...
|
||||
|
||||
@abstractmethod
|
||||
def connect(self, database_settings: DatabaseSettings):
|
||||
|
||||
@@ -4,5 +4,4 @@ from abc import ABC, abstractmethod
|
||||
class DataSeederABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
async def seed(self):
|
||||
pass
|
||||
async def seed(self): ...
|
||||
|
||||
@@ -4,8 +4,7 @@ from abc import ABC, abstractmethod
|
||||
class ScopeABC(ABC):
|
||||
r"""ABC for the class :class:`cpl.dependency.scope.Scope`"""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self): ...
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
|
||||
@@ -13,8 +13,7 @@ class ServiceProviderABC(ABC):
|
||||
_provider: Optional["ServiceProviderABC"] = None
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self): ...
|
||||
|
||||
@classmethod
|
||||
def set_global_provider(cls, provider: "ServiceProviderABC"):
|
||||
@@ -37,8 +36,7 @@ class ServiceProviderABC(ABC):
|
||||
return cls._provider.get_services(instance_type, *args, **kwargs)
|
||||
|
||||
@abstractmethod
|
||||
def _build_by_signature(self, sig: Signature, origin_service_type: type) -> list[R]:
|
||||
pass
|
||||
def _build_by_signature(self, sig: Signature, origin_service_type: type) -> list[R]: ...
|
||||
|
||||
@abstractmethod
|
||||
def _build_service(self, service_type: type, *args, **kwargs) -> object:
|
||||
|
||||
@@ -5,25 +5,19 @@ from cpl.translation.translation_settings import TranslationSettings
|
||||
|
||||
class TranslationServiceABC(ABC):
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self): ...
|
||||
|
||||
@abstractmethod
|
||||
def set_default_lang(self, lang: str):
|
||||
pass
|
||||
def set_default_lang(self, lang: str): ...
|
||||
|
||||
@abstractmethod
|
||||
def set_lang(self, lang: str):
|
||||
pass
|
||||
def set_lang(self, lang: str): ...
|
||||
|
||||
@abstractmethod
|
||||
def load(self, lang: str):
|
||||
pass
|
||||
def load(self, lang: str): ...
|
||||
|
||||
@abstractmethod
|
||||
def load_by_settings(self, settings: TranslationSettings):
|
||||
pass
|
||||
def load_by_settings(self, settings: TranslationSettings): ...
|
||||
|
||||
@abstractmethod
|
||||
def translate(self, key: str) -> str:
|
||||
pass
|
||||
def translate(self, key: str) -> str: ...
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"TimeFormatSettings": {
|
||||
"DateFormat": "%Y-%m-%d",
|
||||
"TimeFormat": "%H:%M:%S",
|
||||
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||
},
|
||||
|
||||
"LoggingSettings": {
|
||||
"Path": "logs/",
|
||||
"Filename": "log_$start_time.log",
|
||||
"ConsoleLogLevel": "ERROR",
|
||||
"FileLogLevel": "WARN"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"WorkspaceSettings": {
|
||||
"DefaultProject": "async",
|
||||
"Projects": {
|
||||
"async": "src/async/async.json"
|
||||
},
|
||||
"Scripts": {}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
from cpl.application import ApplicationABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.core.console import Console
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
async def configure(self):
|
||||
pass
|
||||
|
||||
async def main(self):
|
||||
Console.write_line("Hello World")
|
||||
@@ -1,41 +0,0 @@
|
||||
{
|
||||
"ProjectSettings": {
|
||||
"Name": "async",
|
||||
"Version": {
|
||||
"Major": "0",
|
||||
"Minor": "0",
|
||||
"Micro": "0"
|
||||
},
|
||||
"Author": "",
|
||||
"AuthorEmail": "",
|
||||
"Description": "",
|
||||
"LongDescription": "",
|
||||
"URL": "",
|
||||
"CopyrightDate": "",
|
||||
"CopyrightName": "",
|
||||
"LicenseName": "",
|
||||
"LicenseDescription": "",
|
||||
"Dependencies": [
|
||||
"sh_cpl>=2021.10.0.post1"
|
||||
],
|
||||
"PythonVersion": ">=3.9.2",
|
||||
"PythonPath": {},
|
||||
"Classifiers": []
|
||||
},
|
||||
"BuildSettings": {
|
||||
"ProjectType": "console",
|
||||
"SourcePath": "",
|
||||
"OutputPath": "../../dist",
|
||||
"Main": "async.main",
|
||||
"EntryPoint": "async",
|
||||
"IncludePackageData": false,
|
||||
"Included": [],
|
||||
"Excluded": [
|
||||
"*/__pycache__",
|
||||
"*/logs",
|
||||
"*/tests"
|
||||
],
|
||||
"PackageData": {},
|
||||
"ProjectReferences": []
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import asyncio
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from application import Application
|
||||
from startup import Startup
|
||||
|
||||
|
||||
async def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.use_startup(Startup)
|
||||
app = await app_builder.build_async()
|
||||
await app.run_async()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loop = asyncio.new_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
@@ -1,17 +0,0 @@
|
||||
from cpl.application.async_startup_abc import AsyncStartupABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.dependency import ServiceProviderABC, ServiceCollection
|
||||
from cpl.core.environment import Environment
|
||||
|
||||
|
||||
class Startup(AsyncStartupABC):
|
||||
def __init__(self):
|
||||
AsyncStartupABC.__init__(self)
|
||||
|
||||
async def configure_configuration(
|
||||
self, configuration: ConfigurationABC, environment: Environment
|
||||
) -> ConfigurationABC:
|
||||
return configuration
|
||||
|
||||
async def configure_services(self, services: ServiceCollection, environment: Environment) -> ServiceProviderABC:
|
||||
return services.build()
|
||||
@@ -15,32 +15,27 @@ def test_console():
|
||||
Console.write_line("Hello World")
|
||||
Console.write("\nName: ")
|
||||
Console.write_line(" Hello", Console.read_line())
|
||||
Console.clear()
|
||||
Console.write_at(5, 5, "at 5, 5")
|
||||
Console.write_at(10, 10, "at 10, 10")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Console.write_line("Hello World\n")
|
||||
Console.clear()
|
||||
Console.spinner(
|
||||
"Test:", test_spinner, spinner_foreground_color=ForegroundColorEnum.cyan, text_foreground_color="green"
|
||||
)
|
||||
test_console()
|
||||
Console.write_line("HOLD BACK")
|
||||
# opts = [
|
||||
# 'Option 1',
|
||||
# 'Option 2',
|
||||
# 'Option 3',
|
||||
# 'Option 4'
|
||||
# ]
|
||||
# selected = Console.select(
|
||||
# '>',
|
||||
# 'Select item:',
|
||||
# opts,
|
||||
# header_foreground_color=ForegroundColorEnum.blue,
|
||||
# option_foreground_color=ForegroundColorEnum.green,
|
||||
# cursor_foreground_color=ForegroundColorEnum.red
|
||||
# )
|
||||
# Console.write_line(f'You selected: {selected}')
|
||||
# # test_console()
|
||||
#
|
||||
# Console.write_line()
|
||||
opts = ["Option 1", "Option 2", "Option 3", "Option 4"]
|
||||
selected = Console.select(
|
||||
">",
|
||||
"Select item:",
|
||||
opts,
|
||||
header_foreground_color=ForegroundColorEnum.blue,
|
||||
option_foreground_color=ForegroundColorEnum.green,
|
||||
cursor_foreground_color=ForegroundColorEnum.red,
|
||||
)
|
||||
Console.write_line(f"You selected: {selected}")
|
||||
|
||||
Console.write_line()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from cpl.application.abc.application_abc import ApplicationABC
|
||||
from cpl.auth import KeycloakAdmin
|
||||
from cpl.auth.keycloak import KeycloakAdmin
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.environment import Environment
|
||||
from cpl.core.log import LoggerABC
|
||||
@@ -14,7 +14,7 @@ class Application(ApplicationABC):
|
||||
def __init__(self, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, services)
|
||||
|
||||
self._logger: LoggerABC = services.get_service(LoggerABC)
|
||||
self._logger = services.get_service(LoggerABC)
|
||||
|
||||
async def test_daos(self):
|
||||
userDao: UserDao = self._services.get_service(UserDao)
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
from application import Application
|
||||
from cpl.application import ApplicationBuilder
|
||||
from custom_permissions import CustomPermissions
|
||||
from startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
builder = ApplicationBuilder(Application).use_startup(Startup)
|
||||
builder = ApplicationBuilder(Application).with_startup(Startup)
|
||||
app = builder.build()
|
||||
|
||||
app.with_logging()
|
||||
app.with_permissions(CustomPermissions)
|
||||
app.with_migrations("./scripts")
|
||||
app.with_seeders()
|
||||
app.run()
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
from application import Application
|
||||
from cpl.application import ApplicationBuilder
|
||||
from cpl.auth.permission.permissions_registry import PermissionsRegistry
|
||||
from cpl.core.console import Console
|
||||
from cpl.core.log import LogLevel
|
||||
from custom_permissions import CustomPermissions
|
||||
from startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
builder = ApplicationBuilder(Application).use_startup(Startup)
|
||||
builder = ApplicationBuilder(Application).with_startup(Startup)
|
||||
builder.services.add_logging()
|
||||
|
||||
app = builder.build()
|
||||
|
||||
app.with_logging(LogLevel.trace)
|
||||
app.with_permissions(CustomPermissions)
|
||||
app.with_migrations("./scripts")
|
||||
app.with_seeders()
|
||||
|
||||
Console.write_line(CustomPermissions.test.value in PermissionsRegistry.get())
|
||||
app.run()
|
||||
Console.write_line("Hello from main_simplified.py!")
|
||||
|
||||
|
||||
@@ -1,30 +1,26 @@
|
||||
from cpl import auth
|
||||
from cpl.application.abc.startup_abc import StartupABC
|
||||
from cpl.auth import permission
|
||||
from cpl.auth.permission.permissions_registry import PermissionsRegistry
|
||||
from cpl.core.configuration import Configuration
|
||||
from cpl.core.environment import Environment
|
||||
from cpl.core.log import Logger, LoggerABC
|
||||
from cpl.database import mysql
|
||||
from cpl.database.abc.data_access_object_abc import DataAccessObjectABC
|
||||
from cpl.database.service.migration_service import MigrationService
|
||||
from cpl.database.service.seeder_service import SeederService
|
||||
from cpl.dependency import ServiceCollection
|
||||
from custom_permissions import CustomPermissions
|
||||
from model.city_dao import CityDao
|
||||
from model.user_dao import UserDao
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
async def configure_configuration(self):
|
||||
@staticmethod
|
||||
async def configure_configuration():
|
||||
Configuration.add_json_file(f"appsettings.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_environment()}.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_host_name()}.json", optional=True)
|
||||
|
||||
async def configure_services(self, services: ServiceCollection):
|
||||
@staticmethod
|
||||
async def configure_services(services: ServiceCollection):
|
||||
services.add_module(mysql)
|
||||
services.add_module(auth)
|
||||
services.add_module(permission)
|
||||
@@ -33,13 +29,3 @@ class Startup(StartupABC):
|
||||
services.add_transient(DataAccessObjectABC, CityDao)
|
||||
|
||||
services.add_singleton(LoggerABC, Logger)
|
||||
|
||||
PermissionsRegistry.with_enum(CustomPermissions)
|
||||
|
||||
provider = services.build()
|
||||
migration_service: MigrationService = provider.get_service(MigrationService)
|
||||
|
||||
migration_service.with_directory("./scripts")
|
||||
await migration_service.migrate()
|
||||
seeder_service: SeederService = provider.get_service(SeederService)
|
||||
await seeder_service.seed()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from cpl.application import ApplicationABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.application.abc import ApplicationABC
|
||||
from cpl.core.console.console import Console
|
||||
from cpl.dependency import ServiceProviderABC
|
||||
from cpl.dependency.scope import Scope
|
||||
@@ -11,15 +10,14 @@ from di.tester import Tester
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
def __init__(self, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, services)
|
||||
|
||||
def _part_of_scoped(self):
|
||||
ts: TestService = self._services.get_service(TestService)
|
||||
ts.run()
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
def configure(self): ...
|
||||
|
||||
def main(self):
|
||||
with self._services.create_scope() as scope:
|
||||
|
||||
@@ -6,7 +6,7 @@ from di.startup import Startup
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.use_startup(Startup)
|
||||
app_builder.with_startup(Startup)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
from cpl.application import StartupABC
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.application.abc import StartupABC
|
||||
from cpl.dependency import ServiceProviderABC, ServiceCollection
|
||||
from cpl.core.environment import Environment
|
||||
from di.di_tester_service import DITesterService
|
||||
from di.test1_service import Test1Service
|
||||
from di.test2_service import Test2Service
|
||||
from di.test_abc import TestABC
|
||||
from di.test_service import TestService
|
||||
from di.di_tester_service import DITesterService
|
||||
from di.tester import Tester
|
||||
|
||||
|
||||
@@ -14,10 +12,9 @@ class Startup(StartupABC):
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
def configure_configuration(self, configuration: ConfigurationABC, environment: Environment) -> ConfigurationABC:
|
||||
return configuration
|
||||
def configure_configuration(self): ...
|
||||
|
||||
def configure_services(self, services: ServiceCollection, environment: Environment) -> ServiceProviderABC:
|
||||
def configure_services(self, services: ServiceCollection) -> ServiceProviderABC:
|
||||
services.add_scoped(TestService)
|
||||
services.add_scoped(DITesterService)
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from cpl.core.configuration import ConfigurationABC
|
||||
from cpl.dependency import ServiceProvider, ServiceProviderABC
|
||||
from di.test_service import TestService
|
||||
|
||||
@@ -6,5 +5,5 @@ from di.test_service import TestService
|
||||
class StaticTest:
|
||||
@staticmethod
|
||||
@ServiceProvider.inject
|
||||
def test(services: ServiceProviderABC, config: ConfigurationABC, t1: TestService):
|
||||
def test(services: ServiceProviderABC, t1: TestService):
|
||||
t1.run()
|
||||
|
||||
@@ -6,7 +6,7 @@ from cpl.core.utils.string import String
|
||||
|
||||
class TestService:
|
||||
def __init__(self):
|
||||
self._name = String.random_string(string.ascii_lowercase, 8)
|
||||
self._name = String.random(8)
|
||||
|
||||
def run(self):
|
||||
Console.write_line(f"Im {self._name}")
|
||||
|
||||
@@ -7,9 +7,9 @@ from test_startup_extension import TestStartupExtension
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.use_startup(Startup)
|
||||
app_builder.use_extension(TestStartupExtension)
|
||||
app_builder.use_extension(TestExtension)
|
||||
app_builder.with_startup(Startup)
|
||||
app_builder.with_extension(TestStartupExtension)
|
||||
app_builder.with_extension(TestExtension)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
from cpl import mail
|
||||
from cpl.application.abc import StartupABC
|
||||
from cpl.core.configuration import Configuration
|
||||
from cpl.dependency import ServiceCollection, ServiceProviderABC
|
||||
from cpl.core.environment import Environment
|
||||
from cpl.core.pipes import IPAddressPipe
|
||||
from cpl.dependency import ServiceCollection
|
||||
from test_service import TestService
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
def configure_configuration(selft):
|
||||
@staticmethod
|
||||
def configure_configuration():
|
||||
Configuration.add_json_file(f"appsettings.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_environment()}.json")
|
||||
Configuration.add_json_file(f"appsettings.{Environment.get_host_name()}.json", optional=True)
|
||||
|
||||
def configure_services(self, services: ServiceCollection):
|
||||
@staticmethod
|
||||
def configure_services(services: ServiceCollection):
|
||||
services.add_logging()
|
||||
services.add_module(mail)
|
||||
services.add_transient(IPAddressPipe)
|
||||
|
||||
@@ -4,8 +4,7 @@ from cpl.dependency import ServiceProviderABC
|
||||
|
||||
|
||||
class TestExtension(ApplicationExtensionABC):
|
||||
def __init__(self):
|
||||
ApplicationExtensionABC.__init__(self)
|
||||
|
||||
def run(self, services: ServiceProviderABC):
|
||||
@staticmethod
|
||||
def run(services: ServiceProviderABC):
|
||||
Console.write_line("Hello World from App Extension")
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
from cpl.application.abc import StartupExtensionABC
|
||||
from cpl.core.configuration import Configuration
|
||||
from cpl.core.console import Console
|
||||
from cpl.dependency import ServiceCollection
|
||||
from cpl.core.environment import Environment
|
||||
|
||||
|
||||
class TestStartupExtension(StartupExtensionABC):
|
||||
def __init__(self):
|
||||
StartupExtensionABC.__init__(self)
|
||||
|
||||
def configure_configuration(self):
|
||||
@staticmethod
|
||||
def configure_configuration():
|
||||
Console.write_line("config")
|
||||
|
||||
def configure_services(self, services: ServiceCollection):
|
||||
@staticmethod
|
||||
def configure_services(services: ServiceCollection):
|
||||
Console.write_line("services")
|
||||
|
||||
@@ -18,8 +18,7 @@ class Application(ApplicationABC):
|
||||
self._translation.load_by_settings(config.get_configuration(TranslationSettings))
|
||||
self._translation.set_default_lang("de")
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
def configure(self): ...
|
||||
|
||||
def main(self):
|
||||
Console.write_line(self._translate.transform("main.text.hello_world"))
|
||||
|
||||
@@ -6,7 +6,7 @@ from translation.startup import Startup
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.use_startup(Startup)
|
||||
app_builder.with_startup(Startup)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ class Application(ApplicationABC):
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
def configure(self): ...
|
||||
|
||||
def main(self):
|
||||
runner = unittest.TextTestRunner()
|
||||
|
||||
@@ -2,8 +2,6 @@ from unittests_cli.abc.command_test_case import CommandTestCase
|
||||
|
||||
|
||||
class CustomTestCase(CommandTestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_equal(self):
|
||||
pass
|
||||
def test_equal(self): ...
|
||||
|
||||
@@ -26,8 +26,7 @@ class VersionTestCase(CommandTestCase):
|
||||
self._block_packages = ""
|
||||
self._name = "CPL CLI"
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def _get_version_output(self, version: str):
|
||||
index = 0
|
||||
|
||||
@@ -4,8 +4,7 @@ from cpl.core.pipes import BoolPipe
|
||||
|
||||
|
||||
class BoolPipeTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_transform(self):
|
||||
self.assertEqual("true", BoolPipe.to_str(True))
|
||||
|
||||
@@ -4,8 +4,7 @@ from cpl.core.pipes import IPAddressPipe
|
||||
|
||||
|
||||
class IPAddressTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_transform(self):
|
||||
self.assertEqual("192.168.178.1", IPAddressPipe.to_str([192, 168, 178, 1]))
|
||||
|
||||
@@ -4,8 +4,7 @@ from cpl.core.utils import CredentialManager
|
||||
|
||||
|
||||
class CredentialManagerTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_encrypt(self):
|
||||
self.assertEqual("ZkVjSkplQUx4aW1zWHlPbA==", CredentialManager.encrypt("fEcJJeALximsXyOl"))
|
||||
|
||||
@@ -18,8 +18,7 @@ class TestClass:
|
||||
|
||||
|
||||
class JSONProcessorTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_process(self):
|
||||
test_dict = {
|
||||
|
||||
@@ -5,8 +5,7 @@ from cpl.core.utils import String
|
||||
|
||||
|
||||
class StringTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
def setUp(self): ...
|
||||
|
||||
def test_convert_to_camel_case(self):
|
||||
expected = "HelloWorld"
|
||||
|
||||
@@ -20,8 +20,7 @@ class TranslationTestCase(unittest.TestCase):
|
||||
self._translation.set_default_lang("de")
|
||||
self._translate = TranslatePipe(self._translation)
|
||||
|
||||
def cleanUp(self):
|
||||
pass
|
||||
def cleanUp(self): ...
|
||||
|
||||
def test_service(self):
|
||||
self.assertEqual("Hallo Welt", self._translation.translate("main.text.hello_world"))
|
||||
|
||||
Reference in New Issue
Block a user