mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2025-12-06 07:12:04 +01:00
fix test config file location and paths
This commit is contained in:
parent
2ca62d90f2
commit
4b69b08028
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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/"
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
types:
|
||||
string: Hello World
|
||||
bool: true
|
||||
integer: 11
|
||||
float: 3.14
|
||||
|
||||
list:
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
types:
|
||||
string: Hello World
|
||||
boolean: true
|
||||
integer: 11
|
||||
float: 3.14
|
||||
21
test/test_config.yaml
Normal file
21
test/test_config.yaml
Normal file
|
|
@ -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
|
||||
14
test/test_configFailed.yaml
Normal file
14
test/test_configFailed.yaml
Normal file
|
|
@ -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
|
||||
|
||||
Loading…
Reference in a new issue