Repository navigation
Expand file tree
/
Copy pathtest_install.py
More file actions
executable file
·158 lines (135 loc) · 4.4 KB
/
Copy pathtest_install.py
File metadata and controls
executable file
·158 lines (135 loc) · 4.4 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env python3
"""
Quick test script to verify the gatewayz SDK is installed correctly.
Run this after installing with: pip install -e .
"""
def test_import():
"""Test that the main package can be imported."""
try:
import gatewayz
print("✓ Successfully imported gatewayz package")
return True
except ImportError as e:
print(f"✗ Failed to import gatewayz package: {e}")
return False
def test_client_import():
"""Test that the main client classes can be imported."""
try:
from gatewayz import GatewayzApi, AsyncGatewayzApi
print("✓ Successfully imported GatewayzApi and AsyncGatewayzApi")
return True
except ImportError as e:
print(f"✗ Failed to import client classes: {e}")
return False
def test_types_import():
"""Test that type definitions can be imported."""
try:
from gatewayz.types import Message, ChatSession, UserProfileResponse
print("✓ Successfully imported type definitions")
return True
except ImportError as e:
print(f"✗ Failed to import types: {e}")
return False
def test_client_instantiation():
"""Test that the client can be instantiated."""
try:
from gatewayz import GatewayzApi
client = GatewayzApi(
token="test-token",
base_url="https://test.example.com"
)
print("✓ Successfully instantiated GatewayzApi client")
print(f" Client type: {type(client)}")
return True
except Exception as e:
print(f"✗ Failed to instantiate client: {e}")
return False
def test_client_properties():
"""Test that client properties are accessible."""
try:
from gatewayz import GatewayzApi
client = GatewayzApi(
token="test-token",
base_url="https://test.example.com"
)
# Test accessing sub-clients
_ = client.chat
_ = client.authentication
_ = client.providers
_ = client.models
print("✓ Successfully accessed client properties")
return True
except Exception as e:
print(f"✗ Failed to access client properties: {e}")
return False
def test_async_client():
"""Test that async client can be imported and instantiated."""
try:
from gatewayz import AsyncGatewayzApi
client = AsyncGatewayzApi(
token="test-token",
base_url="https://test.example.com"
)
print("✓ Successfully instantiated AsyncGatewayzApi client")
return True
except Exception as e:
print(f"✗ Failed with async client: {e}")
return False
def test_error_classes():
"""Test that error classes can be imported."""
try:
from gatewayz.errors import UnprocessableEntityError
from gatewayz.core import ApiError
print("✓ Successfully imported error classes")
return True
except ImportError as e:
print(f"✗ Failed to import error classes: {e}")
return False
def main():
"""Run all tests."""
print("=" * 60)
print("Testing gatewayz SDK Installation")
print("=" * 60)
print()
tests = [
test_import,
test_client_import,
test_types_import,
test_client_instantiation,
test_client_properties,
test_async_client,
test_error_classes,
]
results = []
for test in tests:
result = test()
results.append(result)
print()
print("=" * 60)
passed = sum(results)
total = len(results)
if passed == total:
print(f"✓ All {total} tests passed! SDK is installed correctly.")
print()
print("You can now use the SDK:")
print()
print(" from gatewayz import GatewayzApi")
print()
print(" client = GatewayzApi(")
print(" token='YOUR_TOKEN',")
print(" base_url='https://your-api.com'")
print(" )")
print()
return 0
else:
print(f"✗ {total - passed}/{total} tests failed.")
print()
print("Troubleshooting:")
print("1. Make sure you installed with: pip install -e .")
print("2. Check you're in the correct virtual environment")
print("3. Try reinstalling: pip uninstall gatewayz && pip install -e .")
print()
return 1
if __name__ == "__main__":
import sys
sys.exit(main())