mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-04-04 13:57:44 +00:00
add some config tests
This commit is contained in:
parent
0e587e7698
commit
40e0a951da
3 changed files with 37 additions and 31 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -18,4 +18,15 @@ types:
|
|||
list:
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
- three
|
||||
|
||||
list1:
|
||||
- list11:
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
- list12:
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
- string1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue