def test_get_data_fragment_2_fragments(): udp_payload = get_random_bytes(400) fragmented_payload = bytes() f = FragmentGenerator(udp_payload) fragment = f.get_data_fragment() msg_id, is_last, fragment_id, payload = parse_fragment(fragment) fragmented_payload += payload assert msg_id == f.message_id assert not is_last assert fragment_id == 0 fragment = f.get_data_fragment() msg_id, is_last, fragment_id, payload = parse_fragment(fragment) fragmented_payload += payload assert msg_id == f.message_id assert is_last assert fragment_id == 1 assert udp_payload == fragmented_payload
def test_make_dummy_init_fragment(): fragment = make_dummy_init_fragment() msg_id, is_last, fragment_id, payload = parse_fragment(fragment) assert msg_id == 0 assert fragment_id == 0 assert is_last assert payload == bytes()
def test_get_init_fragment(): udp_payload = get_random_bytes(120) f = FragmentGenerator(udp_payload) fragment = f.get_init_fragment() msg_id, is_last, fragment_id, payload = parse_fragment(fragment) assert msg_id == f.message_id assert is_last assert fragment_id == 0 assert udp_payload == payload