Release v3.0.0
- Bump version to 3.0.0 and update docs - Fix Debian payload to include TUI and install /usr/bin/sensorpajen-tui wrapper - Make systemd unit upgrades safer and ignore deb build artifacts
This commit is contained in:
@@ -34,6 +34,35 @@ def test_sensor_config_load(tmp_path):
|
||||
assert sensor_cfg.get_name("AA:BB:CC:DD:EE:FF") == "Living Room"
|
||||
assert sensor_cfg.get_name("UNKNOWN") == "UNKNOWN"
|
||||
|
||||
|
||||
def test_sensor_config_comment_load_and_clear(tmp_path):
|
||||
import json
|
||||
import sensorpajen.config as config
|
||||
|
||||
config_file = tmp_path / "sensors.json"
|
||||
config_file.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"sensors": [
|
||||
{"mac": "AA:BB:CC:DD:EE:FF", "name": "Living Room", "comment": "hello"},
|
||||
]
|
||||
},
|
||||
indent=2,
|
||||
)
|
||||
)
|
||||
|
||||
sensor_cfg = config.SensorConfig(config_file=str(config_file))
|
||||
assert sensor_cfg.get_comment("AA:BB:CC:DD:EE:FF") == "hello"
|
||||
|
||||
# Clear comment explicitly (empty string means remove comment key)
|
||||
sensor_cfg.add_sensor("AA:BB:CC:DD:EE:FF", "Living Room", "")
|
||||
assert sensor_cfg.get_comment("AA:BB:CC:DD:EE:FF") is None
|
||||
|
||||
saved = json.loads(config_file.read_text())
|
||||
assert saved["sensors"][0]["mac"] == "AA:BB:CC:DD:EE:FF"
|
||||
assert saved["sensors"][0]["name"] == "Living Room"
|
||||
assert "comment" not in saved["sensors"][0]
|
||||
|
||||
def test_sensor_config_add_remove(tmp_path):
|
||||
import sensorpajen.config as config
|
||||
config_file = tmp_path / "sensors.json"
|
||||
@@ -47,10 +76,12 @@ def test_sensor_config_add_remove(tmp_path):
|
||||
# Add
|
||||
sensor_cfg.add_sensor("AA:BB:CC:DD:EE:FF", "Living Room", "Test comment")
|
||||
assert sensor_cfg.sensors["AA:BB:CC:DD:EE:FF"] == "Living Room"
|
||||
assert sensor_cfg.get_comment("AA:BB:CC:DD:EE:FF") == "Test comment"
|
||||
|
||||
# Verify persistence
|
||||
sensor_cfg2 = config.SensorConfig(config_file=str(config_file))
|
||||
assert sensor_cfg2.sensors["AA:BB:CC:DD:EE:FF"] == "Living Room"
|
||||
assert sensor_cfg2.get_comment("AA:BB:CC:DD:EE:FF") == "Test comment"
|
||||
|
||||
# Remove
|
||||
sensor_cfg.remove_sensor("AA:BB:CC:DD:EE:FF")
|
||||
|
||||
Reference in New Issue
Block a user