Skip to content

Commit

Permalink
Fix: Reading QUEUE-LENGTH in QueuedReceiverComSpec triggers exception
Browse files Browse the repository at this point in the history
  • Loading branch information
cogu committed Mar 31, 2024
1 parent 055442b commit a5b0213
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ The first name in a bullet point below is the Python class name while the second
Elements marked as `collectable` means that they can be added directly to a package.
Non-collectable elements are various sub-elements to collectable elements.

## [Unreleased]

### Fixed

* Fixed bug in Reader class for property `QUEUED-RECEIVER-COM-SPEC/QUEUE-LENGTH`

## [v0.5.3] - 2024-03-29

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/autosar/xml/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3701,7 +3701,7 @@ def _read_queued_receiver_com_spec(self, xml_element: ElementTree.Element) -> ar
self._read_receiver_com_spec(child_elements, data)
xml_child = child_elements.get("QUEUE-LENGTH")
if xml_child is not None:
data["operation_ref"] = ar_element.PositiveIntegerValue(xml_child.text).value
data["queue_length"] = ar_element.PositiveIntegerValue(xml_child.text).value
self._report_unprocessed_elements(child_elements)
return ar_element.QueuedReceiverComSpec(**data)

Expand Down
12 changes: 12 additions & 0 deletions tests/xml/test_software_component_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,18 @@ def test_uses_end_to_end_protection(self):
self.assertIsInstance(elem, ar_element.QueuedReceiverComSpec)
self.assertFalse(elem.uses_end_to_end_protection)

def test_queue_length(self):
element = ar_element.QueuedReceiverComSpec(queue_length=1)
writer = autosar.xml.Writer()
xml = '''<QUEUED-RECEIVER-COM-SPEC>
<QUEUE-LENGTH>1</QUEUE-LENGTH>
</QUEUED-RECEIVER-COM-SPEC>'''
self.assertEqual(writer.write_str_elem(element), xml)
reader = autosar.xml.Reader()
elem: ar_element.QueuedReceiverComSpec = reader.read_str_elem(xml)
self.assertIsInstance(elem, ar_element.QueuedReceiverComSpec)
self.assertEqual(elem.queue_length, 1)


class TestNonqueuedReceiverComSpec(unittest.TestCase):

Expand Down

0 comments on commit a5b0213

Please sign in to comment.