solved duplicate points error

This commit is contained in:
2026-08-30 13:38:55 +02:00
parent 4c216abb1f
commit 67d8b50333
3 changed files with 33 additions and 6 deletions
+14
View File
@@ -1,3 +1,4 @@
from netatmo_service.data import Sample
from netatmo_service.rrd import RRDStore
@@ -5,3 +6,16 @@ def test_rrd_files_have_netatmo_prefix(tmp_path):
store = RRDStore(tmp_path)
assert store.path("outdoor") == tmp_path / "netatmo_outdoor.rrd"
assert store.path("wind") == tmp_path / "netatmo_wind.rrd"
def test_rrd_is_updated_only_once_per_collection_interval(tmp_path):
store = RRDStore(tmp_path)
store.ensure_all()
now = int(__import__("time").time())
timestamp = ((now // 600) - 1) * 600 + 100
first = Sample(timestamp, {"temperature": 20, "co2": 500, "humidity": 50})
same_interval = Sample(timestamp + 1, {"temperature": 21, "co2": 510, "humidity": 51})
assert store.update("study", first) is True
assert store.update("study", first) is False
assert store.update("study", same_interval) is False