Skip to content

Commit

Permalink
Update Python tests to match fixed behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
simu committed Jan 15, 2025
1 parent d064e20 commit 22ae757
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions tests/test_compose_node_name.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
import pytest
import reclass_rs


def test_no_compose_node_name_compat_collision():
config = reclass_rs.Config.from_dict(
inventory_path="./tests/inventory-compose-node-name",
config={"reclass_rs_compat_flags": ["compose-node-name-literal-dots"]},
)
assert config.compatflags == {reclass_rs.CompatFlag.ComposeNodeNameLiteralDots}
with pytest.raises(ValueError) as exc:
r = reclass_rs.Reclass.from_config(config)

assert "Error while discovering nodes: Definition of node '1'" in str(exc)


def test_no_compose_node_name_compat():
r = reclass_rs.Reclass(inventory_path="./tests/inventory-compose-node-name")
r = reclass_rs.Reclass(inventory_path="./tests/inventory-nested-nodes")
r.set_compat_flag(reclass_rs.CompatFlag.ComposeNodeNameLiteralDots)
assert not r.config.compose_node_name
assert r.config.compatflags == {reclass_rs.CompatFlag.ComposeNodeNameLiteralDots}

inv = r.inventory()

assert set(inv.nodes.keys()) == {"a.1", "a", "d"}
assert set(inv.nodes.keys()) == {"a1", "b1", "c1", "d1"}

a1 = inv.nodes["a.1"].parameters["_reclass_"]["name"]
assert a1["full"] == "a.1"
assert a1["parts"] == ["a.1"]
assert a1["path"] == "a.1"
assert a1["short"] == "a.1"
a1 = inv.nodes["a1"].parameters["_reclass_"]["name"]
assert a1["full"] == "a1"
assert a1["parts"] == ["a1"]
assert a1["path"] == "a1"
assert a1["short"] == "a1"


def test_no_compose_node_name():
r = reclass_rs.Reclass(inventory_path="./tests/inventory-compose-node-name")
r = reclass_rs.Reclass(inventory_path="./tests/inventory-nested-nodes")
assert not r.config.compose_node_name
assert r.config.compatflags == set()

inv = r.inventory()

assert set(inv.nodes.keys()) == {"a.1", "a", "d"}
assert set(inv.nodes.keys()) == {"a1", "b1", "c1", "d1"}

a1 = inv.nodes["a.1"].parameters["_reclass_"]["name"]
assert a1["full"] == "a.1"
assert a1["parts"] == ["a.1"]
assert a1["path"] == "a.1"
assert a1["short"] == "a.1"
a1 = inv.nodes["a1"].parameters["_reclass_"]["name"]
assert a1["full"] == "a1"
assert a1["parts"] == ["a1"]
assert a1["path"] == "a1"
assert a1["short"] == "a1"


def test_compose_node_name_compat():
Expand Down

0 comments on commit 22ae757

Please sign in to comment.