diff --git a/.gitignore b/.gitignore
index eb80cef2..a2f9a4d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,7 +26,6 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
-.idea/
# PyInstaller
# Usually these files are written by a python script from a template
@@ -129,3 +128,6 @@ dmypy.json
# Pyre type checker
.pyre/
+# IDE
+.vscode/
+
diff --git a/.idea/dictionaries/sven.xml b/.idea/dictionaries/sven.xml
new file mode 100644
index 00000000..6b8908ae
--- /dev/null
+++ b/.idea/dictionaries/sven.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 00000000..f9ea47c4
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 00000000..105ce2da
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..74c32a17
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..3430c667
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/sh_common_py_lib.iml b/.idea/sh_common_py_lib.iml
new file mode 100644
index 00000000..7f4b6244
--- /dev/null
+++ b/.idea/sh_common_py_lib.iml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36_[Default_Changelist]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36_[Default_Changelist]/shelved.patch
new file mode 100644
index 00000000..bb3b0e06
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36_[Default_Changelist]/shelved.patch
@@ -0,0 +1,61 @@
+Index: src/tests/publishing/publisher.py
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>import os\r\nimport shutil\r\nimport unittest\r\n\r\nfrom sh_edraft.configuration import ApplicationHost\r\nfrom sh_edraft.logging import Logger\r\nfrom sh_edraft.logging.base import LoggerBase\r\nfrom sh_edraft.logging.model import LoggingSettings\r\nfrom sh_edraft.publishing import Publisher\r\nfrom sh_edraft.publishing.base import PublisherBase\r\nfrom sh_edraft.publishing.model import Template\r\nfrom sh_edraft.publishing.model.publish_settings_model import PublishSettingsModel\r\nfrom sh_edraft.source_code.model import Version\r\nfrom sh_edraft.time.model import TimeFormatSettings\r\n\r\n\r\nclass PublisherTest(unittest.TestCase):\r\n\r\n def _config(self):\r\n self._log_settings = LoggingSettings()\r\n self._log_settings.from_dict({\r\n \"Path\": \"logs/\",\r\n \"Filename\": \"log_$start_time.log\",\r\n \"ConsoleLogLevel\": \"TRACE\",\r\n \"FileLogLevel\": \"TRACE\"\r\n })\r\n\r\n self._time_format_settings = TimeFormatSettings()\r\n self._time_format_settings.from_dict({\r\n \"DateFormat\": \"%Y-%m-%d\",\r\n \"TimeFormat\": \"%H:%M:%S\",\r\n \"DateTimeFormat\": \"%Y-%m-%d %H:%M:%S.%f\",\r\n \"DateTimeLogFormat\": \"%Y-%m-%d_%H-%M-%S\"\r\n })\r\n\r\n self._version = Version(2020, 12, 5).to_dict()\r\n templates = [\r\n Template(\r\n '../../publish_templates/*_template.txt',\r\n '*',\r\n '',\r\n '',\r\n '2020',\r\n 'sh-edraft.de',\r\n 'MIT',\r\n ', see LICENSE for more details.',\r\n '',\r\n 'Sven Heidemann',\r\n self._version\r\n ),\r\n Template(\r\n '../../publish_templates/*_template.txt',\r\n 'sh_edraft',\r\n 'common python library',\r\n 'Library to share common classes and models used at sh-edraft.de',\r\n '2020',\r\n 'sh-edraft.de',\r\n 'MIT',\r\n ', see LICENSE for more details.',\r\n '',\r\n 'Sven Heidemann',\r\n self._version\r\n )\r\n ]\r\n\r\n self._source_path = '../'\r\n self._dist_path = '../../dist'\r\n\r\n self._publish_settings_model = PublishSettingsModel()\r\n self._publish_settings_model.from_dict({\r\n \"SourcePath\": self._source_path,\r\n \"DistPath\": self._dist_path,\r\n \"Templates\": templates,\r\n \"IncludedFiles\": [],\r\n \"ExcludedFiles\": [],\r\n \"TemplateEnding\": \"_template.txt\",\r\n })\r\n\r\n def setUp(self):\r\n self._config()\r\n\r\n self._app_host = ApplicationHost()\r\n self._logger = Logger(self._log_settings, self._time_format_settings, self._app_host)\r\n self._logger.create()\r\n\r\n def tearDown(self):\r\n if os.path.isdir(self._log_settings.path):\r\n shutil.rmtree(self._log_settings.path)\r\n\r\n def test_create(self):\r\n publisher: Publisher = Publisher(self._logger, self._publish_settings_model)\r\n self.assertIsNotNone(publisher)\r\n\r\n publisher.create()\r\n self.assertTrue(os.path.isdir(self._dist_path))\r\n
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+--- src/tests/publishing/publisher.py (revision 9dbad20e9714ffa1546bb2d1b2f8b5ea8e854369)
++++ src/tests/publishing/publisher.py (date 1606383223452)
+@@ -36,8 +36,8 @@
+ self._version = Version(2020, 12, 5).to_dict()
+ templates = [
+ Template(
+- '../../publish_templates/*_template.txt',
+- '*',
++ '../../publish_templates/all_template.txt',
++ 'all',
+ '',
+ '',
+ '2020',
+@@ -49,7 +49,7 @@
+ self._version
+ ),
+ Template(
+- '../../publish_templates/*_template.txt',
++ '../../publish_templates/all_template.txt',
+ 'sh_edraft',
+ 'common python library',
+ 'Library to share common classes and models used at sh-edraft.de',
+Index: src/sh_edraft/publishing/publisher.py
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>import os\r\nimport shutil\r\nfrom string import Template as stringTemplate\r\n\r\nfrom sh_edraft.logging.base.logger_base import LoggerBase\r\nfrom sh_edraft.publishing.base.publisher_base import PublisherBase\r\nfrom sh_edraft.publishing.model.publish_settings_model import PublishSettingsModel\r\nfrom sh_edraft.publishing.model.template import Template\r\n\r\n\r\nclass Publisher(PublisherBase):\r\n\r\n def __init__(self, logger: LoggerBase, publish_settings: PublishSettingsModel):\r\n super().__init__(logger, publish_settings)\r\n\r\n @property\r\n def source_path(self) -> str:\r\n return self._publish_settings.source_path\r\n\r\n @property\r\n def dist_path(self):\r\n return self._publish_settings.dist_path\r\n\r\n def _get_template_output(self, t: Template, name: str, imports: str) -> str:\r\n self._logger.trace(__name__, f'Started {__name__}._get_template_output')\r\n try:\r\n if t.file_content == '':\r\n raise Exception(f'Template is empty: {t.template_path}')\r\n\r\n self._logger.trace(__name__, f'Stopped {__name__}._get_template_output')\r\n return stringTemplate(t.file_content).substitute(\r\n Name=name,\r\n Description=t.description,\r\n LongDescription=t.long_description,\r\n CopyrightDate=t.copyright_date,\r\n CopyrightName=t.copyright_name,\r\n LicenseName=t.license_name,\r\n LicenseDescription=t.license_description,\r\n Title=t.title if t.title is not None and t.title != '' else name,\r\n Author=t.author,\r\n Version=t.version.to_str(),\r\n Major=t.version.major,\r\n Minor=t.version.minor,\r\n Micro=t.version.micro,\r\n Imports=imports\r\n )\r\n except Exception as e:\r\n self._logger.fatal(__name__, f'Cannot read Template: {t.template_path}', e)\r\n self._logger.trace(__name__, f'Stopped {__name__}._get_template_output')\r\n\r\n def _read_source_path(self):\r\n self._logger.trace(__name__, f'Started {__name__}._read_source_path')\r\n for r, d, f in os.walk(self._publish_settings.source_path):\r\n for file in f:\r\n if file.endswith('.py') or file in self._publish_settings.included_files:\r\n self._publish_settings.included_files.append(os.path.join(r, file))\r\n\r\n self._logger.trace(__name__, f'Stopped {__name__}._read_source_path')\r\n\r\n def _read_templates(self):\r\n self._logger.trace(__name__, f'Started {__name__}._read_templates')\r\n for t in self._publish_settings.templates:\r\n output_template: str = ''\r\n if not os.path.isfile(t.template_path):\r\n self._logger.fatal(__name__, f'Template not found: {t.template_path}')\r\n\r\n with open(t.template_path) as template:\r\n t.file_content = template.read()\r\n template.close()\r\n if t.file_content == '':\r\n self._logger.fatal(__name__, f'Template is empty: {t.template_path}')\r\n\r\n self._logger.trace(__name__, f'Stopped {__name__}._read_templates')\r\n\r\n def _create_dist_path(self):\r\n self._logger.trace(__name__, f'Started {__name__}._create_dist_path')\r\n if os.path.isdir(self._publish_settings.dist_path):\r\n try:\r\n shutil.rmtree(self._publish_settings.dist_path)\r\n self._logger.info(__name__, f'Deleted {self._publish_settings.dist_path}')\r\n except Exception as e:\r\n self._logger.fatal(__name__, f'Cannot delete old dist directory', e)\r\n\r\n if not os.path.isdir(self._publish_settings.dist_path):\r\n try:\r\n os.makedirs(self._publish_settings.dist_path)\r\n self._logger.debug(__name__, f'Created directories: {self._publish_settings.dist_path}')\r\n self._logger.info(__name__, f'Created dist directory')\r\n except Exception as e:\r\n self._logger.fatal(__name__, f'Cannot create dist directory', e)\r\n\r\n self._logger.trace(__name__, f'Stopped {__name__}._create_dist_path')\r\n\r\n @staticmethod\r\n def _get_template_name_from_dirs(file: str) -> str:\r\n dirs = os.path.dirname(file).split('/')\r\n for d in dirs:\r\n if d.__contains__('.'):\r\n dirs.remove(d)\r\n\r\n if len(dirs) == 0:\r\n return os.path.basename(file)\r\n else:\r\n return '.'.join(dirs)\r\n\r\n def _write_templates(self):\r\n self._logger.trace(__name__, f'Started {__name__}._write_templates')\r\n for template in self._publish_settings.templates:\r\n for file in self._publish_settings.included_files:\r\n if os.path.basename(file) == '__init__.py' and file not in self._publish_settings.excluded_files:\r\n template_name = template.name\r\n if template.name == '*' or template.name == '':\r\n template_name = self._get_template_name_from_dirs(file)\r\n else:\r\n name = self._get_template_name_from_dirs(file)\r\n\r\n if name.__contains__('.'):\r\n if template.name != name.split('.')[len(name.split('.')) - 1]:\r\n continue\r\n\r\n else:\r\n if template.name != name:\r\n continue\r\n\r\n try:\r\n module_file_lines: list[str] = []\r\n module_py_lines: list[str] = []\r\n imports = ''\r\n with open(file, 'r') as py_file:\r\n module_file_lines = py_file.readlines()\r\n py_file.close()\r\n\r\n if len(module_file_lines) == 0:\r\n with open(file, 'w+') as py_file:\r\n py_file.write(self._get_template_output(template, template_name, '# imports:'))\r\n py_file.close()\r\n self._logger.debug(__name__, f'Written to {file}')\r\n else:\r\n is_started = False\r\n for line in module_file_lines:\r\n if line.__contains__('# imports'):\r\n is_started = True\r\n\r\n if (line.__contains__('from') or line.__contains__('import')) and is_started:\r\n module_py_lines.append(line.replace('\\n', ''))\r\n\r\n if len(module_py_lines) > 0:\r\n imports = '\\n'.join(module_py_lines)\r\n\r\n with open(file, 'w+') as py_file:\r\n py_file.write(self._get_template_output(template, template_name, imports))\r\n py_file.close()\r\n self._logger.debug(__name__, f'Written to {file}')\r\n\r\n except Exception as e:\r\n self._logger.error(__name__, f'Cannot write to file: {file}', e)\r\n\r\n self._logger.info(__name__, f'Written to all included modules')\r\n self._logger.trace(__name__, f'Stopped {__name__}._write_templates')\r\n\r\n def _copy_all_included_files(self):\r\n self._logger.trace(__name__, f'Started {__name__}._copy_all_included_files')\r\n dist_path = self._publish_settings.dist_path\r\n if self._publish_settings.dist_path.endswith('/'):\r\n dist_path = dist_path[:len(dist_path) - 1]\r\n\r\n for file in self._publish_settings.included_files:\r\n is_file_excluded = False\r\n if file in self._publish_settings.excluded_files:\r\n is_file_excluded = True\r\n else:\r\n for excluded in self._publish_settings.excluded_files:\r\n if file.__contains__(excluded):\r\n is_file_excluded = True\r\n\r\n if not is_file_excluded:\r\n output_file = ''\r\n\r\n if file.startswith('..'):\r\n output_file = file.replace('..', '')\r\n elif file.startswith('.'):\r\n output_file = file.replace('.', '', 1)\r\n\r\n output_file = f'{dist_path}{output_file}'\r\n output_path = os.path.dirname(output_file)\r\n\r\n try:\r\n if not os.path.isdir(output_path):\r\n os.makedirs(output_path)\r\n except Exception as e:\r\n self._logger.error(__name__, f'Cannot create directories: {output_path}', e)\r\n\r\n try:\r\n shutil.copy(file, output_file)\r\n except Exception as e:\r\n self._logger.error(__name__, f'Cannot copy file: {file} to {output_path}', e)\r\n\r\n self._logger.debug(__name__, f'Copied {file} to {output_path}')\r\n\r\n self._logger.info(__name__, f'Copied all included files')\r\n self._logger.trace(__name__, f'Stopped {__name__}._copy_all_included_files')\r\n\r\n def include(self, path: str):\r\n self._logger.trace(__name__, f'Started {__name__}.include')\r\n self._publish_settings.included_files.append(path)\r\n self._logger.trace(__name__, f'Stopped {__name__}.include')\r\n\r\n def exclude(self, path: str):\r\n self._logger.trace(__name__, f'Started {__name__}.exclude')\r\n self._publish_settings.excluded_files.append(path)\r\n self._logger.trace(__name__, f'Stopped {__name__}.exclude')\r\n\r\n def create(self):\r\n self._logger.trace(__name__, f'Started {__name__}.create')\r\n if not self._publish_settings.dist_path.endswith('/'):\r\n self._publish_settings.dist_path += '/'\r\n\r\n self._read_source_path()\r\n self._read_templates()\r\n self._create_dist_path()\r\n self._logger.trace(__name__, f'Stopped {__name__}.create')\r\n\r\n def publish(self):\r\n self._logger.trace(__name__, f'Started {__name__}.publish')\r\n self._write_templates()\r\n self._copy_all_included_files()\r\n self._logger.trace(__name__, f'Stopped {__name__}.publish')\r\n
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+--- src/sh_edraft/publishing/publisher.py (revision 9dbad20e9714ffa1546bb2d1b2f8b5ea8e854369)
++++ src/sh_edraft/publishing/publisher.py (date 1606383234093)
+@@ -109,7 +109,7 @@
+ for file in self._publish_settings.included_files:
+ if os.path.basename(file) == '__init__.py' and file not in self._publish_settings.excluded_files:
+ template_name = template.name
+- if template.name == '*' or template.name == '':
++ if template.name == 'all' or template.name == '':
+ template_name = self._get_template_name_from_dirs(file)
+ else:
+ name = self._get_template_name_from_dirs(file)
+Index: publish_templates/*_template.txt
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+># -*- coding: utf-8 -*-\r\n\r\n\"\"\"\r\n$Name $Description\r\n~~~~~~~~~~~~~~~~~~~\r\n\r\n$LongDescription\r\n\r\n:copyright: (c) $CopyrightDate $CopyrightName\r\n:license: $LicenseName$LicenseDescription\r\n\r\n\"\"\"\r\n\r\n__title__ = '$Title'\r\n__author__ = '$Author'\r\n__license__ = '$LicenseName'\r\n__copyright__ = 'Copyright (c) $CopyrightDate $CopyrightName'\r\n__version__ = '$Version'\r\n\r\nfrom collections import namedtuple\r\n\r\n$Imports\r\n\r\nVersionInfo = namedtuple('VersionInfo', 'major minor micro')\r\nversion_info = VersionInfo(major=$Major, minor=$Minor, micro=$Micro)\r\n
+===================================================================
+--- publish_templates/*_template.txt (revision 9dbad20e9714ffa1546bb2d1b2f8b5ea8e854369)
++++ publish_templates/all_template.txt (date 1606383191684)
+@@ -22,4 +22,4 @@
+ $Imports
+
+ VersionInfo = namedtuple('VersionInfo', 'major minor micro')
+-version_info = VersionInfo(major=$Major, minor=$Minor, micro=$Micro)
++version_info = VersionInfo(major=$Major, minor=$Minor, micro=$Micro)
+\ No newline at end of file
diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36__Default_Changelist_.xml b/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36__Default_Changelist_.xml
new file mode 100644
index 00000000..49edc74a
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36__Default_Changelist_.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 00000000..8106a0a5
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,868 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1605881914521
+
+
+ 1605881914521
+
+
+ 1607285697331
+
+
+
+ 1607285697331
+
+
+ 1607620265254
+
+
+
+ 1607620265254
+
+
+ 1607712129507
+
+
+
+ 1607712129507
+
+
+ 1607971885250
+
+
+
+ 1607971885250
+
+
+ 1607976456889
+
+
+
+ 1607976456889
+
+
+ 1607976626173
+
+
+
+ 1607976626173
+
+
+ 1608037411172
+
+
+
+ 1608037411172
+
+
+ 1608047595029
+
+
+
+ 1608047595029
+
+
+ 1608047655667
+
+
+
+ 1608047655667
+
+
+ 1608048544558
+
+
+
+ 1608048544558
+
+
+ 1608049672925
+
+
+
+ 1608049672925
+
+
+ 1608049772153
+
+
+
+ 1608049772153
+
+
+ 1608059323858
+
+
+
+ 1608059323858
+
+
+ 1608059501153
+
+
+
+ 1608059501153
+
+
+ 1608066984496
+
+
+
+ 1608066984496
+
+
+ 1608070231599
+
+
+
+ 1608070231599
+
+
+ 1608122289003
+
+
+
+ 1608122289003
+
+
+ 1608125743068
+
+
+
+ 1608125743068
+
+
+ 1608127752645
+
+
+
+ 1608127752645
+
+
+ 1608127998033
+
+
+
+ 1608127998034
+
+
+ 1608128026922
+
+
+
+ 1608128026922
+
+
+ 1608133651981
+
+
+
+ 1608133651982
+
+
+ 1608136663213
+
+
+
+ 1608136663213
+
+
+ 1608137669182
+
+
+
+ 1608137669182
+
+
+ 1608138851088
+
+
+
+ 1608138851088
+
+
+ 1608138986801
+
+
+
+ 1608138986801
+
+
+ 1608139067953
+
+
+
+ 1608139067953
+
+
+ 1608139239527
+
+
+
+ 1608139239527
+
+
+ 1608139414722
+
+
+
+ 1608139414722
+
+
+ 1608139502304
+
+
+
+ 1608139502304
+
+
+ 1608139612476
+
+
+
+ 1608139612476
+
+
+ 1608383809354
+
+
+
+ 1608383809355
+
+
+ 1608383870849
+
+
+
+ 1608383870849
+
+
+ 1608472168532
+
+
+
+ 1608472168532
+
+
+ 1608472183294
+
+
+
+ 1608472183294
+
+
+ 1608474022759
+
+
+
+ 1608474022759
+
+
+ 1608474032244
+
+
+
+ 1608474032244
+
+
+ 1608474289859
+
+
+
+ 1608474289859
+
+
+ 1608813096023
+
+
+
+ 1608813096023
+
+
+ 1608813152266
+
+
+
+ 1608813152266
+
+
+ 1608822597300
+
+
+
+ 1608822597311
+
+
+ 1608823061488
+
+
+
+ 1608823061489
+
+
+ 1608894745271
+
+
+
+ 1608894745274
+
+
+ 1608896199033
+
+
+
+ 1608896199034
+
+
+ 1608896235005
+
+
+
+ 1608896235006
+
+
+ 1608901608928
+
+
+
+ 1608901608930
+
+
+ 1608921175852
+
+
+
+ 1608921175853
+
+
+ 1608986131753
+
+
+
+ 1608986131755
+
+
+ 1611431001647
+
+
+
+ 1611431001649
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/src/tests/publish_test/publisher_test.py
+ 50
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/sh_edraft/cli/cpl_cli/commands/build/app.py b/src/sh_edraft/cli/cpl_cli/commands/build/app.py
index 84577e8c..4c0b9833 100644
--- a/src/sh_edraft/cli/cpl_cli/commands/build/app.py
+++ b/src/sh_edraft/cli/cpl_cli/commands/build/app.py
@@ -5,8 +5,8 @@ from sh_edraft.hosting.application_host import ApplicationHost
from sh_edraft.hosting.base.application_base import ApplicationBase
from sh_edraft.logging.logger import Logger
from sh_edraft.logging.base.logger_base import LoggerBase
-from sh_edraft.publishing.publisher import Publisher
-from sh_edraft.publishing.base.publisher_base import PublisherBase
+from sh_edraft.publish.publisher import Publisher
+from sh_edraft.publish.base.publisher_base import PublisherBase
from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase
diff --git a/src/sh_edraft/cli/cpl_cli/commands/publish/app.py b/src/sh_edraft/cli/cpl_cli/commands/publish/app.py
index c7ce661a..2a0f6cec 100644
--- a/src/sh_edraft/cli/cpl_cli/commands/publish/app.py
+++ b/src/sh_edraft/cli/cpl_cli/commands/publish/app.py
@@ -5,8 +5,8 @@ from sh_edraft.hosting.application_host import ApplicationHost
from sh_edraft.hosting.base.application_base import ApplicationBase
from sh_edraft.logging.logger import Logger
from sh_edraft.logging.base.logger_base import LoggerBase
-from sh_edraft.publishing.publisher import Publisher
-from sh_edraft.publishing.base.publisher_base import PublisherBase
+from sh_edraft.publish.publisher import Publisher
+from sh_edraft.publish.base.publisher_base import PublisherBase
from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase
diff --git a/src/sh_edraft/console/console.py b/src/sh_edraft/console/console.py
index c454eb81..14964866 100644
--- a/src/sh_edraft/console/console.py
+++ b/src/sh_edraft/console/console.py
@@ -45,6 +45,7 @@ class Console:
@classmethod
def set_foreground_color(cls, color: Union[ForegroundColor, str]):
+
if type(color) is str:
cls._foreground_color = ForegroundColor[color]
else:
@@ -66,9 +67,6 @@ class Console:
@classmethod
def _output(cls, string: str, x: int = None, y: int = None, end='\n'):
- if cls._disabled:
- return
-
if cls._is_first_write:
cls._is_first_write = False
@@ -98,15 +96,21 @@ class Console:
@classmethod
def banner(cls, string: str):
+ if cls._disabled:
+ return
+
ascii_banner = pyfiglet.figlet_format(string)
cls.write_line(ascii_banner)
- @staticmethod
- def clear():
+ @classmethod
+ def clear(cls):
os.system('cls' if os.name == 'nt' else 'clear')
- @staticmethod
- def close():
+ @classmethod
+ def close(cls):
+ if cls._disabled:
+ return
+
Console.reset()
Console.write('\n\n\nPress any key to continue...')
Console.read_line()
@@ -118,6 +122,9 @@ class Console:
@classmethod
def error(cls, string: str, tb: str = None):
+ if cls._disabled:
+ return
+
cls.set_foreground_color('red')
if tb is not None:
cls.write_line(f'{string} -> {tb}')
@@ -138,6 +145,9 @@ class Console:
@classmethod
def read_line(cls, output: str = None) -> str:
+ if cls._disabled:
+ return ''
+
if output is not None:
cls.write(output)
@@ -150,6 +160,9 @@ class Console:
@classmethod
def table(cls, header: list[str], values: list[list[str]]):
+ if cls._disabled:
+ return
+
table = tabulate(values, headers=header)
Console.write_line(table)
@@ -157,16 +170,25 @@ class Console:
@classmethod
def write(cls, *args):
+ if cls._disabled:
+ return
+
string = ' '.join(map(str, args))
cls._output(string, end='')
@classmethod
def write_at(cls, x: int, y: int, *args):
+ if cls._disabled:
+ return
+
string = ' '.join(map(str, args))
cls._output(string, x, y, end='')
@classmethod
def write_line(cls, *args):
+ if cls._disabled:
+ return
+
string = ' '.join(map(str, args))
if not cls._is_first_write:
cls._output('')
@@ -174,6 +196,9 @@ class Console:
@classmethod
def write_line_at(cls, x: int, y: int, *args):
+ if cls._disabled:
+ return
+
string = ' '.join(map(str, args))
if not cls._is_first_write:
cls._output('', end='')
diff --git a/src/sh_edraft/discord/__init__.py b/src/sh_edraft/discord/__init__.py
deleted file mode 100644
index 6e3c9e4c..00000000
--- a/src/sh_edraft/discord/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-sh_edraft.discord
-~~~~~~~~~~~~~~~~~~~
-
-
-
-:copyright: (c) 2020 sh-edraft.de
-:license: MIT, see LICENSE for more details.
-
-"""
-
-__title__ = 'sh_edraft.discord'
-__author__ = 'Sven Heidemann'
-__license__ = 'MIT'
-__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
-__version__ = '2020.12.9'
-
-from collections import namedtuple
-
-
-
-VersionInfo = namedtuple('VersionInfo', 'major minor micro')
-version_info = VersionInfo(major=2020, minor=12, micro=9)
diff --git a/src/sh_edraft/messaging/__init__.py b/src/sh_edraft/messaging/__init__.py
deleted file mode 100644
index 873d0fe5..00000000
--- a/src/sh_edraft/messaging/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-sh_edraft.messaging
-~~~~~~~~~~~~~~~~~~~
-
-
-
-:copyright: (c) 2020 sh-edraft.de
-:license: MIT, see LICENSE for more details.
-
-"""
-
-__title__ = 'sh_edraft.messaging'
-__author__ = 'Sven Heidemann'
-__license__ = 'MIT'
-__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
-__version__ = '2020.12.9'
-
-from collections import namedtuple
-
-# imports:
-
-VersionInfo = namedtuple('VersionInfo', 'major minor micro')
-version_info = VersionInfo(major=2020, minor=12, micro=9)
diff --git a/src/sh_edraft/publishing/base/publisher_base.py b/src/sh_edraft/publish/base/publisher_base.py
similarity index 100%
rename from src/sh_edraft/publishing/base/publisher_base.py
rename to src/sh_edraft/publish/base/publisher_base.py
diff --git a/src/sh_edraft/publishing/model/publish_settings_model.py b/src/sh_edraft/publish/model/publish_settings_model.py
similarity index 95%
rename from src/sh_edraft/publishing/model/publish_settings_model.py
rename to src/sh_edraft/publish/model/publish_settings_model.py
index 17b6b83c..3a1f8ce5 100644
--- a/src/sh_edraft/publishing/model/publish_settings_model.py
+++ b/src/sh_edraft/publish/model/publish_settings_model.py
@@ -2,8 +2,8 @@ import traceback
from typing import Optional
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
-from sh_edraft.publishing.model.template import Template
-from sh_edraft.publishing.model.publish_settings_name import PublishSettingsName
+from sh_edraft.publish.model.template import Template
+from sh_edraft.publish.model.publish_settings_name import PublishSettingsName
from sh_edraft.console.console import Console
from sh_edraft.console.model.foreground_color import ForegroundColor
diff --git a/src/sh_edraft/publishing/model/publish_settings_name.py b/src/sh_edraft/publish/model/publish_settings_name.py
similarity index 100%
rename from src/sh_edraft/publishing/model/publish_settings_name.py
rename to src/sh_edraft/publish/model/publish_settings_name.py
diff --git a/src/sh_edraft/publishing/model/template.py b/src/sh_edraft/publish/model/template.py
similarity index 98%
rename from src/sh_edraft/publishing/model/template.py
rename to src/sh_edraft/publish/model/template.py
index cea0f09c..b98a4738 100644
--- a/src/sh_edraft/publishing/model/template.py
+++ b/src/sh_edraft/publish/model/template.py
@@ -2,7 +2,7 @@ from typing import Optional
from sh_edraft.coding.model.version import Version
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
-from sh_edraft.publishing.model.template_enum import TemplateEnum
+from sh_edraft.publish.model.template_enum import TemplateEnum
class Template(ConfigurationModelBase):
diff --git a/src/sh_edraft/publishing/model/template_enum.py b/src/sh_edraft/publish/model/template_enum.py
similarity index 100%
rename from src/sh_edraft/publishing/model/template_enum.py
rename to src/sh_edraft/publish/model/template_enum.py
diff --git a/src/sh_edraft/publishing/publisher.py b/src/sh_edraft/publish/publisher.py
similarity index 97%
rename from src/sh_edraft/publishing/publisher.py
rename to src/sh_edraft/publish/publisher.py
index 4a8bf1cd..2ddd2b15 100644
--- a/src/sh_edraft/publishing/publisher.py
+++ b/src/sh_edraft/publish/publisher.py
@@ -5,9 +5,9 @@ from string import Template as stringTemplate
from setuptools import sandbox
from sh_edraft.logging.base.logger_base import LoggerBase
-from sh_edraft.publishing.base.publisher_base import PublisherBase
-from sh_edraft.publishing.model.publish_settings_model import PublishSettings
-from sh_edraft.publishing.model.template import Template
+from sh_edraft.publish.base.publisher_base import PublisherBase
+from sh_edraft.publish.model.publish_settings_model import PublishSettings
+from sh_edraft.publish.model.template import Template
class Publisher(PublisherBase):
@@ -229,7 +229,7 @@ class Publisher(PublisherBase):
try:
if not os.path.isdir(output_path):
- os.makedirs(output_path)
+ os.makedirs(output_path, exist_ok=True)
except Exception as e:
self._logger.error(__name__, f'Cannot create directories: {output_path}', e)
diff --git a/src/sh_edraft/service/model/__init__.py b/src/sh_edraft/service/model/__init__.py
deleted file mode 100644
index e268c5ed..00000000
--- a/src/sh_edraft/service/model/__init__.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-sh_edraft.service.model
-~~~~~~~~~~~~~~~~~~~
-
-
-
-:copyright: (c) 2020 sh-edraft.de
-:license: MIT, see LICENSE for more details.
-
-"""
-
-__title__ = 'sh_edraft.service.model'
-__author__ = 'Sven Heidemann'
-__license__ = 'MIT'
-__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
-__version__ = '2020.12.9'
-
-from collections import namedtuple
-
-# imports:
-from .provide_state import ProvideState
-
-VersionInfo = namedtuple('VersionInfo', 'major minor micro')
-version_info = VersionInfo(major=2020, minor=12, micro=9)
diff --git a/src/sh_edraft/service/providing/service_provider.py b/src/sh_edraft/service/providing/service_provider.py
index 6cec42a4..2ba39e4c 100644
--- a/src/sh_edraft/service/providing/service_provider.py
+++ b/src/sh_edraft/service/providing/service_provider.py
@@ -80,16 +80,16 @@ class ServiceProvider(ServiceProviderBase):
def remove_service(self, instance_type: Type[ServiceBase]):
for service in self._transient_services:
- if isinstance(service, type(instance_type)):
+ if service == instance_type and isinstance(self._transient_services[service], type(instance_type)):
del self._transient_services[service]
return
for service in self._scoped_services:
- if isinstance(service, type(instance_type)):
+ if service == instance_type and isinstance(self._scoped_services[service], type(instance_type)):
del self._scoped_services[service]
return
for service in self._singleton_services:
- if isinstance(service, instance_type):
+ if service == instance_type and isinstance(self._singleton_services[service], instance_type):
del self._singleton_services[service]
return
diff --git a/src/sh_edraft/time/model/time_format_settings.py b/src/sh_edraft/time/model/time_format_settings.py
index 664192a4..e4be7511 100644
--- a/src/sh_edraft/time/model/time_format_settings.py
+++ b/src/sh_edraft/time/model/time_format_settings.py
@@ -15,8 +15,6 @@ class TimeFormatSettings(ConfigurationModelBase):
self._time_format: Optional[str] = None
self._date_time_format: Optional[str] = None
self._date_time_log_format: Optional[str] = None
- self._os_name: Optional[str] = None
- self._hostname: Optional[str] = None
@property
def date_format(self) -> str:
diff --git a/src/tests/appsettings.development.json b/src/tests/appsettings.development.json
deleted file mode 100644
index 62ec6c61..00000000
--- a/src/tests/appsettings.development.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "LoggingSettings": {
- "Path": "logs/",
- "Filename": "log_$start_time.log",
- "ConsoleLogLevel": "TRACE",
- "FileLogLevel": "TRACE"
- }
-}
\ No newline at end of file
diff --git a/src/tests/appsettings.edrafts-lapi.json b/src/tests/appsettings.edrafts-lapi.json
new file mode 100644
index 00000000..9af6f6c0
--- /dev/null
+++ b/src/tests/appsettings.edrafts-lapi.json
@@ -0,0 +1,20 @@
+{
+ "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": "TRACE",
+ "FileLogLevel": "TRACE"
+ },
+ "EMailClientSettings": {
+ "Host": "mail.sh-edraft.de",
+ "Port": "587",
+ "UserName": "dev-srv@sh-edraft.de",
+ "Credentials": "RmBOQX1eNFYiYjgsSid3fV1nelc2WA=="
+ }
+}
\ No newline at end of file
diff --git a/src/tests/appsettings.edrafts-pc.json b/src/tests/appsettings.edrafts-pc.json
index 62ec6c61..9af6f6c0 100644
--- a/src/tests/appsettings.edrafts-pc.json
+++ b/src/tests/appsettings.edrafts-pc.json
@@ -1,8 +1,20 @@
{
+ "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": "TRACE",
"FileLogLevel": "TRACE"
+ },
+ "EMailClientSettings": {
+ "Host": "mail.sh-edraft.de",
+ "Port": "587",
+ "UserName": "dev-srv@sh-edraft.de",
+ "Credentials": "RmBOQX1eNFYiYjgsSid3fV1nelc2WA=="
}
}
\ No newline at end of file
diff --git a/src/tests/appsettings.testing.json b/src/tests/appsettings.testing.json
index 3b586a2c..d134912e 100644
--- a/src/tests/appsettings.testing.json
+++ b/src/tests/appsettings.testing.json
@@ -6,12 +6,9 @@
"FileLogLevel": "TRACE"
},
- "PublishSettings": {
- "SourcePath": "../",
- "DistPath": "../../dist",
- "Templates": [],
- "IncludedFiles": [],
- "ExcludedFiles": [],
- "TemplateEnding": "_template.txt"
+ "DatabaseSettings": {
+ "ConnectionString": "mysql+mysqlconnector://sh_cpl:$credentials@localhost/sh_cpl",
+ "Credentials": "MHZhc0Y2bjhKc1VUMWV0Qw==",
+ "Encoding": "utf8mb4"
}
}
\ No newline at end of file
diff --git a/src/tests/build.json b/src/tests/build.json
new file mode 100644
index 00000000..3921c95f
--- /dev/null
+++ b/src/tests/build.json
@@ -0,0 +1,59 @@
+{
+ "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": "../../build_test/logs/",
+ "Filename": "log_$start_time.log",
+ "ConsoleLogLevel": "INFO",
+ "FileLogLevel": "TRACE"
+ },
+ "PublishSettings": {
+ "SourcePath": "./",
+ "DistPath": "../../build_test/dist",
+ "Templates": [
+ {
+ "TemplatePath": "../../publish_templates/all_template.txt",
+ "Name": "all",
+ "Description": "",
+ "LongDescription": "",
+ "CopyrightDate": "2020",
+ "CopyrightName": "sh-edraft.de",
+ "LicenseName": "MIT",
+ "LicenseDescription": ", see LICENSE for more details.",
+ "Title": "",
+ "Author": "Sven Heidemann",
+ "Version": {
+ "Major": 2020,
+ "Minor": 12,
+ "Micro": 10
+ }
+ },
+ {
+ "TemplatePath": "../../publish_templates/all_template.txt",
+ "Name": "sh_edraft",
+ "Description": "common python library",
+ "LongDescription": "Library to share common classes and models used at sh-edraft.de",
+ "CopyrightDate": "2020",
+ "CopyrightName": "sh-edraft.de",
+ "LicenseName": "MIT",
+ "LicenseDescription": ", see LICENSE for more details.",
+ "Title": "",
+ "Author": "Sven Heidemann",
+ "Version": {
+ "Major": 2020,
+ "Minor": 12,
+ "Micro": 10
+ }
+ }
+ ],
+ "IncludedFiles": [
+ ],
+ "ExcludedFiles": [
+ ],
+ "TemplateEnding": "_template.txt"
+ }
+}
diff --git a/src/tests/configuration/__init__.py b/src/tests/configuration/__init__.py
deleted file mode 100644
index 2c43c7cd..00000000
--- a/src/tests/configuration/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-tests.configuration
-~~~~~~~~~~~~~~~~~~~
-
-
-
-:copyright: (c) 2020 sh-edraft.de
-:license: MIT, see LICENSE for more details.
-
-"""
-
-__title__ = 'tests.configuration'
-__author__ = 'Sven Heidemann'
-__license__ = 'MIT'
-__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
-__version__ = '2020.12.9'
-
-from collections import namedtuple
-
-# imports:
-
-VersionInfo = namedtuple('VersionInfo', 'major minor micro')
-version_info = VersionInfo(major=2020, minor=12, micro=9)
diff --git a/src/tests/configuration/config.py b/src/tests/configuration/config.py
deleted file mode 100644
index 27218978..00000000
--- a/src/tests/configuration/config.py
+++ /dev/null
@@ -1,93 +0,0 @@
-import os
-import unittest
-from typing import cast
-
-from sh_edraft.configuration import Configuration
-from sh_edraft.environment.model import EnvironmentName
-from sh_edraft.hosting import ApplicationHost
-from sh_edraft.logging.model import LoggingSettings, LoggingLevel
-from sh_edraft.publishing.model import PublishSettings
-from sh_edraft.time.model import TimeFormatSettings
-
-
-class ConfigTest(unittest.TestCase):
-
- def setUp(self):
- self._app_host = ApplicationHost()
- self._config = cast(Configuration, self._app_host.configuration)
-
- def test_create(self):
- print(f'{__name__}.test_create:')
- self.assertIsNotNone(self._config)
- self._config.create()
- self.assertIsNotNone(self._config)
-
- self.assertEqual(len(self._config._config), 0)
- self.assertIsNotNone(self._app_host.application_runtime)
-
- def test_env_vars(self):
- print(f'{__name__}.test_env_vars:')
- self._config.add_environment_variables('PYTHON_')
- self._config.add_environment_variables('CPL_')
-
- def test_arguments(self):
- print(f'{__name__}.test_arguments:')
- self._config.add_argument_variables()
- self.assertEqual(self._config.environment.environment_name, EnvironmentName.testing.value)
-
- def test_appsettings(self):
- print(f'{__name__}.test_appsettings:')
- self._config.add_json_file(f'appsettings.json')
-
- time_formats: TimeFormatSettings = cast(TimeFormatSettings, self._config.get_configuration(TimeFormatSettings))
- self.assertIsNotNone(time_formats)
- self.assertEqual(time_formats.date_format, '%Y-%m-%d')
- self.assertEqual(time_formats.time_format, '%H:%M:%S')
- self.assertEqual(time_formats.date_time_format, '%Y-%m-%d %H:%M:%S.%f')
- self.assertEqual(time_formats.date_time_log_format, '%Y-%m-%d_%H-%M-%S')
-
- logging = cast(LoggingSettings, self._config.get_configuration(LoggingSettings))
- self.assertIsNotNone(logging)
- self.assertEqual(logging.path, 'logs/')
- self.assertEqual(logging.filename, 'log_$start_time.log')
- self.assertEqual(logging.console.value, LoggingLevel.ERROR.value)
- self.assertEqual(logging.level.value, LoggingLevel.WARN.value)
-
- with self.assertRaises(Exception):
- publish: PublishSettings = cast(PublishSettings, self._config.get_configuration(PublishSettings))
-
- def test_appsettings_environment(self):
- print(f'{__name__}.test_appsettings_environment:')
- self._config.add_argument_variables()
- self._config.add_json_file(f'appsettings.{self._config.environment.environment_name}.json')
-
- logging = cast(LoggingSettings, self._config.get_configuration(LoggingSettings))
- self.assertIsNotNone(logging)
- self.assertEqual(logging.path, 'logs/')
- self.assertEqual(logging.filename, 'log_$start_time.log')
- self.assertEqual(logging.console.value, LoggingLevel.TRACE.value)
- self.assertEqual(logging.level.value, LoggingLevel.TRACE.value)
-
- publish: PublishSettings = cast(PublishSettings, self._config.get_configuration(PublishSettings))
- self.assertIsNotNone(publish)
- self.assertEqual(publish.source_path, '../')
- self.assertEqual(publish.dist_path, '../../dist')
- self.assertEqual(publish.templates, [])
- self.assertEqual(publish.included_files, [])
- self.assertEqual(publish.excluded_files, [])
- self.assertEqual(publish.template_ending, '_template.txt')
-
- def test_appsettings_host(self):
- print(f'{__name__}.test_appsettings_host:')
- self._config.add_json_file(f'appsettings.{self._config.environment.host_name}.json')
-
- def test_appsettings_customer(self):
- print(f'{__name__}.test_appsettings_customer:')
- file_name = f'appsettings.{self._config.environment.customer}.json'
- with self.assertRaises(SystemExit):
- if os.path.isfile(f'{self._config.environment.content_root_path}/{file_name}'):
- os.remove(f'{self._config.environment.content_root_path}/{file_name}')
-
- self._config.add_json_file(file_name)
-
- self._config.add_json_file(file_name, optional=True)
diff --git a/src/tests/hosting/__init__.py b/src/tests/hosting/__init__.py
deleted file mode 100644
index dd9b9446..00000000
--- a/src/tests/hosting/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-tests.hosting
-~~~~~~~~~~~~~~~~~~~
-
-
-
-:copyright: (c) 2020 sh-edraft.de
-:license: MIT, see LICENSE for more details.
-
-"""
-
-__title__ = 'tests.hosting'
-__author__ = 'Sven Heidemann'
-__license__ = 'MIT'
-__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
-__version__ = '2020.12.9'
-
-from collections import namedtuple
-
-# imports:
-
-VersionInfo = namedtuple('VersionInfo', 'major minor micro')
-version_info = VersionInfo(major=2020, minor=12, micro=9)
diff --git a/src/tests/hosting/app_host.py b/src/tests/hosting/app_host.py
deleted file mode 100644
index ec940481..00000000
--- a/src/tests/hosting/app_host.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import unittest
-import datetime
-
-from sh_edraft.configuration.base import ConfigurationBase
-from sh_edraft.hosting import ApplicationHost
-from sh_edraft.hosting.base import ApplicationRuntimeBase
-from sh_edraft.service.base import ServiceProviderBase
-
-
-class AppHostTest(unittest.TestCase):
-
- def setUp(self):
- pass
-
- def test_create(self):
- print(f'{__name__}.test_create:')
- app_host = ApplicationHost()
- self.assertIsNotNone(app_host)
- app_host.create()
-
- self.assertIsNotNone(app_host.configuration)
- self.assertTrue(isinstance(app_host.configuration, ConfigurationBase))
-
- self.assertIsNotNone(app_host.application_runtime)
- self.assertTrue(isinstance(app_host.application_runtime, ApplicationRuntimeBase))
-
- self.assertIsNotNone(app_host.services)
- self.assertTrue(isinstance(app_host.services, ServiceProviderBase))
-
- self.assertIsNotNone(app_host._start_time)
- self.assertTrue(isinstance(app_host._start_time, datetime.datetime))
- self.assertIsNotNone(app_host._end_time)
- self.assertTrue(isinstance(app_host._end_time, datetime.datetime))
diff --git a/src/tests/publish_test/__init__.py b/src/tests/publish_test/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/tests/publish_test/publisher_test.py b/src/tests/publish_test/publisher_test.py
new file mode 100644
index 00000000..06f95519
--- /dev/null
+++ b/src/tests/publish_test/publisher_test.py
@@ -0,0 +1,52 @@
+import os
+import unittest
+
+from sh_edraft.console import Console
+from sh_edraft.hosting import ApplicationHost
+from sh_edraft.logging import Logger
+from sh_edraft.logging.base import LoggerBase
+from sh_edraft.publish import Publisher
+from sh_edraft.publish.base import PublisherBase
+from sh_edraft.publish.model import PublishSettings
+
+
+class PublisherTest(unittest.TestCase):
+
+ def setUp(self):
+ Console.disable()
+ self._app_host = ApplicationHost()
+ self._configuration = self._app_host.configuration
+ self._services = self._app_host.services
+
+ self._configuration.add_environment_variables('CPL_')
+ self._configuration.add_argument_variables()
+ self._configuration.add_json_file(f'build.json')
+
+ self._services.add_singleton(LoggerBase, Logger)
+ self._services.add_singleton(PublisherBase, Publisher)
+ self._publisher: Publisher = self._services.get_service(PublisherBase)
+
+ def test_include(self):
+ value = './test.py'
+ self._publisher.include(value)
+ self.assertTrue(value in self._publisher._publish_settings.included_files)
+
+ def test_exclude(self):
+ value = './test.py'
+ self._publisher.exclude(value)
+ self.assertTrue(value in self._publisher._publish_settings.excluded_files)
+
+ def test_create(self):
+ self._publisher.create()
+ self.assertTrue(os.path.isdir(self._configuration.get_configuration(PublishSettings).dist_path))
+
+ def test_build(self):
+ self._publisher.create()
+ self._publisher.build()
+ self.assertTrue(os.path.isdir(self._configuration.get_configuration(PublishSettings).dist_path))
+
+ def test_publish(self):
+ self._publisher.create()
+ self._publisher.build()
+ self._publisher.publish()
+ self.assertTrue(os.path.isdir(self._configuration.get_configuration(PublishSettings).dist_path))
diff --git a/src/tests/service_providing/__init__.py b/src/tests/service_providing/__init__.py
deleted file mode 100644
index 97f8de34..00000000
--- a/src/tests/service_providing/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-tests.service_providing
-~~~~~~~~~~~~~~~~~~~
-
-
-
-:copyright: (c) 2020 sh-edraft.de
-:license: MIT, see LICENSE for more details.
-
-"""
-
-__title__ = 'tests.service_providing'
-__author__ = 'Sven Heidemann'
-__license__ = 'MIT'
-__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
-__version__ = '2020.12.9'
-
-from collections import namedtuple
-
-# imports:
-
-VersionInfo = namedtuple('VersionInfo', 'major minor micro')
-version_info = VersionInfo(major=2020, minor=12, micro=9)
diff --git a/src/tests/service_providing/service_provider.py b/src/tests/service_providing/service_provider.py
deleted file mode 100644
index 4ddc5734..00000000
--- a/src/tests/service_providing/service_provider.py
+++ /dev/null
@@ -1,136 +0,0 @@
-import unittest
-from typing import cast
-
-from sh_edraft.hosting import ApplicationHost
-from sh_edraft.logging import Logger
-from sh_edraft.logging.base import LoggerBase
-from sh_edraft.publishing import Publisher
-from sh_edraft.publishing.base import PublisherBase
-from sh_edraft.service import ServiceProvider
-from sh_edraft.service.base import ServiceBase
-
-
-class ServiceProviderTest(unittest.TestCase):
-
- def setUp(self):
- self._app_host = ApplicationHost()
- self._config = self._app_host.configuration
- self._config.create()
- self._config.add_environment_variables('PYTHON_')
- self._config.add_environment_variables('CPL_')
- self._config.add_argument_variables()
- self._config.add_json_file(f'appsettings.json')
- self._config.add_json_file(f'appsettings.{self._config.environment.environment_name}.json')
- self._config.add_json_file(f'appsettings.{self._config.environment.host_name}.json', optional=True)
- self._services: ServiceProvider = cast(ServiceProvider, self._app_host.services)
- self._services.create()
-
- def _check_general_requirements(self):
- self.assertIsNotNone(self._services)
-
- def _add_logger(self):
- self._services.add_singleton(LoggerBase, Logger)
- logger: Logger = self._services.get_service(LoggerBase)
- logger.create()
-
- def test_create(self):
- print(f'{__name__}.test_create:')
- provider = ServiceProvider(self._app_host.application_runtime)
- self.assertIsNotNone(provider)
- provider.create()
- self.assertIsNotNone(provider)
-
- def test_add_singleton(self):
- print(f'{__name__}.test_add_singleton:')
- self._check_general_requirements()
-
- self._services.add_singleton(LoggerBase, Logger)
- self.assertGreater(len(self._services._singleton_services), 0)
-
- found = False
- for service_type in self._services._singleton_services:
- service = self._services._singleton_services[service_type]
- if service_type == LoggerBase and (
- isinstance(service, Logger) and
- isinstance(service, LoggerBase) and
- isinstance(service, ServiceBase)
- ):
- if not found:
- found = True
-
- self.assertTrue(found)
-
- found = False
- for service_type in self._services._singleton_services:
- service = self._services._singleton_services[service_type]
- if service_type == PublisherBase and (
- isinstance(service, Publisher) and
- isinstance(service, PublisherBase) and
- isinstance(service, ServiceBase)
- ):
- if not found:
- found = True
-
- self.assertFalse(found)
-
- def test_get_singleton(self):
- print(f'{__name__}.test_get_singleton:')
- self._check_general_requirements()
-
- self._services.add_singleton(LoggerBase, Logger)
- logger: Logger = self._services.get_service(LoggerBase)
- self.assertIsNotNone(logger)
- self.assertTrue(isinstance(logger, Logger))
- self.assertTrue(isinstance(logger, LoggerBase))
- self.assertTrue(isinstance(logger, ServiceBase))
-
- self.assertEqual(logger._app_runtime, self._app_host.application_runtime)
-
- def test_add_scoped(self):
- print(f'{__name__}.test_add_scoped:')
- self._check_general_requirements()
- self._add_logger()
-
- self._services.add_scoped(PublisherBase, Publisher)
-
- def test_get_scoped(self):
- print(f'{__name__}.test_get_scoped:')
- self._check_general_requirements()
- self._add_logger()
-
- self._services.add_scoped(PublisherBase, Publisher)
- publisher: Publisher = self._services.get_service(PublisherBase)
- self.assertIsNotNone(publisher)
- self.assertTrue(isinstance(publisher, Publisher))
- self.assertTrue(isinstance(publisher, PublisherBase))
- self.assertTrue(isinstance(publisher, ServiceBase))
-
- self.assertTrue(isinstance(publisher._logger, Logger))
- self.assertTrue(isinstance(publisher._logger, LoggerBase))
- self.assertTrue(isinstance(publisher._logger, ServiceBase))
-
- def test_add_transient(self):
- print(f'{__name__}.test_add_transient:')
- self._check_general_requirements()
- self._add_logger()
-
- self._services.add_transient(PublisherBase, Publisher)
- self.assertGreater(len(self._services._transient_services), 0)
-
- self.assertTrue(bool(isinstance(service, ServiceBase) for service in self._services._transient_services))
-
- def test_get_transient(self):
- print(f'{__name__}.test_get_transient:')
- self._check_general_requirements()
- self._add_logger()
-
- self._services.add_transient(PublisherBase, Publisher)
- publisher: Publisher = self._services.get_service(PublisherBase)
- self.assertIsNotNone(publisher)
- self.assertTrue(isinstance(publisher, Publisher))
- self.assertTrue(isinstance(publisher, PublisherBase))
- self.assertTrue(isinstance(publisher, ServiceBase))
-
- self.assertTrue(isinstance(publisher._logger, Logger))
- self.assertTrue(isinstance(publisher._logger, LoggerBase))
- self.assertTrue(isinstance(publisher._logger, ServiceBase))
diff --git a/src/tests/service_test/__init__.py b/src/tests/service_test/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/tests/service_test/provider_test.py b/src/tests/service_test/provider_test.py
new file mode 100644
index 00000000..96fef8eb
--- /dev/null
+++ b/src/tests/service_test/provider_test.py
@@ -0,0 +1,79 @@
+import unittest
+
+from sh_edraft.console import Console
+from sh_edraft.database.context import DatabaseContext
+from sh_edraft.hosting import ApplicationHost
+from sh_edraft.logging import Logger
+from sh_edraft.logging.base import LoggerBase
+
+
+class ProviderTest(unittest.TestCase):
+
+ def setUp(self):
+ Console.disable()
+ self._app_host = ApplicationHost()
+ self._configuration = self._app_host.configuration
+ self._services = self._app_host.services
+
+ self._configuration.add_environment_variables('CPL_')
+ self._configuration.add_argument_variables()
+ 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)
+
+ def test_get_db_context(self):
+ self._services.add_db_context(DatabaseContext)
+ db: DatabaseContext = self._services.get_db_context()
+
+ self.assertIsNotNone(db)
+
+ def test_get_service_singleton(self):
+ self._services.add_singleton(LoggerBase, Logger)
+ logger = self._services.get_service(LoggerBase)
+
+ self.assertIsNotNone(logger)
+
+ def test_get_service_scoped(self):
+ self._services.add_scoped(LoggerBase, Logger)
+ logger = self._services.get_service(LoggerBase)
+
+ self.assertIsNotNone(logger)
+
+ def test_get_service_transient(self):
+ self._services.add_transient(LoggerBase, Logger)
+ logger = self._services.get_service(LoggerBase)
+
+ self.assertIsNotNone(logger)
+
+ def test_remove_service_singleton(self):
+ self._services.add_singleton(LoggerBase, Logger)
+ logger = self._services.get_service(LoggerBase)
+
+ self.assertIsNotNone(logger)
+
+ self._services.remove_service(LoggerBase)
+ logger = self._services.get_service(LoggerBase)
+
+ self.assertIsNone(logger)
+
+ def test_remove_service_scoped(self):
+ self._services.add_scoped(LoggerBase, Logger)
+ logger = self._services.get_service(LoggerBase)
+
+ self.assertIsNotNone(logger)
+
+ self._services.remove_service(LoggerBase)
+ logger = self._services.get_service(LoggerBase)
+
+ self.assertIsNone(logger)
+
+ def test_remove_service_transient(self):
+ self._services.add_transient(LoggerBase, Logger)
+ logger = self._services.get_service(LoggerBase)
+
+ self.assertIsNotNone(logger)
+
+ self._services.remove_service(LoggerBase)
+ logger = self._services.get_service(LoggerBase)
+
+ self.assertIsNone(logger)
diff --git a/src/tests/services/__init__.py b/src/tests/services/__init__.py
deleted file mode 100644
index ad20eee4..00000000
--- a/src/tests/services/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-tests.services
-~~~~~~~~~~~~~~~~~~~
-
-
-
-:copyright: (c) 2020 sh-edraft.de
-:license: MIT, see LICENSE for more details.
-
-"""
-
-__title__ = 'tests.services'
-__author__ = 'Sven Heidemann'
-__license__ = 'MIT'
-__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
-__version__ = '2020.12.9'
-
-from collections import namedtuple
-
-# imports:
-
-VersionInfo = namedtuple('VersionInfo', 'major minor micro')
-version_info = VersionInfo(major=2020, minor=12, micro=9)
diff --git a/src/tests/services/logging/__init__.py b/src/tests/services/logging/__init__.py
deleted file mode 100644
index 37ae0e14..00000000
--- a/src/tests/services/logging/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-tests.services.logging
-~~~~~~~~~~~~~~~~~~~
-
-
-
-:copyright: (c) 2020 sh-edraft.de
-:license: MIT, see LICENSE for more details.
-
-"""
-
-__title__ = 'tests.services.logging'
-__author__ = 'Sven Heidemann'
-__license__ = 'MIT'
-__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
-__version__ = '2020.12.9'
-
-from collections import namedtuple
-
-# imports:
-
-VersionInfo = namedtuple('VersionInfo', 'major minor micro')
-version_info = VersionInfo(major=2020, minor=12, micro=9)
diff --git a/src/tests/services/logging/logger.py b/src/tests/services/logging/logger.py
deleted file mode 100644
index 4a17331e..00000000
--- a/src/tests/services/logging/logger.py
+++ /dev/null
@@ -1,206 +0,0 @@
-import os
-import shutil
-import unittest
-from string import Template
-from typing import cast
-
-from sh_edraft.hosting import ApplicationHost
-from sh_edraft.logging import Logger
-from sh_edraft.logging.model import LoggingSettings
-from sh_edraft.service import ServiceProvider
-from sh_edraft.time.model import TimeFormatSettings
-
-
-class LoggerTest(unittest.TestCase):
-
- def setUp(self):
- self._app_host = ApplicationHost()
- self._config = self._app_host.configuration
- self._config.create()
- self._config.add_environment_variables('PYTHON_')
- self._config.add_environment_variables('CPL_')
- self._config.add_argument_variables()
- self._config.add_json_file(f'appsettings.json')
- self._config.add_json_file(f'appsettings.{self._config.environment.environment_name}.json')
- self._config.add_json_file(f'appsettings.{self._config.environment.host_name}.json', optional=True)
- self._services: ServiceProvider = cast(ServiceProvider, self._app_host.services)
- self._services.create()
-
- self._app_runtime = self._app_host.application_runtime
- self._log_settings: LoggingSettings = self._config.get_configuration(LoggingSettings)
- self._time_format_settings: TimeFormatSettings = self._config.get_configuration(TimeFormatSettings)
-
- def tearDown(self):
- if os.path.isdir(self._log_settings.path):
- shutil.rmtree(self._log_settings.path)
-
- def _check_general_requirements(self):
- self.assertIsNotNone(self._log_settings)
- self.assertIsNotNone(self._time_format_settings)
-
- def test_create(self):
- print(f'{__name__}.test_create:')
- logger = Logger(self._log_settings, self._time_format_settings, self._app_runtime)
- logger.create()
- self.assertTrue(os.path.isdir(self._log_settings.path))
-
- log_file = Template(self._log_settings.filename).substitute(
- date_time_now=self._app_runtime.date_time_now.strftime(self._time_format_settings.date_time_format),
- start_time=self._app_runtime.start_time.strftime(self._time_format_settings.date_time_log_format)
- )
- self.assertTrue(os.path.isfile(self._log_settings.path + log_file))
-
- def test_header(self):
- print(f'{__name__}.test_header:')
- logger = Logger(self._log_settings, self._time_format_settings, self._app_runtime)
- logger.create()
- logger.header('HeaderTest:')
-
- log_file = Template(self._log_settings.filename).substitute(
- date_time_now=self._app_runtime.date_time_now.strftime(self._time_format_settings.date_time_format),
- start_time=self._app_runtime.start_time.strftime(self._time_format_settings.date_time_log_format)
- )
- log_content = []
-
- try:
- with open(self._log_settings.path + log_file, "r") as log:
- log_content = log.readlines()
- log.close()
- except Exception as e:
- print('Cannot open log file', e)
-
- self.assertGreater(len(log_content), 0)
- self.assertEqual(log_content[len(log_content) - 1], 'HeaderTest:\n')
-
- def test_trace(self):
- print(f'{__name__}.test_trace:')
- logger = Logger(self._log_settings, self._time_format_settings, self._app_runtime)
- logger.create()
- logger.trace(__name__, f'{__name__}.test_trace:')
-
- log_file = Template(self._log_settings.filename).substitute(
- date_time_now=self._app_runtime.date_time_now.strftime(self._time_format_settings.date_time_format),
- start_time=self._app_runtime.start_time.strftime(self._time_format_settings.date_time_log_format)
- )
- log_content = []
-
- try:
- with open(self._log_settings.path + log_file, "r") as log:
- log_content = log.readlines()
- log.close()
- except Exception as e:
- print('Cannot open log file', e)
-
- self.assertGreater(len(log_content), 0)
- self.assertTrue(log_content[len(log_content) - 1].endswith(f'[ TRACE ] [ {__name__} ]: {__name__}.test_trace:\n'))
-
- def test_debug(self):
- print(f'{__name__}.test_debug:')
- logger = Logger(self._log_settings, self._time_format_settings, self._app_runtime)
- logger.create()
- logger.debug(__name__, f'{__name__}.test_debug:')
-
- log_file = Template(self._log_settings.filename).substitute(
- date_time_now=self._app_runtime.date_time_now.strftime(self._time_format_settings.date_time_format),
- start_time=self._app_runtime.start_time.strftime(self._time_format_settings.date_time_log_format)
- )
- log_content = []
-
- try:
- with open(self._log_settings.path + log_file, "r") as log:
- log_content = log.readlines()
- log.close()
- except Exception as e:
- print('Cannot open log file', e)
-
- self.assertGreater(len(log_content), 0)
- self.assertTrue(log_content[len(log_content) - 1].endswith(f'[ DEBUG ] [ {__name__} ]: {__name__}.test_debug:\n'))
-
- def test_info(self):
- print(f'{__name__}.test_info:')
- logger = Logger(self._log_settings, self._time_format_settings, self._app_runtime)
- logger.create()
- logger.info(__name__, f'{__name__}.test_info:')
-
- log_file = Template(self._log_settings.filename).substitute(
- date_time_now=self._app_runtime.date_time_now.strftime(self._time_format_settings.date_time_format),
- start_time=self._app_runtime.start_time.strftime(self._time_format_settings.date_time_log_format)
- )
- log_content = []
-
- try:
- with open(self._log_settings.path + log_file, "r") as log:
- log_content = log.readlines()
- log.close()
- except Exception as e:
- print('Cannot open log file', e)
-
- self.assertGreater(len(log_content), 0)
- self.assertTrue(log_content[len(log_content) - 1].endswith(f'[ INFO ] [ {__name__} ]: {__name__}.test_info:\n'))
-
- def test_warn(self):
- print(f'{__name__}.test_warn:')
- logger = Logger(self._log_settings, self._time_format_settings, self._app_runtime)
- logger.create()
- logger.warn(__name__, f'{__name__}.test_warn:')
-
- log_file = Template(self._log_settings.filename).substitute(
- date_time_now=self._app_runtime.date_time_now.strftime(self._time_format_settings.date_time_format),
- start_time=self._app_runtime.start_time.strftime(self._time_format_settings.date_time_log_format)
- )
- log_content = []
-
- try:
- with open(self._log_settings.path + log_file, "r") as log:
- log_content = log.readlines()
- log.close()
- except Exception as e:
- print('Cannot open log file', e)
-
- self.assertGreater(len(log_content), 0)
- self.assertTrue(log_content[len(log_content) - 1].endswith(f'[ WARN ] [ {__name__} ]: {__name__}.test_warn:\n'))
-
- def test_error(self):
- print(f'{__name__}.test_error:')
- logger = Logger(self._log_settings, self._time_format_settings, self._app_runtime)
- logger.create()
- logger.error(__name__, f'{__name__}.test_error:')
-
- log_file = Template(self._log_settings.filename).substitute(
- date_time_now=self._app_runtime.date_time_now.strftime(self._time_format_settings.date_time_format),
- start_time=self._app_runtime.start_time.strftime(self._time_format_settings.date_time_log_format)
- )
- log_content = []
-
- try:
- with open(self._log_settings.path + log_file, "r") as log:
- log_content = log.readlines()
- log.close()
- except Exception as e:
- print('Cannot open log file', e)
-
- self.assertGreater(len(log_content), 0)
- self.assertTrue(log_content[len(log_content) - 1].endswith(f'[ ERROR ] [ {__name__} ]: {__name__}.test_error:\n'))
-
- def test_fatal(self):
- print(f'{__name__}.test_fatal:')
- logger = Logger(self._log_settings, self._time_format_settings, self._app_runtime)
- logger.create()
- with self.assertRaises(SystemExit):
- logger.fatal(__name__, f'{__name__}.test_fatal:')
-
- log_file = Template(self._log_settings.filename).substitute(
- date_time_now=self._app_runtime.date_time_now.strftime(self._time_format_settings.date_time_format),
- start_time=self._app_runtime.start_time.strftime(self._time_format_settings.date_time_log_format)
- )
- log_content = []
-
- try:
- with open(self._log_settings.path + log_file, "r") as log:
- log_content = log.readlines()
- log.close()
- except Exception as e:
- print('Cannot open log file', e)
-
- self.assertGreater(len(log_content), 0)
- self.assertTrue(log_content[len(log_content) - 1].endswith(f'[ FATAL ] [ {__name__} ]: {__name__}.test_fatal:\n'))
diff --git a/src/tests/services/publishing/__init__.py b/src/tests/services/publishing/__init__.py
deleted file mode 100644
index dbe20dd2..00000000
--- a/src/tests/services/publishing/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-tests.services.publishing
-~~~~~~~~~~~~~~~~~~~
-
-
-
-:copyright: (c) 2020 sh-edraft.de
-:license: MIT, see LICENSE for more details.
-
-"""
-
-__title__ = 'tests.services.publishing'
-__author__ = 'Sven Heidemann'
-__license__ = 'MIT'
-__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
-__version__ = '2020.12.9'
-
-from collections import namedtuple
-
-# imports:
-
-VersionInfo = namedtuple('VersionInfo', 'major minor micro')
-version_info = VersionInfo(major=2020, minor=12, micro=9)
diff --git a/src/tests/services/publishing/publisher.py b/src/tests/services/publishing/publisher.py
deleted file mode 100644
index 9b75d13a..00000000
--- a/src/tests/services/publishing/publisher.py
+++ /dev/null
@@ -1,92 +0,0 @@
-import os
-import shutil
-import unittest
-
-from sh_edraft.hosting import ApplicationHost
-from sh_edraft.logging import Logger
-from sh_edraft.logging.model import LoggingSettings
-from sh_edraft.publishing import Publisher
-from sh_edraft.publishing.model import Template
-from sh_edraft.publishing.model import PublishSettings
-from sh_edraft.coding.model import Version
-from sh_edraft.time.model import TimeFormatSettings
-
-
-class PublisherTest(unittest.TestCase):
-
- def _configure(self):
- self._version = Version(2020, 12, 5)
- templates = [
- Template(
- '../../publish_templates/all_template.txt',
- 'all',
- '',
- '',
- '2020',
- 'sh-edraft.de',
- 'MIT',
- ', see LICENSE for more details.',
- '',
- 'Sven Heidemann',
- self._version
- ),
- Template(
- '../../publish_templates/all_template.txt',
- 'sh_edraft',
- 'common python library',
- 'Library to share common classes and models used at sh-edraft.de',
- '2020',
- 'sh-edraft.de',
- 'MIT',
- ', see LICENSE for more details.',
- '',
- 'Sven Heidemann',
- self._version
- )
- ]
-
- self._source_path = '../'
- self._dist_path = '../../dist'
-
- self._publish_settings_model = PublishSettings()
- self._publish_settings_model.from_dict({
- "SourcePath": self._source_path,
- "DistPath": self._dist_path,
- "Templates": templates,
- "IncludedFiles": [],
- "ExcludedFiles": [],
- "TemplateEnding": "_template.txt",
- })
-
- def setUp(self):
- self._app_host = ApplicationHost()
- self._config = self._app_host.configuration
- self._config.create()
- self._config.add_environment_variables('PYTHON_')
- self._config.add_environment_variables('CPL_')
- self._config.add_argument_variables()
- self._config.add_json_file(f'appsettings.json')
- self._config.add_json_file(f'appsettings.{self._config.environment.environment_name}.json')
- self._config.add_json_file(f'appsettings.{self._config.environment.host_name}.json', optional=True)
-
- self._app_runtime = self._app_host.application_runtime
-
- self._configure()
-
- self._log_settings: LoggingSettings = self._config.get_configuration(LoggingSettings)
- self._time_format_settings: TimeFormatSettings = self._config.get_configuration(TimeFormatSettings)
- self._logger = Logger(self._log_settings, self._time_format_settings, self._app_host.application_runtime)
- self._logger.create()
-
- def tearDown(self):
- if os.path.isdir(self._log_settings.path):
- shutil.rmtree(self._log_settings.path)
-
- def test_create(self):
- print(f'{__name__}.test_create:')
- publisher: Publisher = Publisher(self._logger, self._publish_settings_model)
- self.assertIsNotNone(publisher)
-
- publisher.create()
- self.assertTrue(os.path.isdir(self._dist_path))
- self.assertEqual(publisher._publish_settings, self._publish_settings_model)
diff --git a/src/tests/setup.py b/src/tests/setup.py
new file mode 100644
index 00000000..b9da5bf5
--- /dev/null
+++ b/src/tests/setup.py
@@ -0,0 +1,24 @@
+import setuptools
+
+setuptools.setup(
+ name='sh_edraft_unittests',
+ version='2020.0.1',
+ packages=setuptools.find_packages(exclude=["tests*"]),
+ url='https://www.sh-edraft.de',
+ license='MIT',
+ author='Sven Heidemann',
+ author_email='edraft.sh@gmail.com',
+ include_package_data=True,
+ description='sh-edraft python common lib unittest',
+ python_requires='>=3.8',
+ install_requires=[
+ 'discord.py',
+ 'flask',
+ 'mysql-connector',
+ 'SQLAlchemy',
+ 'termcolor',
+ 'pyfiglet',
+ 'tabulate',
+ 'smtplib'
+ ]
+)
diff --git a/src/tests/tester.py b/src/tests/tester.py
deleted file mode 100644
index d7b17030..00000000
--- a/src/tests/tester.py
+++ /dev/null
@@ -1,59 +0,0 @@
-import unittest
-
-from tests.configuration.config import ConfigTest
-from tests.hosting.app_host import AppHostTest
-from tests.services.logging.logger import LoggerTest
-from tests.services.publishing.publisher import PublisherTest
-from tests.service_providing.service_provider import ServiceProviderTest
-
-
-class Tester:
-
- def __init__(self):
- self._suite = unittest.TestSuite()
-
- def create(self):
- # hosting app host
- self._suite.addTest(AppHostTest('test_create'))
-
- # configuration
- self._suite.addTest(ConfigTest('test_create'))
- self._suite.addTest(ConfigTest('test_env_vars'))
- self._suite.addTest(ConfigTest('test_arguments'))
- self._suite.addTest(ConfigTest('test_appsettings'))
- self._suite.addTest(ConfigTest('test_appsettings_environment'))
- self._suite.addTest(ConfigTest('test_appsettings_host'))
- self._suite.addTest(ConfigTest('test_appsettings_customer'))
-
- # providing
- self._suite.addTest(ServiceProviderTest('test_create'))
- self._suite.addTest(ServiceProviderTest('test_add_singleton'))
- self._suite.addTest(ServiceProviderTest('test_get_singleton'))
- self._suite.addTest(ServiceProviderTest('test_add_scoped'))
- self._suite.addTest(ServiceProviderTest('test_get_scoped'))
- self._suite.addTest(ServiceProviderTest('test_add_transient'))
- self._suite.addTest(ServiceProviderTest('test_get_transient'))
-
- # logging
- self._suite.addTest(LoggerTest('test_create'))
- self._suite.addTest(LoggerTest('test_header'))
- self._suite.addTest(LoggerTest('test_trace'))
- self._suite.addTest(LoggerTest('test_debug'))
- self._suite.addTest(LoggerTest('test_info'))
- self._suite.addTest(LoggerTest('test_warn'))
- self._suite.addTest(LoggerTest('test_error'))
- self._suite.addTest(LoggerTest('test_fatal'))
-
- # publishing
- self._suite.addTest(PublisherTest('test_create'))
-
- def start(self):
- runner = unittest.TextTestRunner()
- runner.run(self._suite)
- # unittest.main()
-
-
-if __name__ == '__main__':
- tester = Tester()
- tester.create()
- tester.start()
diff --git a/src/tests/time_test/__init__.py b/src/tests/time_test/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/tests/time_test/time_format_settings_test.py b/src/tests/time_test/time_format_settings_test.py
new file mode 100644
index 00000000..9bc5347a
--- /dev/null
+++ b/src/tests/time_test/time_format_settings_test.py
@@ -0,0 +1,26 @@
+import unittest
+
+from sh_edraft.time.model import TimeFormatSettingsNames, TimeFormatSettings
+
+
+class TimeFormatSettingsTest(unittest.TestCase):
+
+ def setUp(self): pass
+
+ def test_from_dict(self):
+ test_dict = {
+ TimeFormatSettingsNames.date_format.value: '%H:%M:%S',
+ TimeFormatSettingsNames.time_format.value: '%Y-%m-%d',
+ TimeFormatSettingsNames.date_time_format.value: '%Y-%m-%d %H:%M:%S.%f',
+ TimeFormatSettingsNames.date_time_log_format.value: '%Y-%m-%d_%H-%M-%S'
+ }
+
+ settings = TimeFormatSettings()
+ settings.from_dict(test_dict)
+
+ self.assertIsNotNone(settings)
+
+ self.assertEqual(test_dict[TimeFormatSettingsNames.date_format.value], settings.date_format)
+ self.assertEqual(test_dict[TimeFormatSettingsNames.time_format.value], settings.time_format)
+ self.assertEqual(test_dict[TimeFormatSettingsNames.date_time_format.value], settings.date_time_format)
+ self.assertEqual(test_dict[TimeFormatSettingsNames.date_time_log_format.value], settings.date_time_log_format)
diff --git a/src/tests/utils_test/__init__.py b/src/tests/utils_test/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/tests/utils_test/credential_manager_test.py b/src/tests/utils_test/credential_manager_test.py
new file mode 100644
index 00000000..204f1283
--- /dev/null
+++ b/src/tests/utils_test/credential_manager_test.py
@@ -0,0 +1,37 @@
+import base64
+import unittest
+
+from sh_edraft.utils import CredentialManager
+
+
+class CredentialManagerTest(unittest.TestCase):
+
+ def setUp(self): pass
+
+ def test_encode(self):
+ test_string = 'Hello World'
+ expected_test_result = base64.b64encode(test_string.encode('utf-8')).decode('utf-8')
+
+ test_result = CredentialManager.encrypt(test_string)
+
+ self.assertIsNotNone(test_result)
+ self.assertEqual(expected_test_result, test_result)
+
+ def test_decode(self):
+ test_string = 'SGVsbG8gV29ybGQ='
+ expected_test_result = base64.b64decode(test_string).decode('utf-8')
+
+ test_result = CredentialManager.decrypt(test_string)
+
+ self.assertIsNotNone(test_result)
+ self.assertEqual(expected_test_result, test_result)
+
+ def test_build_string(self):
+ test_string = 'String is $credentials'
+ test_credentials = 'SGVsbG8gV29ybGQ='
+ expected_test_result = test_string.replace('$credentials', base64.b64decode(test_credentials).decode('utf-8'))
+
+ test_result = CredentialManager.build_string(test_string, test_credentials)
+
+ self.assertIsNotNone(test_result)
+ self.assertEqual(expected_test_result, test_result)
diff --git a/src/tests_dev/program.py b/src/tests_dev/program.py
index fec9b31e..e08eadbe 100644
--- a/src/tests_dev/program.py
+++ b/src/tests_dev/program.py
@@ -74,7 +74,6 @@ class Program(ApplicationBase):
Console.write_line('Hello World')
Console.write('\nName: ')
Console.write_line('Hello', Console.read_line())
- Console
Console.clear()
Console.write_at(5, 5, 'at 5, 5')
Console.write_at(10, 10, 'at 10, 10')