🚧 WIP
This commit is contained in:
+24
-3
@@ -60,12 +60,33 @@ def test_unknown_top_level_section_rejected(tmp_path: Path) -> None:
|
||||
load_config(p)
|
||||
|
||||
|
||||
def test_empty_tags_rejected(tmp_path: Path) -> None:
|
||||
p = _write(tmp_path, "opc:\n server: X\ntags: []\n")
|
||||
with pytest.raises(ConfigError, match="at least one tag"):
|
||||
def test_both_tags_and_devices_empty_rejected(tmp_path: Path) -> None:
|
||||
"""tags: and devices: are each optional, but their union must not be empty."""
|
||||
p = _write(tmp_path, "opc:\n server: X\ntags: []\ndevices: []\n")
|
||||
with pytest.raises(ConfigError, match="nothing to monitor"):
|
||||
load_config(p)
|
||||
|
||||
|
||||
def test_no_tags_section_with_devices_is_allowed(tmp_path: Path) -> None:
|
||||
"""Devices-only config: link monitoring without extra surveillance tags."""
|
||||
p = _write(
|
||||
tmp_path,
|
||||
"opc:\n server: X\n"
|
||||
"devices:\n - { name: 'Pump A', tag: Ind.Tag }\n",
|
||||
)
|
||||
config = load_config(p)
|
||||
assert config.tags == ()
|
||||
assert [d.name for d in config.devices] == ["Pump A"]
|
||||
|
||||
|
||||
def test_tags_only_still_allowed(tmp_path: Path) -> None:
|
||||
"""The classic setup (no device indicators) stays valid."""
|
||||
p = _write(tmp_path, "opc:\n server: X\ntags:\n - name: t\n")
|
||||
config = load_config(p)
|
||||
assert len(config.tags) == 1
|
||||
assert config.devices == ()
|
||||
|
||||
|
||||
def test_duplicate_tags_rejected(tmp_path: Path) -> None:
|
||||
p = _write(tmp_path, "opc:\n server: X\ntags:\n - name: a\n - name: a\n")
|
||||
with pytest.raises(ConfigError, match="duplicate"):
|
||||
|
||||
Reference in New Issue
Block a user