Skip to content

Commit

Permalink
Exercise the new getters in the Python tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simu committed Jan 27, 2024
1 parent 59cadfb commit 3fe6c9d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def test_import_new():
assert pathlib.Path(r.config.classes_path) == invpath / "classes"
assert r.config.ignore_class_notfound

assert r.nodes is not None
assert r.classes is not None


def test_import_raises():
with pytest.raises(ValueError) as exc:
Expand Down
20 changes: 20 additions & 0 deletions tests/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ def test_inventory():
inventory_path="./tests/inventory",
ignore_class_notfound=True,
)
assert set(r.nodes.keys()) == expected_nodes
included_classes = set(expected_classes.keys())
all_classes = set(r.classes.keys())
# discovered classes which aren't shown with their resolved names in the output:
assert all_classes - included_classes == {
"${baz}", # appears as `\\${baz}`
"cluster.foo", # appears as `cluster.${dist}`
"config_symlink", # doesn't appear
"foo.bar", # appears as `${tenant}.${cluster}`
}
# class includes which aren't shown in their resolved form:
assert included_classes - all_classes == {
"${cls9}", # resolved as `cls9` for n15
"${qux}", # resolved as `cls1` for n4
"${tenant}.${cluster}", # resolved as `foo.bar` for n16
"\\${baz}", # resolved as `${baz}` for n17
"cluster.${dist}", # resolved as `cluster.foo` for n19
"nonexisting", # skipped because ignore_class_notfound=True
}

inv = r.inventory()

assert set(inv.nodes.keys()) == expected_nodes
Expand Down

0 comments on commit 3fe6c9d

Please sign in to comment.