From 6769518f672e8ff8f2f83456f438fc979d344347 Mon Sep 17 00:00:00 2001 From: Paul Warren Date: Sat, 26 Oct 2024 16:00:49 +1100 Subject: [PATCH] some more tests --- tests/test_regs.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/test_regs.py b/tests/test_regs.py index 36973d4..3734050 100644 --- a/tests/test_regs.py +++ b/tests/test_regs.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 import unittest -from pyfroniusreg import gen24_registers +from pyfroniusreg import gen24_primo_symo_inverter_register_map_float_storage as gen24_registers +from pyfroniusreg import smart_meter_register_map_float as smart_meter from pymodbus.client.tcp import ModbusTcpClient @@ -9,7 +10,7 @@ fronius1 = ModbusTcpClient("172.19.107.211", port=502, timeout=10) fronius1.connect() -class TestRead(unittest.TestCase): +class TestReadRegs(unittest.TestCase): def test_read_scaled(self): soc = gen24_registers.scaledChaState.get(fronius1) assert isinstance(soc, float) @@ -35,7 +36,7 @@ class TestRead(unittest.TestCase): # This doesn't seem to return anything useful # SN = gen24_registers.SN.get(fronius1) # assert SN == "12345567" - +class testWriteRegs(unittest.TestCase): def test_write_direct(self): current = gen24_registers.OutWRte.get(fronius1) retval = gen24_registers.OutWRte.set(fronius1, current) @@ -46,7 +47,16 @@ class TestRead(unittest.TestCase): retval = gen24_registers.scaledInWRte.set(fronius1, current) assert retval is not None +class testSmartMeter(unittest.TestCase): + def test_freq_read(self): + Hz = smart_meter.Hz.get(fronius1) + print(Hz) + assert isinstance(Hz, float) + def test_import_read(self): + wh_import = smart_meter.TotWhImp.get(fronius1) + assert isinstance(wh_import, float) + if __name__ == "__main__": unittest.main() fronius1.close()