Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test SparseDataStore. #1532

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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