|
|
|
@ -1,6 +1,7 @@
|
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
from copy import deepcopy
|
|
|
|
from copy import deepcopy
|
|
|
|
import pytest
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
import preserve
|
|
|
|
import configspec
|
|
|
|
import configspec
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -63,6 +64,38 @@ def example_values():
|
|
|
|
return vals
|
|
|
|
return vals
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_addspec(example_spec):
|
|
|
|
|
|
|
|
confspec = configspec.ConfigSpecification()
|
|
|
|
|
|
|
|
confspec.add_specs([
|
|
|
|
|
|
|
|
("bool_a", configspec.BoolSpec(False, False, "Bool A")),
|
|
|
|
|
|
|
|
("boollist_a", configspec.BoolListSpec(False, False, "Bool A")),
|
|
|
|
|
|
|
|
("int_a", configspec.IntSpec(0, -4, 4, False, "Int A")),
|
|
|
|
|
|
|
|
("intlist_a", configspec.IntListSpec(0, -4, 4, False, "Int A")),
|
|
|
|
|
|
|
|
("string_a", configspec.StringSpec("ThisIsAString", 4, 15, False, "String A")),
|
|
|
|
|
|
|
|
("stringlist_a", configspec.StringListSpec("ThisIsAString", 4, 15, False, "String A"))
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
confdictspec = confspec.add_spec("dict_a", configspec.DictSpec(None, False, "Dict A"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
confdictspec.add_specs([
|
|
|
|
|
|
|
|
("bool_b", configspec.BoolSpec(False, False, "Bool B")),
|
|
|
|
|
|
|
|
("int_b", configspec.IntSpec(0, -4, 4, False, "Int B")),
|
|
|
|
|
|
|
|
("string_b", configspec.StringSpec("ThisIsAString", 4, 15, False, "String B"))
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
confdictlist = confspec.add_spec("dictlist_a",
|
|
|
|
|
|
|
|
configspec.DictListSpec(None, False, "List of Dicts B"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
confdictlist.add_specs([
|
|
|
|
|
|
|
|
("bool_c", configspec.BoolSpec(False, False, "Bool C")),
|
|
|
|
|
|
|
|
("int_c", configspec.IntSpec(0, -4, 4, False, "Int C")),
|
|
|
|
|
|
|
|
("string_c", configspec.StringSpec("ThisIsAString", 4, 15, False, "String C"))
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Preserve to be able to directly compare resulting confspec structure
|
|
|
|
|
|
|
|
assert preserve.preserve(example_spec) == preserve.preserve(confspec)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_config_validate(example_spec, example_values):
|
|
|
|
def test_config_validate(example_spec, example_values):
|
|
|
|
spec = example_spec
|
|
|
|
spec = example_spec
|
|
|
|
spec.validate(example_values)
|
|
|
|
spec.validate(example_values)
|
|
|
|
|