Skip to content

Commit

Permalink
simpler and more robust ModbusRequest test
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshilliard authored and alexrudd2 committed Jul 20, 2024
1 parent bade40c commit 8eb06fa
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions test/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,33 +186,20 @@ def test_transaction_manager_tid(self):

def test_get_transaction_manager_transaction(self):
"""Test the getting a transaction from the transaction manager."""

class Request: # pylint: disable=too-few-public-methods
"""Request."""

self._manager.reset()
handle = Request()
handle.transaction_id = ( # pylint: disable=attribute-defined-outside-init
self._manager.getNextTID()
handle = ModbusRequest(
0, self._manager.getNextTID(), 0, False
)
handle.message = b"testing" # pylint: disable=attribute-defined-outside-init
self._manager.addTransaction(handle)
result = self._manager.getTransaction(handle.transaction_id)
assert handle.message == result.message
assert handle is result

def test_delete_transaction_manager_transaction(self):
"""Test deleting a transaction from the dict transaction manager."""

class Request: # pylint: disable=too-few-public-methods
"""Request."""

self._manager.reset()
handle = Request()
handle.transaction_id = ( # pylint: disable=attribute-defined-outside-init
self._manager.getNextTID()
handle = ModbusRequest(
0, self._manager.getNextTID(), 0, False
)
handle.message = b"testing" # pylint: disable=attribute-defined-outside-init

self._manager.addTransaction(handle)
self._manager.delTransaction(handle.transaction_id)
assert not self._manager.getTransaction(handle.transaction_id)
Expand Down

0 comments on commit 8eb06fa

Please sign in to comment.