fix zapisovani casu
This commit is contained in:
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from types import SimpleNamespace
|
||||
|
||||
from services.control_exporter import (
|
||||
DEYE_CLOCK_DRIFT_OK_SEC,
|
||||
@@ -12,6 +13,7 @@ from services.control_exporter import (
|
||||
InverterConfig,
|
||||
PRAGUE_TZ,
|
||||
_deye_clock_registers_verify_match,
|
||||
_deye_expected_clock_triplet_for_verify,
|
||||
_deye_registers_to_prague_datetime,
|
||||
_deye_should_skip_time_sync_after_read,
|
||||
_deye_system_time_register_rows,
|
||||
@@ -121,5 +123,23 @@ class DeyeSkipTimeSyncPolicyTests(unittest.TestCase):
|
||||
self.assertGreater(DEYE_CLOCK_DRIFT_OK_SEC, 5)
|
||||
|
||||
|
||||
class DeyeClockTripletForVerifyTests(unittest.TestCase):
|
||||
def test_orphan_reg64_fills_w62_w63_from_device_read(self) -> None:
|
||||
a62 = (2026 - 2000) << 8 | 4
|
||||
a63 = 10 << 8 | 12
|
||||
a64 = 45 << 8 | 30
|
||||
bundle = [SimpleNamespace(register=64, value_to_write=(45 << 8) | 0)]
|
||||
w62, w63, w64 = _deye_expected_clock_triplet_for_verify(bundle, {}, a62, a63, a64)
|
||||
self.assertEqual(w62, a62)
|
||||
self.assertEqual(w63, a63)
|
||||
self.assertEqual(w64, 45 << 8)
|
||||
|
||||
def test_last_verified_used_when_not_in_bundle(self) -> None:
|
||||
bundle: list[SimpleNamespace] = []
|
||||
last = {62: 1, 63: 2, 64: 3}
|
||||
w62, w63, w64 = _deye_expected_clock_triplet_for_verify(bundle, last, 9, 8, 7)
|
||||
self.assertEqual((w62, w63, w64), (1, 2, 3))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user