ClickHouse/tests/integration/test_http_native/test.py

30 lines
851 B
Python
Raw Normal View History

2023-02-14 16:30:13 +00:00
import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
instance = cluster.add_instance("instance")
@pytest.fixture(scope="module", autouse=True)
def setup_nodes():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def test_http_native_returns_timezone():
# No timezone when no protocol version sent
query = "SELECT toDateTime(1676369730, 'Asia/Shanghai') as dt FORMAT Native"
raw = instance.http_query(query, content=True)
2023-02-15 01:44:41 +00:00
assert raw.hex(" ", 2) == "0101 0264 7408 4461 7465 5469 6d65 425f eb63"
2023-02-14 16:30:13 +00:00
# Timezone available when protocol version sent
raw = instance.http_query(
query, params={"client_protocol_version": 54337}, content=True
)
2023-02-14 16:30:13 +00:00
ch_type = raw[14:39].decode()
assert ch_type == "DateTime('Asia/Shanghai')"