Skip to content

Commit

Permalink
Add test for SdoArray length and iteration count.
Browse files Browse the repository at this point in the history
  • Loading branch information
acolomb committed Aug 17, 2024
1 parent daf8ca6 commit 5cbb00e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/test_sdo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ def setUp(self):
node = canopen.LocalNode(1, SAMPLE_EDS)
self.sdo_node = node.sdo

def test_array_iter_length(self):
"""Assume the "highest subindex supported" entry is not counted."""
array = self.sdo_node[0x1003]
subs = sum(1 for _ in iter(array))
self.assertEqual(len(array), 3)
self.assertEqual(subs, 3)
# Simulate more entries getting added dynamically
array[0].set_data(b'\x08')
subs = sum(1 for _ in iter(array))
self.assertEqual(subs, 8)

def test_array_members_dynamic(self):
"""Check if sub-objects missing from OD entry are generated dynamically."""
array = self.sdo_node[0x1003]
Expand Down

0 comments on commit 5cbb00e

Please sign in to comment.