Add config parser functionality

Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
2022-07-24 21:14:05 +02:00
parent b31b2e199b
commit 8e92bc70a7
9 changed files with 265 additions and 11 deletions

View File

@@ -66,7 +66,7 @@ def test_set_property():
# invalid type
with pytest.raises(ValueError) as exc:
x._set_property("cloner_interval", "č")
assert exc.exconly() == "ValueError: Invalid value for key cloner_interval: type is <class 'str'>"
assert exc.exconly() == "ValueError: Invalid value for key cloner_interval: type is <class 'str'> instead of <class 'int'>, conversion failed"
x._set_property("cloner_project_name", "č")
@@ -74,3 +74,15 @@ def test_set_property():
with pytest.raises(KeyError) as exc:
x._set_property("nonexistent_key", 888)
assert exc.exconly() == "KeyError: 'nonexistent_key is not recognized config option'"
# boolean conversion
x._set_property("cloner_submodules", "1")
assert x.cloner_submodules == True
x._set_property("cloner_submodules", "0")
assert x.cloner_submodules == False
# integer conversion
x._set_property("cloner_interval", 60)
assert x.cloner_interval == 60