Improved logging and updated modules

This commit is contained in:
2020-11-22 20:56:31 +01:00
parent be62b173d3
commit 413800f2c3
27 changed files with 158 additions and 130 deletions

View File

@@ -15,11 +15,11 @@ __title__ = 'tests'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.0.1'
__version__ = '2020.12.5'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=0.1)
version_info = VersionInfo(major=2020, minor=12, micro=5)

View File

@@ -1,5 +1,6 @@
import os
from sh_edraft.logging.base.logger_base import LoggerBase
from sh_edraft.publish.base import PublisherBase
from sh_edraft.service.base import ServiceProviderBase
from sh_edraft.source_code.model import Version
@@ -11,6 +12,7 @@ class PublisherTest:
@staticmethod
def start(services: ServiceProviderBase):
version = Version(2020, 12, 5).to_dict()
templates = [
Template(
'../../publish_templates/*_template.txt',
@@ -23,7 +25,7 @@ class PublisherTest:
', see LICENSE for more details.',
'',
'Sven Heidemann',
Version(2020, 12, 0.1).to_dict()
version
),
Template(
'../../publish_templates/*_template.txt',
@@ -36,14 +38,14 @@ class PublisherTest:
', see LICENSE for more details.',
'',
'Sven Heidemann',
Version(2020, 12, 0.1).to_dict()
version
)
]
source = '../'
dist = '../../dist'
services.add_singleton(Publisher, None, source, dist, templates)
services.add_transient(Publisher, services.get_service(LoggerBase), source, dist, templates)
publisher: Publisher = services.get_service(PublisherBase)
publisher.exclude('../tests/')

View File

@@ -1,3 +1,4 @@
from sh_edraft.logging.base.logger_base import LoggerBase
from sh_edraft.publish import Publisher
from sh_edraft.publish.base import PublisherBase
from sh_edraft.service.base import ServiceProviderBase
@@ -6,16 +7,14 @@ from sh_edraft.service.base import ServiceProviderBase
class ServiceProviderTest:
@staticmethod
def start(provider: ServiceProviderBase):
provider.create()
def start(services: ServiceProviderBase):
services.add_transient(Publisher, services.get_service(LoggerBase), '../', '../../dist', [])
provider.add_transient(Publisher, None, '../', '../../dist', [])
publisher: Publisher = provider.get_service(PublisherBase)
publisher: Publisher = services.get_service(PublisherBase)
if publisher is None or publisher.source_path != '../' or publisher.dist_path != '../../dist':
raise Exception(f'{__name__}: Invalid value in {Publisher.__name__}')
provider.remove_service(PublisherBase)
if provider.get_service(PublisherBase) is not None:
services.remove_service(PublisherBase)
if services.get_service(PublisherBase) is not None:
raise Exception(f'{__name__}: Service {Publisher.__name__} was not removed')

View File

@@ -1,12 +1,10 @@
import os
import sys
import traceback
from typing import Optional
from termcolor import colored
from sh_edraft.configuration import ApplicationHost
from sh_edraft.service import ServiceProvider
from tests.logger import LoggerTest
from tests.publisher import PublisherTest
from tests.service_provider import ServiceProviderTest
@@ -16,7 +14,6 @@ class Tester:
def __init__(self):
self._app_host = ApplicationHost()
self._services: Optional[ServiceProvider] = None
self._error: bool = False
@@ -46,7 +43,14 @@ class Tester:
def create(self): pass
def start(self):
self.disable_print()
if not self._error:
try:
LoggerTest.start(self._app_host)
self.success(f'{LoggerTest.__name__} test succeeded.')
except Exception as e:
self._error = True
self.failed(f'{LoggerTest.__name__} test failed!\n{e}')
self.exception()
if not self._error:
try:
@@ -57,15 +61,6 @@ class Tester:
self.failed(f'{ServiceProviderTest.__name__} test failed!\n{e}')
self.exception()
if not self._error:
try:
LoggerTest.start(self._app_host)
self.success(f'{LoggerTest.__name__} test succeeded.')
except Exception as e:
self._error = True
self.failed(f'{LoggerTest.__name__} test failed!\n{e}')
self.exception()
if not self._error:
try:
PublisherTest.start(self._app_host.services)
@@ -79,4 +74,6 @@ class Tester:
if __name__ == '__main__':
tester = Tester()
tester.create()
tester.disable_print()
tester.start()
tester.enable_print()