Repository navigation
Expand file tree
/
Copy pathtest_models.py
More file actions
114 lines (94 loc) · 3.17 KB
/
Copy pathtest_models.py
File metadata and controls
114 lines (94 loc) · 3.17 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"""Tests for Pydantic models validation."""
import pytest
from minilake.models.identity import User
from minilake.models.sql import ColumnInfo, CreateWarehouseResponse, GetWarehouseResponse
from minilake.models.unity_catalog import CatalogInfo, SchemaInfo, TableInfo
@pytest.mark.smoke
def test_column_info_model_creation():
"""Test: ColumnInfo model can be created and serialized."""
col = ColumnInfo(name="test_col", type_text="VARCHAR")
assert col.name == "test_col"
assert col.type_text == "VARCHAR"
# Test serialization
col_dict = col.model_dump()
assert col_dict["name"] == "test_col"
print("✓ ColumnInfo model works")
@pytest.mark.smoke
def test_warehouse_response_models():
"""Test: Warehouse response models."""
# CreateWarehouseResponse
create_resp = CreateWarehouseResponse(id="wh-123")
assert create_resp.id == "wh-123"
# GetWarehouseResponse
get_resp = GetWarehouseResponse(
id="wh-123",
name="test-wh",
state="RUNNING",
cluster_size="Small",
creator_user_id="user-1",
created_at=1234567890,
updated_at=1234567890,
)
assert get_resp.id == "wh-123"
assert get_resp.name == "test-wh"
print("✓ Warehouse response models work")
@pytest.mark.smoke
def test_catalog_info_model():
"""Test: CatalogInfo model."""
cat = CatalogInfo(
name="test_cat",
comment="Test catalog",
owner="test-user",
created_at=1234567890,
updated_at=1234567890,
)
assert cat.name == "test_cat"
assert cat.comment == "Test catalog"
print("✓ CatalogInfo model works")
@pytest.mark.smoke
def test_schema_info_model():
"""Test: SchemaInfo model."""
schema = SchemaInfo(
name="test_schema",
catalog_name="test_cat",
full_name="test_cat.test_schema",
owner="test-user",
created_at=1234567890,
updated_at=1234567890,
)
assert schema.name == "test_schema"
assert schema.full_name == "test_cat.test_schema"
print("✓ SchemaInfo model works")
@pytest.mark.smoke
def test_table_info_model():
"""Test: TableInfo model."""
table = TableInfo(
name="test_table",
catalog_name="test_cat",
schema_name="test_schema",
table_type="MANAGED",
owner="test-user",
created_at=1234567890,
updated_at=1234567890,
)
assert table.name == "test_table"
assert table.full_name == "test_cat.test_schema.test_table"
print("✓ TableInfo model works")
@pytest.mark.smoke
def test_user_model():
"""Test: User model (SCIM)."""
user = User(user_name="test-user", id="user-123")
assert user.user_name == "test-user"
assert user.id == "user-123"
# Test serialization
user_dict = user.model_dump()
assert user_dict["user_name"] == "test-user"
print("✓ User model works")
@pytest.mark.smoke
def test_model_validation_errors():
"""Test: Model validation catches missing required fields."""
# ColumnInfo requires name and type_text
with pytest.raises(Exception):
ColumnInfo() # type: ignore
print("✓ Model validation works")