Files
shelly-ui/tests/test_json_path.py
jonas 71803418e5 Initial commit: Shelly Manager with Textual CLI, Streamlit UI, and comprehensive .gitignore
Shelly device management app with mDNS/subnet discovery, inventory,
configuration, and mass operations for Gen1/Gen2+ devices.

Includes .gitignore excluding runtime data (device DB, user config),
AI conversation history, build artifacts, and common Python/OS patterns.
2026-03-23 21:51:59 +01:00

30 lines
838 B
Python

"""json_path helper tests."""
from __future__ import annotations
from shelly_manager.core.json_path import get_json_path, is_missing
def test_get_json_path_nested() -> None:
d = {"ble": {"enable": True, "rpc": {"enable": False}}}
assert get_json_path(d, "ble.enable") is True
assert get_json_path(d, "ble.rpc.enable") is False
def test_get_json_path_missing() -> None:
assert is_missing(get_json_path({}, "ble.enable"))
def test_get_json_path_empty() -> None:
assert is_missing(get_json_path(None, "a")) # type: ignore[arg-type]
def test_get_json_path_pipe_segment() -> None:
d = {"switch:0": {"output": True}}
assert get_json_path(d, "switch:0|output") is True
def test_get_json_path_list_index() -> None:
d = {"relays": [{"ison": True}]}
assert get_json_path(d, "relays.0.ison") is True