-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_contract.py
More file actions
58 lines (50 loc) · 1.51 KB
/
test_contract.py
File metadata and controls
58 lines (50 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from __future__ import annotations
from dataclasses import fields
from unittest.mock import patch
import hotdata_runtime as hr
from hotdata_runtime.client import HotdataClient
from hotdata_runtime.result import QueryResult
def test_public_exports_contract():
assert hr.__all__ == [
"__version__",
"DEFAULT_SCHEMA",
"HotdataClient",
"LoadManagedTableResult",
"MANAGED_SOURCE_TYPE",
"ManagedDatabase",
"ManagedTable",
"QueryResult",
"build_managed_config",
"create_connection_request",
"is_parquet_path",
"workspace_health_lines",
"default_api_key",
"default_host",
"default_session_id",
"explicit_workspace_id",
"from_env",
"list_workspaces",
"normalize_host",
"pick_workspace",
"resolve_workspace_selection",
"ResultSummary",
"RunHistoryItem",
"WorkspaceSelection",
]
def test_module_from_env_delegates_to_client_classmethod():
sentinel = HotdataClient("k", "ws", host="https://api.hotdata.dev")
with patch.object(HotdataClient, "from_env", return_value=sentinel) as m:
got = hr.from_env()
m.assert_called_once_with()
assert got is sentinel
def test_query_result_contract_fields():
assert [f.name for f in fields(QueryResult)] == [
"columns",
"rows",
"row_count",
"result_id",
"query_run_id",
"execution_time_ms",
"warning",
"error_message",
]