MCPcopy
hub / github.com/kovidgoyal/kitty / test_large_data_chunking

Method test_large_data_chunking

kitty_tests/dnd.py:556–574  ·  view source on GitHub ↗

Data larger than the chunk limit is sent in multiple base64 chunks.

(self)

Source from the content-addressed store, hash-verified

554 self.ae(events[0]['payload'].strip().partition(b':')[0], b'EPERM')
555
556 def test_large_data_chunking(self) -> None:
557 """Data larger than the chunk limit is sent in multiple base64 chunks."""
558 # Each chunk is ≤ 3072 bytes of raw data (base64-encoded to ≤ 4096 bytes).
559 chunk_limit = 3072
560 big_payload = b'X' * (chunk_limit * 3) # 3 chunks expected
561 with dnd_test_window() as (screen, cap):
562 self._register_for_drops(screen, cap, 'text/plain')
563 dnd_test_set_mouse_pos(cap.window_id, 0, 0, 0, 0)
564 dnd_test_fake_drop_event(cap.window_id, True, ['text/plain'])
565 cap.consume()
566
567 parse_bytes(screen, client_request_data(1))
568 dnd_test_fake_drop_data(cap.window_id, 'text/plain', big_payload)
569 raw = cap.consume()
570 data_events = parse_escape_codes_b64(raw)
571 combined = b''.join(e['payload'] for e in data_events if e['type'] == 'r')
572 self.ae(combined, big_payload)
573 # Verify that we got more than one escape code (chunking happened)
574 self.assertGreater(len(data_events), 1, 'expected multiple chunks')
575
576 def test_client_id_propagated(self) -> None:
577 """The client_id (i=…) set during registration is echoed in all replies."""

Callers

nothing calls this directly

Calls 6

_register_for_dropsMethod · 0.95
dnd_test_windowFunction · 0.85
client_request_dataFunction · 0.85
parse_escape_codes_b64Function · 0.85
consumeMethod · 0.80
parse_bytesFunction · 0.70

Tested by

no test coverage detected