Files
zeekay 999d38466d rename: this fork is ours — datastore_connect
Imports read `datastore_connect`, distribution `datastore-connect`, so nothing has to
import another product's name to talk to Hanzo Datastore.

Cut from upstream 0.8.17 — the version this stack already ran — rather than from
upstream HEAD, so it is a PURE RENAME with no behaviour change. Forking from
HEAD would have dragged versions along with the name (connect alone jumped
0.8.17 -> 1.6.0, a major), which is a different and much riskier change wearing
a rename's clothes.

X-ClickHouse-* headers are untouched: they are wire protocol the server sends
and expects, and a different token shape from the module name.
2026-07-26 11:01:30 -07:00

40 lines
1.4 KiB
Python

from datastore_connect.driver.buffer import ResponseBuffer as PyResponseBuffer
from datastore_connect.driver.exceptions import StreamCompleteException
from datastore_connect.driverc.buffer import ResponseBuffer as CResponseBuffer # pylint: disable=no-name-in-module
from tests.helpers import bytes_source, to_bytes
def test_read_ints():
for cls in CResponseBuffer, PyResponseBuffer:
buff = bytes_source('05 20 00 00 00 00 00 00 68 10 83 03 77', cls=cls)
assert buff.read_uint64() == 8197
assert buff.read_leb128() == 104
assert buff.read_leb128() == 16
assert buff.read_leb128() == 387
assert buff.read_byte() == 0x77
try:
buff.read_byte()
except StreamCompleteException:
pass
def test_read_strings():
for cls in CResponseBuffer, PyResponseBuffer:
buff = bytes_source('04 43 44 4d 41', cls=cls)
assert buff.read_leb128_str() == 'CDMA'
try:
buff.read_str_col(2, 'utf8')
except StreamCompleteException:
pass
def test_read_bytes():
for cls in CResponseBuffer, PyResponseBuffer, :
buff = bytes_source('04 43 44 4d 41 22 44 66 88 AA', cls=cls)
buff.read_byte()
assert buff.read_bytes(5) == to_bytes('43 44 4d 41 22')
try:
buff.read_bytes(10)
except StreamCompleteException:
pass