Improved testing and service providing
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sh_edraft.service import ServiceProvider
|
||||
from sh_edraft.configuration.model.application_host_base import ApplicationHostBase
|
||||
from sh_edraft.service.service_provider import ServiceProvider
|
||||
|
||||
|
||||
class ApplicationHost:
|
||||
class ApplicationHost(ApplicationHostBase):
|
||||
|
||||
def __init__(self):
|
||||
ApplicationHostBase.__init__(self)
|
||||
self._services = ServiceProvider()
|
||||
self._end_time: datetime = datetime.now()
|
||||
self._start_time: datetime = datetime.now()
|
||||
|
27
src/sh_edraft/configuration/configuration.py
Normal file
27
src/sh_edraft/configuration/configuration.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from collections import Callable
|
||||
|
||||
from sh_edraft.configuration.model.configuration_model_base import ConfigurationModelBase
|
||||
from sh_edraft.configuration.model.configuration_base import ConfigurationBase
|
||||
|
||||
|
||||
class Configuration(ConfigurationBase):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@property
|
||||
def config(self):
|
||||
return self._config
|
||||
|
||||
def create(self): pass
|
||||
|
||||
def add_config_by_type(self, key_type: type, value: object):
|
||||
self._config[key_type] = value
|
||||
|
||||
def get_config_by_type(self, search_type: type) -> Callable[ConfigurationModelBase]:
|
||||
if search_type not in self._config:
|
||||
raise Exception(f'Config model by type {search_type} not found')
|
||||
|
||||
for config_model in self._config:
|
||||
if config_model == search_type:
|
||||
return self._config[config_model]
|
@@ -0,0 +1,8 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class ApplicationHostBase(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self): pass
|
23
src/sh_edraft/configuration/model/configuration_base.py
Normal file
23
src/sh_edraft/configuration/model/configuration_base.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from abc import abstractmethod
|
||||
from collections import Callable
|
||||
|
||||
from sh_edraft.configuration.model.configuration_model_base import ConfigurationModelBase
|
||||
from sh_edraft.service.base.service_base import ServiceBase
|
||||
|
||||
|
||||
class ConfigurationBase(ServiceBase):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
ServiceBase.__init__(self)
|
||||
self._config: dict[type, object] = {}
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def config(self): pass
|
||||
|
||||
@abstractmethod
|
||||
def add_config_by_type(self, key_type: type, value: object): pass
|
||||
|
||||
@abstractmethod
|
||||
def get_config_by_type(self, search_type: ConfigurationModelBase) -> Callable[ConfigurationModelBase]: pass
|
Reference in New Issue
Block a user