Skip to content

Commit

Permalink
test SparseDataStore. (#1532)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored Apr 27, 2023
1 parent d8f2675 commit 92cc53a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/test_sparse_datastore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Test framers."""


from pymodbus.datastore import ModbusSparseDataBlock


def test_check_sparsedatastore():
"""Test check frame."""
data_in_block = {
1: 6720,
2: 130,
30: [0x0D, 0xFE],
105: [1, 2, 3, 4],
20000: [45, 241, 48],
20008: 38,
48140: [0x4208, 0xCCCD],
}
datablock = ModbusSparseDataBlock(data_in_block)
for key, entry in data_in_block.items():
if isinstance(entry, int):
entry = [entry]
for value in entry:
assert datablock.validate(key, 1)
assert datablock.getValues(key, 1) == [value]
key += 1

0 comments on commit 92cc53a

Please sign in to comment.