Skip to content

Commit

Permalink
Final.
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen committed Oct 10, 2024
1 parent 0160f5e commit d8a19fe
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions test/framers/test_multidrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

import pytest

from pymodbus.framer import FramerRTU
from pymodbus.framer import FramerRTU, FramerAscii
from pymodbus.server.async_io import ServerDecoder
from pymodbus.exceptions import ModbusIOException


class TestMultidrop:
Expand Down Expand Up @@ -100,7 +101,7 @@ def test_split_frame_trailing_data_with_id(self, framer, callback):
b"\x02\x10\x07",
b"\x02\x10\x07\x10",
])
def test_coincidental_1(self, garbage, framer, callback):
def test_coincidental(self, garbage, framer, callback):
"""Test conincidental."""
serial_events = [garbage, self.good_frame[:5], self.good_frame[5:]]
for serial_event in serial_events:
Expand Down Expand Up @@ -128,6 +129,31 @@ def test_frame_with_trailing_data(self, framer, callback):
# We should not respond in this case for identical reasons as test_wrapped_frame
callback.assert_called_once()

def test_wrong_dev_id(self, callback):
"""Test conincidental."""
framer = FramerAscii(ServerDecoder(), [87])
framer.processIncomingPacket(b':0003007C00027F\r\n', callback)
callback.assert_not_called()

def test_wrong_tid(self, callback):
"""Test conincidental."""
framer = FramerAscii(ServerDecoder(), [])
framer.processIncomingPacket(b':1103007C00026E\r\n', callback, tid=117)
callback.assert_not_called()

def test_wrong_class(self, callback):
"""Test conincidental."""

def return_none(_data):
"""Return none."""
return None

framer = FramerAscii(ServerDecoder(), [])
framer.decoder.decode = return_none
with pytest.raises(ModbusIOException):
framer.processIncomingPacket(b':1103007C00026E\r\n', callback)
callback.assert_not_called()

@pytest.mark.skip
def test_getFrameStart(self, framer): # pragma: no cover
"""Test getFrameStart."""
Expand Down

0 comments on commit d8a19fe

Please sign in to comment.