Improved testing and service providing

This commit is contained in:
2020-11-25 21:41:45 +01:00
parent cd9d4d3c3d
commit b501fef27d
20 changed files with 340 additions and 169 deletions

View File

@@ -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()

View 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]

View File

@@ -0,0 +1,8 @@
from abc import ABC, abstractmethod
from datetime import datetime
class ApplicationHostBase(ABC):
@abstractmethod
def __init__(self): pass

View 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