diff --git a/.idea/sh_common_py_lib.iml b/.idea/sh_common_py_lib.iml
index ea803c41..7f4b6244 100644
--- a/.idea/sh_common_py_lib.iml
+++ b/.idea/sh_common_py_lib.iml
@@ -12,6 +12,7 @@
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 8a2e33f9..8106a0a5 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -22,8 +22,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -33,8 +55,8 @@
@@ -62,7 +84,7 @@
-
+
@@ -75,10 +97,10 @@
+
-
@@ -446,13 +468,6 @@
1605881914521
-
- 1606682897559
-
-
-
- 1606682897559
-
1607285697331
@@ -789,7 +804,14 @@
1608986131755
-
+
+ 1611431001647
+
+
+
+ 1611431001649
+
+
@@ -805,7 +827,6 @@
-
@@ -830,6 +851,18 @@
-
+
+
+
+
+
+
+
+ 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/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/tests/appsettings.edrafts-lapi.json b/src/tests/appsettings.edrafts-lapi.json
index 0b2e194a..9af6f6c0 100644
--- a/src/tests/appsettings.edrafts-lapi.json
+++ b/src/tests/appsettings.edrafts-lapi.json
@@ -16,48 +16,5 @@
"Port": "587",
"UserName": "dev-srv@sh-edraft.de",
"Credentials": "RmBOQX1eNFYiYjgsSid3fV1nelc2WA=="
- },
- "PublishSettings": {
- "SourcePath": "../",
- "DistPath": "../../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": 9
- }
- },
- {
- "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": 9
- }
- }
- ],
- "IncludedFiles": [],
- "ExcludedFiles": [],
- "TemplateEnding": "_template.txt"
}
}
\ No newline at end of file
diff --git a/src/tests/appsettings.edrafts-pc.json b/src/tests/appsettings.edrafts-pc.json
index 0b2e194a..9af6f6c0 100644
--- a/src/tests/appsettings.edrafts-pc.json
+++ b/src/tests/appsettings.edrafts-pc.json
@@ -16,48 +16,5 @@
"Port": "587",
"UserName": "dev-srv@sh-edraft.de",
"Credentials": "RmBOQX1eNFYiYjgsSid3fV1nelc2WA=="
- },
- "PublishSettings": {
- "SourcePath": "../",
- "DistPath": "../../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": 9
- }
- },
- {
- "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": 9
- }
- }
- ],
- "IncludedFiles": [],
- "ExcludedFiles": [],
- "TemplateEnding": "_template.txt"
}
}
\ No newline at end of file
diff --git a/src/tests/build.json b/src/tests/build.json
index dd013a2c..3921c95f 100644
--- a/src/tests/build.json
+++ b/src/tests/build.json
@@ -6,17 +6,17 @@
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
},
"LoggingSettings": {
- "Path": "../build/logs/",
+ "Path": "../../build_test/logs/",
"Filename": "log_$start_time.log",
"ConsoleLogLevel": "INFO",
"FileLogLevel": "TRACE"
},
"PublishSettings": {
"SourcePath": "./",
- "DistPath": "../build/dist",
+ "DistPath": "../../build_test/dist",
"Templates": [
{
- "TemplatePath": "../publish_templates/all_template.txt",
+ "TemplatePath": "../../publish_templates/all_template.txt",
"Name": "all",
"Description": "",
"LongDescription": "",
@@ -33,7 +33,7 @@
}
},
{
- "TemplatePath": "../publish_templates/all_template.txt",
+ "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",
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/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'
+ ]
+)