mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-10-10 00:16:39 +00:00
docs(measurement): describe household settings and consolidate regression coverage
This commit is contained in:
@@ -91,7 +91,10 @@ class MeasurementCommonSettings(SettingsBaseModel):
|
||||
},
|
||||
)
|
||||
|
||||
household: Optional[HouseholdSettings] = None
|
||||
household: Optional[HouseholdSettings] = Field(
|
||||
default=None,
|
||||
json_schema_extra={"description": "Optional household energy balance definition.", "examples": [None]},
|
||||
)
|
||||
energy_context_seconds: int = Field(default=86400, gt=0, le=604800, strict=True)
|
||||
|
||||
@model_validator(mode="after")
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
"""Verify fallback JSON loading does not lose records through the singleton."""
|
||||
from unittest.mock import AsyncMock
|
||||
import pytest
|
||||
from akkudoktoreos.core.coreabc import get_measurement
|
||||
from akkudoktoreos.core.dataabc import DataSequence
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_measurement_json_roundtrip(config_eos, tmp_path, monkeypatch):
|
||||
m = get_measurement()
|
||||
config_eos.measurement.load_emr_keys = ["meter"]
|
||||
config_eos.general.data_folder_path = tmp_path
|
||||
config_eos.database.provider = None
|
||||
m._db_reset_state()
|
||||
try:
|
||||
await m.update_value("2026-09-16T08:00:00Z", "meter", 123.5)
|
||||
monkeypatch.setattr(DataSequence, "save", AsyncMock(return_value=False))
|
||||
monkeypatch.setattr(DataSequence, "load", AsyncMock(return_value=False))
|
||||
assert await m.save()
|
||||
m._db_reset_state()
|
||||
assert await m.load()
|
||||
assert len(m.records) == 1
|
||||
assert m.records[0]["meter"] == 123.5
|
||||
finally:
|
||||
m._db_reset_state()
|
||||
Reference in New Issue
Block a user