testzeus-sdk 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- testzeus_sdk-0.0.1/LICENSE +21 -0
- testzeus_sdk-0.0.1/PKG-INFO +323 -0
- testzeus_sdk-0.0.1/README.md +298 -0
- testzeus_sdk-0.0.1/pyproject.toml +54 -0
- testzeus_sdk-0.0.1/testzeus_sdk/__init__.py +12 -0
- testzeus_sdk-0.0.1/testzeus_sdk/client.py +308 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/__init__.py +24 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/agent_configs_manager.py +44 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/base.py +304 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/environment_manager.py +144 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/tag_manager.py +94 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/tags_manager.py +43 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/tenant_consumption_logs_manager.py +44 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/tenant_consumption_manager.py +43 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/tenants_manager.py +42 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_data_manager.py +75 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_designs_manager.py +46 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_device_manager.py +44 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_manager.py +247 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_run_dash_output_steps_manager.py +45 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_run_dash_outputs_attachments_manager.py +107 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_run_dash_outputs_manager.py +45 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_run_dashs_manager.py +70 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_run_manager.py +150 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_run_reports_manager.py +45 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_runs_manager.py +49 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/test_runs_stage_manager.py +49 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/tests_manager.py +73 -0
- testzeus_sdk-0.0.1/testzeus_sdk/managers/users_manager.py +42 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/__init__.py +24 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/agent_configs.py +31 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/base.py +55 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/environment.py +61 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/tag.py +30 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/tags.py +26 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/tenant_consumption.py +34 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/tenant_consumption_logs.py +30 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/tenants.py +30 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test.py +65 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test_data.py +71 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test_designs.py +31 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test_device.py +47 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test_run.py +104 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test_run_dash_output_steps.py +40 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test_run_dash_outputs.py +30 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test_run_dash_outputs_attachments.py +32 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test_run_dashs.py +34 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test_run_reports.py +31 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test_runs.py +38 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/test_runs_stage.py +38 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/tests.py +34 -0
- testzeus_sdk-0.0.1/testzeus_sdk/models/users.py +37 -0
- testzeus_sdk-0.0.1/testzeus_sdk/utils/__init__.py +3 -0
- testzeus_sdk-0.0.1/testzeus_sdk/utils/helpers.py +110 -0
- testzeus_sdk-0.0.1/testzeus_sdk/utils/schema_generator.py +363 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 TestZeus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: testzeus-sdk
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Python SDK for TestZeus testing platform
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: Shriyansh Agnihotri
|
|
7
|
+
Author-email: shriyansh@testzeus.com
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Requires-Dist: aiohttp (>=3.9.3,<4.0.0)
|
|
19
|
+
Requires-Dist: dotenv (>=0.9.9,<0.10.0)
|
|
20
|
+
Requires-Dist: pocketbase (>=0.15.0,<0.16.0)
|
|
21
|
+
Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
|
|
22
|
+
Project-URL: Repository, https://github.com/test-zeus-ai/testzeus-sdk
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# TestZeus SDK
|
|
26
|
+
|
|
27
|
+
Python SDK for the TestZeus testing platform.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
Install the package using pip:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install testzeus-sdk
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or use Poetry:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
poetry add testzeus-sdk
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Getting Started
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import asyncio
|
|
47
|
+
from testzeus_sdk import TestZeusClient
|
|
48
|
+
|
|
49
|
+
async def main():
|
|
50
|
+
# Create a client with email/password
|
|
51
|
+
client = TestZeusClient(email="your-email", password="your-password")
|
|
52
|
+
|
|
53
|
+
# Use as a context manager
|
|
54
|
+
async with client:
|
|
55
|
+
# Your code here
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
# Run the example
|
|
59
|
+
asyncio.run(main())
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Authentication
|
|
63
|
+
|
|
64
|
+
The SDK supports three authentication methods:
|
|
65
|
+
|
|
66
|
+
### Email/Password
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
client = TestZeusClient(email="your-email", password="your-password")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Environment Variables
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
export TESTZEUS_EMAIL="your-email"
|
|
76
|
+
export TESTZEUS_PASSWORD="your-password"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Then create the client without parameters:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
client = TestZeusClient()
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Core Functionality
|
|
86
|
+
|
|
87
|
+
### Tests Management
|
|
88
|
+
|
|
89
|
+
#### List Tests
|
|
90
|
+
```python
|
|
91
|
+
# Get list of tests with filters and sorting
|
|
92
|
+
tests = await client.tests.get_list(
|
|
93
|
+
expand='tags', # Expand related entities
|
|
94
|
+
sort='id', # Sort by field
|
|
95
|
+
filters={ # Filter results
|
|
96
|
+
'id': 'y9b88f17vabx476'
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
print(tests)
|
|
100
|
+
print(tests['items'][0].data) # Access test data
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Get Single Test
|
|
104
|
+
```python
|
|
105
|
+
# Get test by ID
|
|
106
|
+
test = await client.tests.get_one('311137kown88nd6')
|
|
107
|
+
print(test.data)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Create Test
|
|
111
|
+
```python
|
|
112
|
+
# Create a new test
|
|
113
|
+
new_test = await client.tests.create(
|
|
114
|
+
name="New Test",
|
|
115
|
+
test_feature="Example feature",
|
|
116
|
+
status="draft", # Optional: 'draft', 'ready', 'deleted'
|
|
117
|
+
test_data=["data_id1", "data_id2"], # Optional: List of test data IDs
|
|
118
|
+
tags=["tag1", "tag2"], # Optional: List of tag IDs
|
|
119
|
+
environment="env_id" # Optional: Environment ID
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Update Test
|
|
124
|
+
```python
|
|
125
|
+
# Update test properties
|
|
126
|
+
updated_test = await client.tests.update(
|
|
127
|
+
'test_id',
|
|
128
|
+
name='Updated Test Name'
|
|
129
|
+
)
|
|
130
|
+
print(updated_test.data)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### Delete Test
|
|
134
|
+
```python
|
|
135
|
+
# Delete a test
|
|
136
|
+
await client.tests.delete('test_id')
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Test Runs Management
|
|
140
|
+
|
|
141
|
+
#### Create and Start Test Run
|
|
142
|
+
```python
|
|
143
|
+
# Create and start a test run
|
|
144
|
+
test_run = await client.test_runs.create_and_start(
|
|
145
|
+
name="Test Run Name",
|
|
146
|
+
test="Test Name or ID"
|
|
147
|
+
)
|
|
148
|
+
print(test_run.data)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### Track Test Run Status
|
|
152
|
+
```python
|
|
153
|
+
# Get test run by ID
|
|
154
|
+
test_run = await client.test_runs.get_one('test_run_id')
|
|
155
|
+
|
|
156
|
+
# Check test run status
|
|
157
|
+
if test_run.is_running():
|
|
158
|
+
print("Test is currently running")
|
|
159
|
+
elif test_run.is_completed():
|
|
160
|
+
print("Test has completed successfully")
|
|
161
|
+
elif test_run.is_failed():
|
|
162
|
+
print("Test has failed")
|
|
163
|
+
elif test_run.is_crashed():
|
|
164
|
+
print("Test has crashed")
|
|
165
|
+
elif test_run.is_cancelled():
|
|
166
|
+
print("Test was cancelled")
|
|
167
|
+
elif test_run.is_pending():
|
|
168
|
+
print("Test is pending")
|
|
169
|
+
|
|
170
|
+
# Get test run duration
|
|
171
|
+
duration = test_run.get_duration()
|
|
172
|
+
if duration:
|
|
173
|
+
print(f"Test run took {duration} seconds")
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### Get Detailed Test Run Information
|
|
177
|
+
```python
|
|
178
|
+
# Get expanded test run details including all outputs, steps, and attachments
|
|
179
|
+
expanded_test_run = await client.test_runs.get_expanded('test_run_id')
|
|
180
|
+
|
|
181
|
+
# Access different components of the test run
|
|
182
|
+
test_run_data = expanded_test_run['test_run']
|
|
183
|
+
test_run_dashs = expanded_test_run['test_run_dashs']
|
|
184
|
+
test_run_dash_outputs = expanded_test_run['test_run_dash_outputs']
|
|
185
|
+
test_run_dash_output_steps = expanded_test_run['test_run_dash_output_steps']
|
|
186
|
+
test_run_dash_outputs_attachments = expanded_test_run['test_run_dash_outputs_attachments']
|
|
187
|
+
|
|
188
|
+
# Print test run details
|
|
189
|
+
print(f"Test Run Name: {test_run_data['name']}")
|
|
190
|
+
print(f"Status: {test_run_data['status']}")
|
|
191
|
+
print(f"Start Time: {test_run_data['start_time']}")
|
|
192
|
+
print(f"End Time: {test_run_data['end_time']}")
|
|
193
|
+
|
|
194
|
+
# Print test run steps
|
|
195
|
+
for step in test_run_dash_output_steps:
|
|
196
|
+
print(f"Step: {step['name']}")
|
|
197
|
+
print(f"Status: {step['status']}")
|
|
198
|
+
print(f"Is Passed: {step['is_passed']}")
|
|
199
|
+
print(f"Assert Summary: {step['assert_summary']}")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### Cancel Test Run
|
|
203
|
+
```python
|
|
204
|
+
# Cancel a running test
|
|
205
|
+
try:
|
|
206
|
+
cancelled_test = await client.test_runs.cancel('test_run_id')
|
|
207
|
+
print(f"Test run cancelled: {cancelled_test.status}")
|
|
208
|
+
except ValueError as e:
|
|
209
|
+
print(f"Cannot cancel test: {str(e)}")
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
#### Download Test Run Attachments
|
|
213
|
+
```python
|
|
214
|
+
# Download all attachments for a test run
|
|
215
|
+
download_attachment = await client.test_runs.download_all_attachments(
|
|
216
|
+
'test_run_id',
|
|
217
|
+
'local/path/to/save'
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
# Download specific attachment
|
|
221
|
+
attachment = await client.test_run_dash_outputs_attachments.download_attachment(
|
|
222
|
+
'attachment_id',
|
|
223
|
+
'local/path/to/save'
|
|
224
|
+
)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### Monitor Test Run Progress
|
|
228
|
+
```python
|
|
229
|
+
import asyncio
|
|
230
|
+
import time
|
|
231
|
+
|
|
232
|
+
async def monitor_test_run(test_run_id: str, check_interval: int = 5):
|
|
233
|
+
"""
|
|
234
|
+
Monitor a test run's progress until completion
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
test_run_id: ID of the test run to monitor
|
|
238
|
+
check_interval: Time between status checks in seconds
|
|
239
|
+
"""
|
|
240
|
+
while True:
|
|
241
|
+
test_run = await client.test_runs.get_one(test_run_id)
|
|
242
|
+
|
|
243
|
+
if test_run.is_completed():
|
|
244
|
+
print("Test run completed successfully!")
|
|
245
|
+
break
|
|
246
|
+
elif test_run.is_failed():
|
|
247
|
+
print("Test run failed!")
|
|
248
|
+
break
|
|
249
|
+
elif test_run.is_crashed():
|
|
250
|
+
print("Test run crashed!")
|
|
251
|
+
break
|
|
252
|
+
elif test_run.is_cancelled():
|
|
253
|
+
print("Test run was cancelled!")
|
|
254
|
+
break
|
|
255
|
+
|
|
256
|
+
print(f"Test run status: {test_run.status}")
|
|
257
|
+
await asyncio.sleep(check_interval)
|
|
258
|
+
|
|
259
|
+
# Usage
|
|
260
|
+
await monitor_test_run('test_run_id')
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Test Data Management
|
|
264
|
+
|
|
265
|
+
```python
|
|
266
|
+
# Create test data
|
|
267
|
+
test_data = await client.test_data.create({
|
|
268
|
+
"name": "Test Data",
|
|
269
|
+
"type": "test", # Optional: defaults to "test"
|
|
270
|
+
"status": "draft" # Optional: defaults to "draft"
|
|
271
|
+
})
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Environment Management
|
|
275
|
+
|
|
276
|
+
```python
|
|
277
|
+
# List environments
|
|
278
|
+
environments = await client.environments.get_list()
|
|
279
|
+
|
|
280
|
+
# Get environment by ID
|
|
281
|
+
environment = await client.environments.get_one('env_id')
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Tags Management
|
|
285
|
+
|
|
286
|
+
```python
|
|
287
|
+
# List tags
|
|
288
|
+
tags = await client.tags.get_list()
|
|
289
|
+
|
|
290
|
+
# Create tag
|
|
291
|
+
tag = await client.tags.create({
|
|
292
|
+
"name": "New Tag"
|
|
293
|
+
})
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Available Managers
|
|
297
|
+
|
|
298
|
+
The SDK provides managers for all TestZeus collections:
|
|
299
|
+
|
|
300
|
+
- `client.tests` - Tests
|
|
301
|
+
- `client.test_runs` - Test Runs
|
|
302
|
+
- `client.test_run_dashs` - Test Run Dashboards
|
|
303
|
+
- `client.test_data` - Test Data
|
|
304
|
+
- `client.environments` - Environments
|
|
305
|
+
- `client.tags` - Tags
|
|
306
|
+
- `client.agent_configs` - Agent Configurations
|
|
307
|
+
- `client.test_devices` - Test Devices
|
|
308
|
+
- `client.test_designs` - Test Designs
|
|
309
|
+
- `client.test_run_dash_outputs` - Test Run Dashboard Outputs
|
|
310
|
+
- `client.test_run_dash_output_steps` - Test Run Dashboard Output Steps
|
|
311
|
+
- `client.tenant_consumption` - Tenant Consumption
|
|
312
|
+
- `client.tenant_consumption_logs` - Tenant Consumption Logs
|
|
313
|
+
|
|
314
|
+
## Contributing
|
|
315
|
+
|
|
316
|
+
1. Clone the repository
|
|
317
|
+
2. Install dependencies with Poetry: `poetry install`
|
|
318
|
+
3. Run tests: `poetry run pytest`
|
|
319
|
+
|
|
320
|
+
## License
|
|
321
|
+
|
|
322
|
+
MIT
|
|
323
|
+
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# TestZeus SDK
|
|
2
|
+
|
|
3
|
+
Python SDK for the TestZeus testing platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the package using pip:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install testzeus-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or use Poetry:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
poetry add testzeus-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Getting Started
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
import asyncio
|
|
23
|
+
from testzeus_sdk import TestZeusClient
|
|
24
|
+
|
|
25
|
+
async def main():
|
|
26
|
+
# Create a client with email/password
|
|
27
|
+
client = TestZeusClient(email="your-email", password="your-password")
|
|
28
|
+
|
|
29
|
+
# Use as a context manager
|
|
30
|
+
async with client:
|
|
31
|
+
# Your code here
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
# Run the example
|
|
35
|
+
asyncio.run(main())
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Authentication
|
|
39
|
+
|
|
40
|
+
The SDK supports three authentication methods:
|
|
41
|
+
|
|
42
|
+
### Email/Password
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
client = TestZeusClient(email="your-email", password="your-password")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Environment Variables
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
export TESTZEUS_EMAIL="your-email"
|
|
52
|
+
export TESTZEUS_PASSWORD="your-password"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Then create the client without parameters:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
client = TestZeusClient()
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Core Functionality
|
|
62
|
+
|
|
63
|
+
### Tests Management
|
|
64
|
+
|
|
65
|
+
#### List Tests
|
|
66
|
+
```python
|
|
67
|
+
# Get list of tests with filters and sorting
|
|
68
|
+
tests = await client.tests.get_list(
|
|
69
|
+
expand='tags', # Expand related entities
|
|
70
|
+
sort='id', # Sort by field
|
|
71
|
+
filters={ # Filter results
|
|
72
|
+
'id': 'y9b88f17vabx476'
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
print(tests)
|
|
76
|
+
print(tests['items'][0].data) # Access test data
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Get Single Test
|
|
80
|
+
```python
|
|
81
|
+
# Get test by ID
|
|
82
|
+
test = await client.tests.get_one('311137kown88nd6')
|
|
83
|
+
print(test.data)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### Create Test
|
|
87
|
+
```python
|
|
88
|
+
# Create a new test
|
|
89
|
+
new_test = await client.tests.create(
|
|
90
|
+
name="New Test",
|
|
91
|
+
test_feature="Example feature",
|
|
92
|
+
status="draft", # Optional: 'draft', 'ready', 'deleted'
|
|
93
|
+
test_data=["data_id1", "data_id2"], # Optional: List of test data IDs
|
|
94
|
+
tags=["tag1", "tag2"], # Optional: List of tag IDs
|
|
95
|
+
environment="env_id" # Optional: Environment ID
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Update Test
|
|
100
|
+
```python
|
|
101
|
+
# Update test properties
|
|
102
|
+
updated_test = await client.tests.update(
|
|
103
|
+
'test_id',
|
|
104
|
+
name='Updated Test Name'
|
|
105
|
+
)
|
|
106
|
+
print(updated_test.data)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Delete Test
|
|
110
|
+
```python
|
|
111
|
+
# Delete a test
|
|
112
|
+
await client.tests.delete('test_id')
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Test Runs Management
|
|
116
|
+
|
|
117
|
+
#### Create and Start Test Run
|
|
118
|
+
```python
|
|
119
|
+
# Create and start a test run
|
|
120
|
+
test_run = await client.test_runs.create_and_start(
|
|
121
|
+
name="Test Run Name",
|
|
122
|
+
test="Test Name or ID"
|
|
123
|
+
)
|
|
124
|
+
print(test_run.data)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Track Test Run Status
|
|
128
|
+
```python
|
|
129
|
+
# Get test run by ID
|
|
130
|
+
test_run = await client.test_runs.get_one('test_run_id')
|
|
131
|
+
|
|
132
|
+
# Check test run status
|
|
133
|
+
if test_run.is_running():
|
|
134
|
+
print("Test is currently running")
|
|
135
|
+
elif test_run.is_completed():
|
|
136
|
+
print("Test has completed successfully")
|
|
137
|
+
elif test_run.is_failed():
|
|
138
|
+
print("Test has failed")
|
|
139
|
+
elif test_run.is_crashed():
|
|
140
|
+
print("Test has crashed")
|
|
141
|
+
elif test_run.is_cancelled():
|
|
142
|
+
print("Test was cancelled")
|
|
143
|
+
elif test_run.is_pending():
|
|
144
|
+
print("Test is pending")
|
|
145
|
+
|
|
146
|
+
# Get test run duration
|
|
147
|
+
duration = test_run.get_duration()
|
|
148
|
+
if duration:
|
|
149
|
+
print(f"Test run took {duration} seconds")
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### Get Detailed Test Run Information
|
|
153
|
+
```python
|
|
154
|
+
# Get expanded test run details including all outputs, steps, and attachments
|
|
155
|
+
expanded_test_run = await client.test_runs.get_expanded('test_run_id')
|
|
156
|
+
|
|
157
|
+
# Access different components of the test run
|
|
158
|
+
test_run_data = expanded_test_run['test_run']
|
|
159
|
+
test_run_dashs = expanded_test_run['test_run_dashs']
|
|
160
|
+
test_run_dash_outputs = expanded_test_run['test_run_dash_outputs']
|
|
161
|
+
test_run_dash_output_steps = expanded_test_run['test_run_dash_output_steps']
|
|
162
|
+
test_run_dash_outputs_attachments = expanded_test_run['test_run_dash_outputs_attachments']
|
|
163
|
+
|
|
164
|
+
# Print test run details
|
|
165
|
+
print(f"Test Run Name: {test_run_data['name']}")
|
|
166
|
+
print(f"Status: {test_run_data['status']}")
|
|
167
|
+
print(f"Start Time: {test_run_data['start_time']}")
|
|
168
|
+
print(f"End Time: {test_run_data['end_time']}")
|
|
169
|
+
|
|
170
|
+
# Print test run steps
|
|
171
|
+
for step in test_run_dash_output_steps:
|
|
172
|
+
print(f"Step: {step['name']}")
|
|
173
|
+
print(f"Status: {step['status']}")
|
|
174
|
+
print(f"Is Passed: {step['is_passed']}")
|
|
175
|
+
print(f"Assert Summary: {step['assert_summary']}")
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
#### Cancel Test Run
|
|
179
|
+
```python
|
|
180
|
+
# Cancel a running test
|
|
181
|
+
try:
|
|
182
|
+
cancelled_test = await client.test_runs.cancel('test_run_id')
|
|
183
|
+
print(f"Test run cancelled: {cancelled_test.status}")
|
|
184
|
+
except ValueError as e:
|
|
185
|
+
print(f"Cannot cancel test: {str(e)}")
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### Download Test Run Attachments
|
|
189
|
+
```python
|
|
190
|
+
# Download all attachments for a test run
|
|
191
|
+
download_attachment = await client.test_runs.download_all_attachments(
|
|
192
|
+
'test_run_id',
|
|
193
|
+
'local/path/to/save'
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
# Download specific attachment
|
|
197
|
+
attachment = await client.test_run_dash_outputs_attachments.download_attachment(
|
|
198
|
+
'attachment_id',
|
|
199
|
+
'local/path/to/save'
|
|
200
|
+
)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Monitor Test Run Progress
|
|
204
|
+
```python
|
|
205
|
+
import asyncio
|
|
206
|
+
import time
|
|
207
|
+
|
|
208
|
+
async def monitor_test_run(test_run_id: str, check_interval: int = 5):
|
|
209
|
+
"""
|
|
210
|
+
Monitor a test run's progress until completion
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
test_run_id: ID of the test run to monitor
|
|
214
|
+
check_interval: Time between status checks in seconds
|
|
215
|
+
"""
|
|
216
|
+
while True:
|
|
217
|
+
test_run = await client.test_runs.get_one(test_run_id)
|
|
218
|
+
|
|
219
|
+
if test_run.is_completed():
|
|
220
|
+
print("Test run completed successfully!")
|
|
221
|
+
break
|
|
222
|
+
elif test_run.is_failed():
|
|
223
|
+
print("Test run failed!")
|
|
224
|
+
break
|
|
225
|
+
elif test_run.is_crashed():
|
|
226
|
+
print("Test run crashed!")
|
|
227
|
+
break
|
|
228
|
+
elif test_run.is_cancelled():
|
|
229
|
+
print("Test run was cancelled!")
|
|
230
|
+
break
|
|
231
|
+
|
|
232
|
+
print(f"Test run status: {test_run.status}")
|
|
233
|
+
await asyncio.sleep(check_interval)
|
|
234
|
+
|
|
235
|
+
# Usage
|
|
236
|
+
await monitor_test_run('test_run_id')
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Test Data Management
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
# Create test data
|
|
243
|
+
test_data = await client.test_data.create({
|
|
244
|
+
"name": "Test Data",
|
|
245
|
+
"type": "test", # Optional: defaults to "test"
|
|
246
|
+
"status": "draft" # Optional: defaults to "draft"
|
|
247
|
+
})
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Environment Management
|
|
251
|
+
|
|
252
|
+
```python
|
|
253
|
+
# List environments
|
|
254
|
+
environments = await client.environments.get_list()
|
|
255
|
+
|
|
256
|
+
# Get environment by ID
|
|
257
|
+
environment = await client.environments.get_one('env_id')
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Tags Management
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
# List tags
|
|
264
|
+
tags = await client.tags.get_list()
|
|
265
|
+
|
|
266
|
+
# Create tag
|
|
267
|
+
tag = await client.tags.create({
|
|
268
|
+
"name": "New Tag"
|
|
269
|
+
})
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Available Managers
|
|
273
|
+
|
|
274
|
+
The SDK provides managers for all TestZeus collections:
|
|
275
|
+
|
|
276
|
+
- `client.tests` - Tests
|
|
277
|
+
- `client.test_runs` - Test Runs
|
|
278
|
+
- `client.test_run_dashs` - Test Run Dashboards
|
|
279
|
+
- `client.test_data` - Test Data
|
|
280
|
+
- `client.environments` - Environments
|
|
281
|
+
- `client.tags` - Tags
|
|
282
|
+
- `client.agent_configs` - Agent Configurations
|
|
283
|
+
- `client.test_devices` - Test Devices
|
|
284
|
+
- `client.test_designs` - Test Designs
|
|
285
|
+
- `client.test_run_dash_outputs` - Test Run Dashboard Outputs
|
|
286
|
+
- `client.test_run_dash_output_steps` - Test Run Dashboard Output Steps
|
|
287
|
+
- `client.tenant_consumption` - Tenant Consumption
|
|
288
|
+
- `client.tenant_consumption_logs` - Tenant Consumption Logs
|
|
289
|
+
|
|
290
|
+
## Contributing
|
|
291
|
+
|
|
292
|
+
1. Clone the repository
|
|
293
|
+
2. Install dependencies with Poetry: `poetry install`
|
|
294
|
+
3. Run tests: `poetry run pytest`
|
|
295
|
+
|
|
296
|
+
## License
|
|
297
|
+
|
|
298
|
+
MIT
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "testzeus-sdk"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "Python SDK for TestZeus testing platform"
|
|
5
|
+
authors = ["Shriyansh Agnihotri <shriyansh@testzeus.com>"]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
repository = "https://github.com/test-zeus-ai/testzeus-sdk"
|
|
8
|
+
license = "MIT"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 3 - Alpha",
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3.9",
|
|
15
|
+
"Programming Language :: Python :: 3.10",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[tool.poetry.dependencies]
|
|
20
|
+
python = ">=3.11"
|
|
21
|
+
pocketbase = "^0.15.0"
|
|
22
|
+
aiohttp = "^3.9.3"
|
|
23
|
+
python-dotenv = "^1.0.1"
|
|
24
|
+
dotenv = "^0.9.9"
|
|
25
|
+
|
|
26
|
+
[tool.poetry.group.dev.dependencies]
|
|
27
|
+
pytest = "^7.0.0"
|
|
28
|
+
black = "^23.0.0"
|
|
29
|
+
isort = "^5.12.0"
|
|
30
|
+
mypy = "^1.0.0"
|
|
31
|
+
ipython = "^9.1.0"
|
|
32
|
+
ipdb = "^0.13.13"
|
|
33
|
+
flake8 = "^7.2.0"
|
|
34
|
+
pytest-asyncio = "^0.23.6"
|
|
35
|
+
ipykernel = "^6.29.5"
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["poetry-core"]
|
|
39
|
+
build-backend = "poetry.core.masonry.api"
|
|
40
|
+
|
|
41
|
+
[tool.black]
|
|
42
|
+
line-length = 88
|
|
43
|
+
target-version = ["py39"]
|
|
44
|
+
|
|
45
|
+
[tool.isort]
|
|
46
|
+
profile = "black"
|
|
47
|
+
line_length = 88
|
|
48
|
+
|
|
49
|
+
[tool.mypy]
|
|
50
|
+
python_version = "3.9"
|
|
51
|
+
warn_return_any = true
|
|
52
|
+
warn_unused_configs = true
|
|
53
|
+
disallow_untyped_defs = true
|
|
54
|
+
disallow_incomplete_defs = true
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TestZeus SDK for Python.
|
|
3
|
+
|
|
4
|
+
This SDK provides a simple interface to interact with TestZeus testing platform.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__version__ = "0.1.0"
|
|
8
|
+
|
|
9
|
+
from testzeus_sdk.client import TestZeusClient
|
|
10
|
+
|
|
11
|
+
# Provide a simple alias for the client
|
|
12
|
+
Client = TestZeusClient
|