🚧 WIP
This commit is contained in:
+35
-2
@@ -480,13 +480,32 @@ class TestChannelRanges:
|
||||
assert ai["range"] == {"min": 0, "max": 32000}
|
||||
assert app.node.channel_ranges["AO0.0"] == (400, 2000)
|
||||
|
||||
async def test_default_range_dropped_from_store(self, client, app):
|
||||
async def test_default_range_kept_in_dense_store(self, client, app):
|
||||
# the store is DENSE (FR-10.2.14): a default-equal entry is
|
||||
# materialized like any other — no sparse-override dropping
|
||||
r = await client.put("/api/config/channel-ranges", json={
|
||||
"channel_ranges": {"AI0.0": {"min": 0, "max": 4095}}, # == default
|
||||
"persist": False,
|
||||
})
|
||||
assert r.status_code == 200
|
||||
assert app.node.channel_ranges == {} # kept clean
|
||||
assert app.node.channel_ranges["AI0.0"] == (0, 4095)
|
||||
# every analog channel of the layout is present
|
||||
analog = {c for c in app.node.channel_ranges}
|
||||
assert {"AI0.0", "AI0.1", "AO0.0", "AO0.1"} <= analog
|
||||
# and digital codes never are
|
||||
assert not any(c.startswith(("DI", "DO")) for c in analog)
|
||||
|
||||
async def test_dense_store_pruned_on_module_save(self, client, app, tmp_path):
|
||||
app.node_config_path = str(tmp_path / "node.yaml")
|
||||
await client.put("/api/config/channel-ranges", json={
|
||||
"channel_ranges": {"AI0.0": {"min": 0, "max": 32000}}, "persist": False,
|
||||
})
|
||||
r = await client.put("/api/config/modules", json={
|
||||
"modules": ["750-430", "750-530"], "persist": False,
|
||||
})
|
||||
assert r.status_code == 200
|
||||
# no analog modules left -> the range store is empty (pruned)
|
||||
assert app.node.channel_ranges == {}
|
||||
|
||||
async def test_range_validation(self, client):
|
||||
base = {"persist": False}
|
||||
@@ -569,6 +588,20 @@ class TestChannelRanges:
|
||||
ranges = load_channel_ranges(load_yaml(cfg_file))
|
||||
assert ranges == {"AI0.0": (0, 32000)}
|
||||
|
||||
async def test_ranges_yaml_lean_defaults(self, client, app, tmp_path):
|
||||
# dense store, lean YAML: default-equal entries are NOT written
|
||||
cfg_file = tmp_path / "node.yaml"
|
||||
app.node_config_path = str(cfg_file)
|
||||
r = await client.put("/api/config/channel-ranges", json={
|
||||
"channel_ranges": {"AI0.0": {"min": 0, "max": 4095},
|
||||
"AO0.0": {"min": 0, "max": 32000}},
|
||||
"persist": True,
|
||||
})
|
||||
assert r.status_code == 200
|
||||
text = cfg_file.read_text(encoding="utf-8")
|
||||
assert "AO0.0" in text and "AI0.0" not in text
|
||||
assert app.node.channel_ranges["AI0.0"] == (0, 4095) # store dense
|
||||
|
||||
async def test_ranges_survive_module_save(self, client, app, tmp_path):
|
||||
app.node_config_path = str(tmp_path / "node.yaml")
|
||||
await client.put("/api/config/channel-ranges", json={
|
||||
|
||||
Reference in New Issue
Block a user