Skip to content

Commit 10e92a0

Browse files
authored
Merge pull request #161 from projectsyn/fix/nodeinfo-dict-classes
Add missing `classes` in `NodeInfo::as_dict()`
2 parents a052f7a + 80699ee commit 10e92a0

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/node/nodeinfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl NodeInfo {
180180
let dict = PyDict::new(py);
181181
dict.set_item("__reclass__", self.reclass_as_dict(py)?)?;
182182
dict.set_item("applications", self.applications.clone().into_pyobject(py)?)?;
183-
dict.set_item("applications", self.applications.clone().into_pyobject(py)?)?;
183+
dict.set_item("classes", self.classes.clone().into_pyobject(py)?)?;
184184
dict.set_item(
185185
"environment",
186186
self.reclass.environment.clone().into_pyobject(py)?,

tests/test_nodeinfo.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,28 @@ def test_nodeinfo_n1():
2525
}
2626

2727

28+
def test_nodeinfo_n1_as_dict():
29+
r = reclass_rs.Reclass(inventory_path="./tests/inventory")
30+
n = r.nodeinfo("n1").as_dict()
31+
npath = Path("./tests/inventory/nodes/n1.yml").resolve()
32+
assert n["__reclass__"]["uri"] == f"yaml_fs://{npath}"
33+
assert n["applications"] == ["app1", "app2"]
34+
assert n["classes"] == ["cls1", "cls2"]
35+
assert n["parameters"] == {
36+
"_reclass_": {
37+
"environment": "base",
38+
"name": {
39+
"full": "n1",
40+
"parts": ["n1"],
41+
"path": "n1",
42+
"short": "n1",
43+
},
44+
},
45+
"foo": {"foo": "foo", "bar": "cls2", "baz": "cls1"},
46+
"bar": {"foo": "foo"},
47+
}
48+
49+
2850
def test_nodeinfo_n1_no_invpath():
2951
r = reclass_rs.Reclass(
3052
nodes_path="./tests/inventory/nodes", classes_path="./tests/inventory/classes"

0 commit comments

Comments
 (0)