some tests for the registers
This commit is contained in:
parent
25c1297a53
commit
4a284d1341
1 changed files with 31 additions and 0 deletions
31
tests/test_regs.py
Normal file
31
tests/test_regs.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
|
||||
from pyfroniusreg import gen24_registers
|
||||
|
||||
from pymodbus.client.tcp import ModbusTcpClient
|
||||
|
||||
fronius1 = ModbusTcpClient("172.19.107.211", port=502, timeout=10)
|
||||
fronius1.connect()
|
||||
|
||||
class TestRead(unittest.TestCase):
|
||||
|
||||
def test_read_scaled(self):
|
||||
soc = gen24_registers.scaledStateOfCharge.getValue(fronius1)
|
||||
assert isinstance(soc, float)
|
||||
|
||||
def test_read_direct(self):
|
||||
dr = gen24_registers.OutWRte.getValue(fronius1)
|
||||
assert isinstance(dr, int)
|
||||
|
||||
def test_write_direct(self):
|
||||
current = gen24_registers.OutWRte.getValue(fronius1)
|
||||
retval = gen24_registers.OutWRte.setValue(fronius1, current)
|
||||
|
||||
def test_write_scaled(self):
|
||||
current = gen24_registers.scaledInWRte.getValue(fronius1)
|
||||
retval = gen24_registers.scaledInWRte.setValue(fronius1, current)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
fronius1.close()
|
Loading…
Reference in a new issue