-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Python test cases for
Config.from_dict()
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import reclass_rs | ||
import pytest | ||
|
||
|
||
def test_config_from_dict(): | ||
config_options = { | ||
"nodes_uri": "targets", | ||
"classes_uri": "classes", | ||
"ignore_class_notfound": False, | ||
"compose_node_name": False, | ||
} | ||
c = reclass_rs.Config.from_dict("./tests/inventory", config_options) | ||
assert c is not None | ||
|
||
assert not c.ignore_class_notfound | ||
assert not c.compose_node_name | ||
|
||
expected_nodes_path = pathlib.Path("./tests/inventory/targets") | ||
expected_classes_path = pathlib.Path("./tests/inventory/classes") | ||
assert pathlib.Path(c.nodes_path) == expected_nodes_path | ||
assert pathlib.Path(c.classes_path) == expected_classes_path | ||
|
||
|
||
def test_config_from_dict_non_default(): | ||
config_options = { | ||
"nodes_uri": "targets", | ||
"classes_uri": "classes", | ||
"ignore_class_notfound": True, | ||
"ignore_class_notfound_regexp": ["foo", "bar"], | ||
"compose_node_name": True, | ||
} | ||
c = reclass_rs.Config.from_dict("./tests/inventory", config_options) | ||
assert c is not None | ||
|
||
assert c.ignore_class_notfound | ||
assert c.compose_node_name | ||
|
||
expected_nodes_path = pathlib.Path("./tests/inventory/targets") | ||
expected_classes_path = pathlib.Path("./tests/inventory/classes") | ||
assert pathlib.Path(c.nodes_path) == expected_nodes_path | ||
assert pathlib.Path(c.classes_path) == expected_classes_path | ||
|
||
assert c.ignore_class_notfound_regexp == ["foo", "bar"] |