diff --git a/boswatch/configYaml.py b/boswatch/configYaml.py index d045de0..5e7239f 100644 --- a/boswatch/configYaml.py +++ b/boswatch/configYaml.py @@ -50,7 +50,7 @@ class ConfigYAML: except FileNotFoundError: logging.error("config file not found: %s", configPath) except yaml.parser.ParserError: - logging.exception("error in config file") + logging.exception("syntax error in config file: %s", configPath) return False def get(self, *args, default=None): diff --git a/boswatch/utils/paths.py b/boswatch/utils/paths.py index 146a260..e1c12c5 100644 --- a/boswatch/utils/paths.py +++ b/boswatch/utils/paths.py @@ -17,25 +17,13 @@ import logging import os import sys -import platform logging.debug("- %s loaded", __name__) # note searching for root part is not a nice solution atm ROOT_PATH = os.path.dirname(sys.modules['boswatch'].__file__).replace("\\", "/") + "/../" -# implements a system adaption for the paths -if platform.system() == "Linux": - LOG_PATH = "/var/log/boswatch/" - CONFIG_PATH = "/etc/opt/boswatch/" -else: - # FIXME LOG_PATH not used actually - # path is fixed in logger config.ini - LOG_PATH = ROOT_PATH + "log/" - CONFIG_PATH = ROOT_PATH + "config/" - -PLUGIN_PATH = ROOT_PATH + "plugin/" -CSV_PATH = ROOT_PATH + "csv/" +CONFIG_PATH = ROOT_PATH + "config/" BIN_PATH = ROOT_PATH + "_bin/" TEST_PATH = ROOT_PATH + "test/" diff --git a/test/boswatch/test_config.py b/test/boswatch/test_config.py index cbbc9f4..df6f7d1 100644 --- a/test/boswatch/test_config.py +++ b/test/boswatch/test_config.py @@ -15,9 +15,8 @@ @description: Unittests for BOSWatch. File have to run as "pytest" unittest """ import logging -from typing import Dict - import pytest +from boswatch.utils import paths from boswatch.configYaml import ConfigYAML @@ -34,23 +33,23 @@ def getConfig(): @pytest.fixture def getFilledConfig(): filledConfig = ConfigYAML() - filledConfig.loadConfigFile("test_config.yaml") + assert filledConfig.loadConfigFile(paths.TEST_PATH + "test_config.yaml") is True return filledConfig def test_loadConfigFile(getConfig): - """!load a local config file""" - assert getConfig.loadConfigFile("test_config.yaml") is True + """!load a config file""" + assert getConfig.loadConfigFile(paths.TEST_PATH + "test_config.yaml") is True def test_loadConfigFileFailed(getConfig): - """!load a local config file with syntax error""" - assert getConfig.loadConfigFile("test_configFailed.yaml") is False + """!load a config file with syntax error""" + assert getConfig.loadConfigFile(paths.TEST_PATH + "test_configFailed.yaml") is False def test_loadConfigFileNotFound(getConfig): - """!load a local config file where is not available""" - assert getConfig.loadConfigFile("test_configNotFound.yaml") is False + """!load a config file where is not available""" + assert getConfig.loadConfigFile(paths.TEST_PATH + "test_configNotFound.yaml") is False def test_getTypes(getFilledConfig): diff --git a/test/boswatch/test_config.yaml b/test/boswatch/test_config.yaml deleted file mode 100644 index abdbd6b..0000000 --- a/test/boswatch/test_config.yaml +++ /dev/null @@ -1,10 +0,0 @@ -types: - string: Hello World - bool: true - integer: 11 - float: 3.14 - -list: - - one - - two - - three \ No newline at end of file diff --git a/test/boswatch/test_configFailed.yaml b/test/boswatch/test_configFailed.yaml deleted file mode 100644 index e113d1e..0000000 --- a/test/boswatch/test_configFailed.yaml +++ /dev/null @@ -1,5 +0,0 @@ -types: - string: Hello World - boolean: true - integer: 11 - float: 3.14 diff --git a/test/test_config.yaml b/test/test_config.yaml new file mode 100644 index 0000000..5a96119 --- /dev/null +++ b/test/test_config.yaml @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# ____ ____ ______ __ __ __ _____ +# / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ / +# / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ < +# / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ / +#/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/ +# German BOS Information Script +# + +# for the test_config +types: + string: Hello World + bool: true + integer: 11 + float: 3.14 + +# for the test_config +list: + - one + - two + - three \ No newline at end of file diff --git a/test/test_configFailed.yaml b/test/test_configFailed.yaml new file mode 100644 index 0000000..579eb77 --- /dev/null +++ b/test/test_configFailed.yaml @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# ____ ____ ______ __ __ __ _____ +# / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ / +# / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ < +# / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ / +#/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/ +# German BOS Information Script +# + +# for the test_config - a config failing while loading +types: + failedIntend: Hello World # this line has false indentation + rightIntend: Hello World +