Skip to content

Commit

Permalink
issue #17: frame: Add unit test for SABME decode
Browse files Browse the repository at this point in the history
  • Loading branch information
sjlongland committed Apr 16, 2023
1 parent 5e1ea27 commit 2f6d0b2
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion tests/test_frame/test_uframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from aioax25.frame import AX25Frame, \
AX25UnnumberedInformationFrame, AX25FrameRejectFrame, \
AX25UnnumberedFrame, AX25DisconnectModeFrame, \
AX25SetAsyncBalancedModeFrame, AX25TestFrame
AX25SetAsyncBalancedModeFrame, \
AX25SetAsyncBalancedModeExtendedFrame, AX25TestFrame

from ..nosecompat import eq_
from ..hex import from_hex, hex_cmp
Expand Down Expand Up @@ -57,6 +58,37 @@ def test_decode_sabm_payload():
except ValueError as e:
eq_(str(e), 'Frame does not support payload')

def test_decode_sabme():
"""
Test that a SABME frame is recognised and decoded.
"""
frame = AX25Frame.decode(
from_hex(
'ac 96 68 84 ae 92 e0' # Destination
'ac 96 68 9a a6 98 61' # Source
'6f' # Control byte
)
)
assert isinstance(frame, AX25SetAsyncBalancedModeExtendedFrame), \
'Did not decode to SABME frame'

def test_decode_sabme_payload():
"""
Test that a SABME frame forbids payload.
"""
try:
AX25Frame.decode(
from_hex(
'ac 96 68 84 ae 92 e0' # Destination
'ac 96 68 9a a6 98 61' # Source
'6f' # Control byte
'11 22 33 44 55' # Payload
)
)
assert False, 'This should not have worked'
except ValueError as e:
eq_(str(e), 'Frame does not support payload')

def test_decode_uframe_payload():
"""
Test that U-frames other than FRMR and UI are forbidden to have payloads.
Expand Down

0 comments on commit 2f6d0b2

Please sign in to comment.