add some config tests

This commit is contained in:
Bastian Schroll 2019-10-21 10:28:46 +02:00
parent 0e587e7698
commit 40e0a951da
3 changed files with 37 additions and 31 deletions

View file

@ -1,29 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""!
____ ____ ______ __ __ __ _____
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
/ /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ /
/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/
German BOS Information Script
by Bastian Schroll
@file: watchdog.py
@date: ##.##.2018
@author: Bastian Schroll
@description: Watchdog to _check if BOSWatch client, server, rtl_fm or multimon-ng is still running
"""
import logging
logging.debug("- %s loaded", __name__)
class Watchdog:
"""!Class for an Watchdog to observe,
if needed subprocess still running"""
def __init__(self):
"""!Create a new instance"""
pass

View file

@ -56,6 +56,12 @@ def test_loadConfigFileNotFound(getConfig):
assert getConfig.loadConfigFile(paths.TEST_PATH + "test_configNotFound.yaml") is False
def test_getConfigAsString(getFilledConfig):
"""!Get the string representation of the config"""
assert type(str(getFilledConfig)) is str
logging.debug(getFilledConfig)
def test_getTypes(getFilledConfig):
"""!Get and check different data types in config"""
assert type(getFilledConfig.get("types")) is ConfigYAML
@ -65,6 +71,11 @@ def test_getTypes(getFilledConfig):
assert type(getFilledConfig.get("types", "float")) is float
def test_getDefaultValue(getFilledConfig):
"""!Get the default value of an not existent entry"""
assert getFilledConfig.get("notExistent", default="defaultValue") == "defaultValue"
def test_getNestedConfig(getFilledConfig):
"""!Work with nested sub-config elements"""
nestedConfig = getFilledConfig.get("types")
@ -78,4 +89,17 @@ def test_configIterationList(getFilledConfig):
for item in getFilledConfig.get("list"):
assert type(item) is str
counter += 1
assert counter == 3
assert counter is 3
def test_configIterationListWithNestedList(getFilledConfig):
"""!Try to iterate over a list in the config where its elements are lists itself"""
listCnt = 0
strCnt = 0
for item in getFilledConfig.get("list1"):
if type(item) is ConfigYAML:
listCnt += 1
if type(item) is str:
strCnt += 1
assert listCnt == 2
assert strCnt == 1

View file

@ -18,4 +18,15 @@ types:
list:
- one
- two
- three
- three
list1:
- list11:
- one
- two
- three
- list12:
- one
- two
- three
- string1