Skip to content

Commit 6d681b3

Browse files
committed
added unit tests
1 parent 9872691 commit 6d681b3

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

tests/rsocket/test_frame.py

+24-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
MetadataPushFrame, PayloadFrame, LeaseFrame, ResumeOKFrame, KeepAliveFrame,
1212
serialize_with_frame_size_header, RequestStreamFrame, RequestChannelFrame, ParseError,
1313
parse_or_ignore, Frame, RequestFireAndForgetFrame, serialize_prefix_with_frame_size_header,
14-
parse_header_native, Header)
14+
parse_header_native, Header, is_frame_to_ignore, is_fragmentable_frame, new_frame_fragment)
1515
from rsocket.frame_parser import FrameParser
1616
from tests.rsocket.helpers import data_bits, build_frame, bits
1717

@@ -23,7 +23,6 @@
2323
(1, 0, 1)
2424
))
2525
def test_parse_header_native(follows, complete, is_next):
26-
2726
data = build_frame(
2827
bits(24, 28, 'Frame size'),
2928
bits(1, 0, 'Padding'),
@@ -51,6 +50,7 @@ def test_parse_header_native(follows, complete, is_next):
5150
assert flags.flags_complete_lease == complete
5251
assert flags.flags_next == is_next
5352

53+
5454
@pytest.mark.parametrize('metadata_flag, metadata, lease, frame_data', (
5555
(0, b'', 0, b'\x01\x02\x03'),
5656
(1, b'\x04\x05\x06\x07\x08', 1, b'\x01\x02\x03'),
@@ -801,3 +801,25 @@ def test_equality():
801801
async def parse_frame(data: bytes, frame_parser: FrameParser) -> Frame:
802802
frames = await asyncstdlib.builtins.list(frame_parser.receive_data(data))
803803
return frames[0]
804+
805+
806+
def test_is_frame_to_ignore():
807+
frame = RequestResponseFrame()
808+
frame.stream_id = 1
809+
frame.flags_ignore = True
810+
811+
assert not is_frame_to_ignore(frame)
812+
813+
814+
@pytest.mark.allow_error_log(regex_filter='Invalid metadata frame')
815+
def test_is_frame_to_ignore_invalid_metadata_push():
816+
ignored_frame = MetadataPushFrame()
817+
ignored_frame.stream_id = 1
818+
819+
assert is_frame_to_ignore(ignored_frame)
820+
821+
822+
def test_is_fragmentable_frame():
823+
frame = PayloadFrame()
824+
825+
assert is_fragmentable_frame(frame)

0 commit comments

Comments
 (0)