testzeus-cli 0.0.12__tar.gz → 0.0.14__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_cli-0.0.12 → testzeus_cli-0.0.14}/PKG-INFO +2 -2
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/pyproject.toml +3 -3
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/commands/environments.py +20 -20
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/commands/tags.py +10 -10
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/commands/test_data.py +15 -15
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/commands/test_runs.py +125 -20
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/commands/tests.py +9 -9
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/utils/formatters.py +59 -3
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/LICENSE +0 -0
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/README.md +0 -0
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/__init__.py +0 -0
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/auth.py +0 -0
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/cli.py +0 -0
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/commands/__init__.py +0 -0
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/config.py +0 -0
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/utils/__init__.py +0 -0
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/utils/auth.py +0 -0
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/utils/client.py +0 -0
- {testzeus_cli-0.0.12 → testzeus_cli-0.0.14}/testzeus_cli/utils/validators.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: testzeus-cli
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.14
|
|
4
4
|
Summary: Command-line interface for TestZeus testing platform
|
|
5
5
|
Author: Shriyansh Agnihotri
|
|
6
6
|
Author-email: shriyansh@testzeus.com
|
|
@@ -17,7 +17,7 @@ Requires-Dist: pocketbase (>=0.15.0,<0.16.0)
|
|
|
17
17
|
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
|
|
18
18
|
Requires-Dist: pyyaml (>=6.0,<7.0)
|
|
19
19
|
Requires-Dist: rich (>=13.3.1,<14.0.0)
|
|
20
|
-
Requires-Dist: testzeus-sdk (>=0.0.
|
|
20
|
+
Requires-Dist: testzeus-sdk (>=0.0.13,<0.0.14)
|
|
21
21
|
Project-URL: Repository, https://github.com/test-zeus-ai/testzeus-cli
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "testzeus-cli"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.14"
|
|
8
8
|
description = "Command-line interface for TestZeus testing platform"
|
|
9
9
|
authors = ["Shriyansh Agnihotri <shriyansh@testzeus.com>"]
|
|
10
10
|
readme = "README.md"
|
|
@@ -22,7 +22,7 @@ pydantic = "^2.0.0"
|
|
|
22
22
|
pyyaml = "^6.0"
|
|
23
23
|
keyring = "^24.0.0"
|
|
24
24
|
ipdb = "^0.13.13"
|
|
25
|
-
testzeus-sdk = "^0.0.
|
|
25
|
+
testzeus-sdk = "^0.0.13"
|
|
26
26
|
pocketbase = "^0.15.0"
|
|
27
27
|
|
|
28
28
|
[tool.poetry.group.dev.dependencies]
|
|
@@ -33,4 +33,4 @@ python-dotenv = "^1.0.0"
|
|
|
33
33
|
ipykernel = "^6.29.5"
|
|
34
34
|
|
|
35
35
|
[tool.poetry.scripts]
|
|
36
|
-
testzeus = "testzeus_cli.cli:main"
|
|
36
|
+
testzeus = "testzeus_cli.cli:main"
|
|
@@ -9,7 +9,7 @@ from rich.console import Console
|
|
|
9
9
|
from pocketbase.client import FileUpload
|
|
10
10
|
from testzeus_sdk import TestZeusClient
|
|
11
11
|
from testzeus_cli.config import get_client_config
|
|
12
|
-
from testzeus_cli.utils.formatters import format_output
|
|
12
|
+
from testzeus_cli.utils.formatters import format_output, print_message
|
|
13
13
|
from testzeus_cli.utils.auth import initialize_client_with_token
|
|
14
14
|
from testzeus_cli.utils.validators import parse_key_value_pairs
|
|
15
15
|
|
|
@@ -106,7 +106,7 @@ def create(ctx, name, status, data, data_file, tags, file):
|
|
|
106
106
|
try:
|
|
107
107
|
params["supporting_data_files"] = FileUpload(file, open(file, "rb"))
|
|
108
108
|
except Exception as e:
|
|
109
|
-
|
|
109
|
+
print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
110
110
|
exit(1)
|
|
111
111
|
|
|
112
112
|
env = await client.environments.create(params)
|
|
@@ -114,12 +114,12 @@ def create(ctx, name, status, data, data_file, tags, file):
|
|
|
114
114
|
|
|
115
115
|
try:
|
|
116
116
|
result = asyncio.run(_run())
|
|
117
|
-
|
|
118
|
-
f"[green]Environment created successfully with ID: {result['id']}[/green]"
|
|
117
|
+
print_message(
|
|
118
|
+
f"[green]Environment created successfully with ID: {result['id']}[/green]", ctx.obj["FORMAT"]
|
|
119
119
|
)
|
|
120
120
|
format_output(result, ctx.obj["FORMAT"])
|
|
121
121
|
except Exception as e:
|
|
122
|
-
|
|
122
|
+
print_message(f"[red]Error creating environment: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
123
123
|
raise click.Abort()
|
|
124
124
|
|
|
125
125
|
|
|
@@ -153,7 +153,7 @@ def list(ctx, filters, sort, expand):
|
|
|
153
153
|
result = asyncio.run(_run())
|
|
154
154
|
format_output(result, ctx.obj["FORMAT"])
|
|
155
155
|
except Exception as e:
|
|
156
|
-
|
|
156
|
+
print_message(f"[red]Error listing environments: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
157
157
|
raise click.Abort()
|
|
158
158
|
|
|
159
159
|
|
|
@@ -178,9 +178,9 @@ def delete(ctx, env_id):
|
|
|
178
178
|
|
|
179
179
|
try:
|
|
180
180
|
result = asyncio.run(_run())
|
|
181
|
-
|
|
181
|
+
print_message(f"[green]Environment {result['id']} deleted successfully[/green]", ctx.obj["FORMAT"])
|
|
182
182
|
except Exception as e:
|
|
183
|
-
|
|
183
|
+
print_message(f"[red]Error deleting environment: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
184
184
|
raise click.Abort()
|
|
185
185
|
|
|
186
186
|
|
|
@@ -208,7 +208,7 @@ def get(ctx, env_id, expand):
|
|
|
208
208
|
result = asyncio.run(_run())
|
|
209
209
|
format_output(result, ctx.obj["FORMAT"])
|
|
210
210
|
except Exception as e:
|
|
211
|
-
|
|
211
|
+
print_message(f"[red]Error getting environment: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
212
212
|
raise click.Abort()
|
|
213
213
|
|
|
214
214
|
|
|
@@ -283,22 +283,22 @@ def update(ctx, env_id, name, status, data, data_file, tags, file):
|
|
|
283
283
|
file, open(file, "rb")
|
|
284
284
|
)
|
|
285
285
|
except Exception as e:
|
|
286
|
-
|
|
286
|
+
print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
287
287
|
exit(1)
|
|
288
288
|
|
|
289
289
|
if has_updates:
|
|
290
290
|
updated_env = await client.environments.update(env_id, updates)
|
|
291
291
|
return updated_env.data
|
|
292
292
|
else:
|
|
293
|
-
|
|
293
|
+
print_message("[yellow]No updates provided[/yellow]", ctx.obj["FORMAT"])
|
|
294
294
|
return None
|
|
295
295
|
|
|
296
296
|
try:
|
|
297
297
|
result = asyncio.run(_run())
|
|
298
|
-
|
|
298
|
+
print_message("[green]Environment updated successfully[/green]", ctx.obj["FORMAT"])
|
|
299
299
|
format_output(result, ctx.obj["FORMAT"])
|
|
300
300
|
except Exception as e:
|
|
301
|
-
|
|
301
|
+
print_message(f"[red]Error updating environment: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
302
302
|
raise click.Abort()
|
|
303
303
|
|
|
304
304
|
|
|
@@ -323,7 +323,7 @@ def upload_file(ctx, env_id, file_path):
|
|
|
323
323
|
await client.ensure_authenticated()
|
|
324
324
|
file_path_validated = Path(file_path)
|
|
325
325
|
if not file_path_validated.exists():
|
|
326
|
-
|
|
326
|
+
print_message(f"[red]File not found:[/red] {file_path}", ctx.obj["FORMAT"])
|
|
327
327
|
exit(1)
|
|
328
328
|
params = {
|
|
329
329
|
"supporting_data_files+": FileUpload(file_path, open(file_path, "rb")),
|
|
@@ -337,7 +337,7 @@ def upload_file(ctx, env_id, file_path):
|
|
|
337
337
|
result = asyncio.run(_run())
|
|
338
338
|
format_output(result, ctx.obj["FORMAT"])
|
|
339
339
|
except Exception as e:
|
|
340
|
-
|
|
340
|
+
print_message(f"[red]Error uploading file:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
341
341
|
raise click.Abort()
|
|
342
342
|
|
|
343
343
|
|
|
@@ -371,11 +371,11 @@ def delete_all_files(ctx, env_id):
|
|
|
371
371
|
|
|
372
372
|
try:
|
|
373
373
|
result = asyncio.run(_run())
|
|
374
|
-
|
|
375
|
-
f"[green]All files deleted from environment {result['id']}[/green]"
|
|
374
|
+
print_message(
|
|
375
|
+
f"[green]All files deleted from environment {result['id']}[/green]", ctx.obj["FORMAT"]
|
|
376
376
|
)
|
|
377
377
|
except Exception as e:
|
|
378
|
-
|
|
378
|
+
print_message(f"[red]Error deleting files:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
379
379
|
raise click.Abort()
|
|
380
380
|
|
|
381
381
|
|
|
@@ -418,7 +418,7 @@ def remove_file(ctx, env_id, file_path):
|
|
|
418
418
|
|
|
419
419
|
try:
|
|
420
420
|
result = asyncio.run(_run())
|
|
421
|
-
|
|
421
|
+
print_message(f"[green]File removed from environment {result['id']}[/green]", ctx.obj["FORMAT"])
|
|
422
422
|
except Exception as e:
|
|
423
|
-
|
|
423
|
+
print_message(f"[red]Error removing file:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
424
424
|
raise click.Abort()
|
|
@@ -7,7 +7,7 @@ import click
|
|
|
7
7
|
from rich.console import Console
|
|
8
8
|
from testzeus_sdk import TestZeusClient
|
|
9
9
|
from testzeus_cli.config import get_client_config
|
|
10
|
-
from testzeus_cli.utils.formatters import format_output
|
|
10
|
+
from testzeus_cli.utils.formatters import format_output, print_message
|
|
11
11
|
from testzeus_cli.utils.auth import initialize_client_with_token
|
|
12
12
|
from testzeus_cli.utils.validators import parse_key_value_pairs, validate_id
|
|
13
13
|
|
|
@@ -48,10 +48,10 @@ def create(ctx, name, value):
|
|
|
48
48
|
|
|
49
49
|
try:
|
|
50
50
|
result = asyncio.run(_run())
|
|
51
|
-
|
|
51
|
+
print_message(f"[green]Tag '{result['name']}' created successfully[/green]", ctx.obj["FORMAT"])
|
|
52
52
|
format_output(result, ctx.obj["FORMAT"])
|
|
53
53
|
except Exception as e:
|
|
54
|
-
|
|
54
|
+
print_message(f"[red]Error creating tag: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
55
55
|
raise click.Abort()
|
|
56
56
|
|
|
57
57
|
|
|
@@ -88,7 +88,7 @@ def list(ctx, filters, sort, expand):
|
|
|
88
88
|
result = asyncio.run(_run())
|
|
89
89
|
format_output(result, ctx.obj["FORMAT"])
|
|
90
90
|
except Exception as e:
|
|
91
|
-
|
|
91
|
+
print_message(f"[red]Error listing tags: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
92
92
|
raise click.Abort()
|
|
93
93
|
|
|
94
94
|
|
|
@@ -118,7 +118,7 @@ def get_tags(ctx, tag_id, expand):
|
|
|
118
118
|
result = asyncio.run(_run())
|
|
119
119
|
format_output(result, ctx.obj["FORMAT"])
|
|
120
120
|
except Exception as e:
|
|
121
|
-
|
|
121
|
+
print_message(f"[red]Error getting tag: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
122
122
|
raise click.Abort()
|
|
123
123
|
|
|
124
124
|
|
|
@@ -156,15 +156,15 @@ def update_tags(ctx, tags_id, name, value):
|
|
|
156
156
|
update_tags = await client.tags.update(tag_id_validated, updates)
|
|
157
157
|
return update_tags.data
|
|
158
158
|
else:
|
|
159
|
-
|
|
159
|
+
print_message("[yellow]No updates provided[/yellow]", ctx.obj["FORMAT"])
|
|
160
160
|
return None
|
|
161
161
|
|
|
162
162
|
try:
|
|
163
163
|
result = asyncio.run(_run())
|
|
164
|
-
|
|
164
|
+
print_message(f"[green]Tag '{result['name']}' updated successfully[/green]", ctx.obj["FORMAT"])
|
|
165
165
|
format_output(result, ctx.obj["FORMAT"])
|
|
166
166
|
except Exception as e:
|
|
167
|
-
|
|
167
|
+
print_message(f"[red]Error updating tag: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
168
168
|
raise click.Abort()
|
|
169
169
|
|
|
170
170
|
|
|
@@ -190,7 +190,7 @@ def delete(ctx, name):
|
|
|
190
190
|
|
|
191
191
|
try:
|
|
192
192
|
result = asyncio.run(_run())
|
|
193
|
-
|
|
193
|
+
print_message(f"[green]Tag '{result['name']}' deleted successfully[/green]", ctx.obj["FORMAT"])
|
|
194
194
|
except Exception as e:
|
|
195
|
-
|
|
195
|
+
print_message(f"[red]Error deleting tag: {str(e)}[/red]", ctx.obj["FORMAT"])
|
|
196
196
|
raise click.Abort()
|
|
@@ -9,7 +9,7 @@ from pathlib import Path
|
|
|
9
9
|
|
|
10
10
|
from testzeus_sdk import TestZeusClient
|
|
11
11
|
from testzeus_cli.config import get_client_config
|
|
12
|
-
from testzeus_cli.utils.formatters import format_output
|
|
12
|
+
from testzeus_cli.utils.formatters import format_output, print_message
|
|
13
13
|
from testzeus_cli.utils.validators import validate_id, parse_key_value_pairs
|
|
14
14
|
from testzeus_cli.utils.auth import initialize_client_with_token
|
|
15
15
|
from pocketbase.client import FileUpload
|
|
@@ -165,7 +165,7 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
|
|
|
165
165
|
try:
|
|
166
166
|
test_data["supporting_data_files"] = FileUpload(file, open(file, "rb"))
|
|
167
167
|
except Exception as e:
|
|
168
|
-
|
|
168
|
+
print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
169
169
|
exit(1)
|
|
170
170
|
|
|
171
171
|
async with client:
|
|
@@ -179,8 +179,8 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
|
|
|
179
179
|
return new_test_data.data
|
|
180
180
|
|
|
181
181
|
result = asyncio.run(_run())
|
|
182
|
-
|
|
183
|
-
f"[green]Test data created successfully with ID: {result['id']}[/green]"
|
|
182
|
+
print_message(
|
|
183
|
+
f"[green]Test data created successfully with ID: {result['id']}[/green]", ctx.obj["FORMAT"]
|
|
184
184
|
)
|
|
185
185
|
format_output(result, ctx.obj["FORMAT"])
|
|
186
186
|
|
|
@@ -260,7 +260,7 @@ def update_test_data(ctx, test_data_id, name, type, status, data, data_file, fil
|
|
|
260
260
|
)
|
|
261
261
|
has_updates = True
|
|
262
262
|
except Exception as e:
|
|
263
|
-
|
|
263
|
+
print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
264
264
|
exit(1)
|
|
265
265
|
|
|
266
266
|
if has_updates:
|
|
@@ -269,14 +269,14 @@ def update_test_data(ctx, test_data_id, name, type, status, data, data_file, fil
|
|
|
269
269
|
)
|
|
270
270
|
return updated_data.data
|
|
271
271
|
else:
|
|
272
|
-
|
|
272
|
+
print_message("[yellow]No updates provided[/yellow]", ctx.obj["FORMAT"])
|
|
273
273
|
return None
|
|
274
274
|
|
|
275
275
|
try:
|
|
276
276
|
result = asyncio.run(_run())
|
|
277
277
|
format_output(result, ctx.obj["FORMAT"])
|
|
278
278
|
except Exception as e:
|
|
279
|
-
|
|
279
|
+
print_message(f"[red]Error updating test data:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
280
280
|
raise click.Abort()
|
|
281
281
|
|
|
282
282
|
|
|
@@ -307,11 +307,11 @@ def delete_test_data(ctx, test_data_id):
|
|
|
307
307
|
|
|
308
308
|
try:
|
|
309
309
|
result = asyncio.run(_run())
|
|
310
|
-
|
|
311
|
-
f"[green]Test data '{result['name']}' deleted successfully[/green]"
|
|
310
|
+
print_message(
|
|
311
|
+
f"[green]Test data '{result['name']}' deleted successfully[/green]", ctx.obj["FORMAT"]
|
|
312
312
|
)
|
|
313
313
|
except Exception as e:
|
|
314
|
-
|
|
314
|
+
print_message(f"[red]Failed to delete test data:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
315
315
|
exit(1)
|
|
316
316
|
|
|
317
317
|
|
|
@@ -341,7 +341,7 @@ def upload_file(ctx, test_data_id, file_path):
|
|
|
341
341
|
|
|
342
342
|
file_path_validated = Path(file_path)
|
|
343
343
|
if not file_path_validated.exists():
|
|
344
|
-
|
|
344
|
+
print_message(f"[red]File not found:[/red] {file_path}", ctx.obj["FORMAT"])
|
|
345
345
|
exit(1)
|
|
346
346
|
params = {
|
|
347
347
|
"supporting_data_files+": FileUpload(file_path, open(file_path, "rb")),
|
|
@@ -355,7 +355,7 @@ def upload_file(ctx, test_data_id, file_path):
|
|
|
355
355
|
result = asyncio.run(_run())
|
|
356
356
|
format_output(result, ctx.obj["FORMAT"])
|
|
357
357
|
except Exception as e:
|
|
358
|
-
|
|
358
|
+
print_message(f"[red]Error uploading file:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
359
359
|
raise click.Abort()
|
|
360
360
|
|
|
361
361
|
|
|
@@ -395,7 +395,7 @@ def delete_all_files(ctx, test_data_id):
|
|
|
395
395
|
result = asyncio.run(_run())
|
|
396
396
|
format_output(result, ctx.obj["FORMAT"])
|
|
397
397
|
except Exception as e:
|
|
398
|
-
|
|
398
|
+
print_message(f"[red]Error deleting all files:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
399
399
|
raise click.Abort()
|
|
400
400
|
|
|
401
401
|
|
|
@@ -438,7 +438,7 @@ def remove_file(ctx, test_data_id, file_path):
|
|
|
438
438
|
|
|
439
439
|
try:
|
|
440
440
|
result = asyncio.run(_run())
|
|
441
|
-
|
|
441
|
+
print_message(f"[green]File removed from test data {result['id']}[/green]", ctx.obj["FORMAT"])
|
|
442
442
|
except Exception as e:
|
|
443
|
-
|
|
443
|
+
print_message(f"[red]Error removing file:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
444
444
|
raise click.Abort()
|
|
@@ -11,7 +11,7 @@ from datetime import datetime
|
|
|
11
11
|
|
|
12
12
|
from testzeus_sdk import TestZeusClient
|
|
13
13
|
from testzeus_cli.config import get_client_config
|
|
14
|
-
from testzeus_cli.utils.formatters import format_output
|
|
14
|
+
from testzeus_cli.utils.formatters import format_output, print_message
|
|
15
15
|
from testzeus_cli.utils.validators import validate_id, parse_key_value_pairs
|
|
16
16
|
from testzeus_cli.utils.auth import initialize_client_with_token
|
|
17
17
|
|
|
@@ -72,8 +72,8 @@ def create_test_run(ctx, name, test, env, tag):
|
|
|
72
72
|
return test_run.data
|
|
73
73
|
|
|
74
74
|
result = asyncio.run(_run())
|
|
75
|
-
|
|
76
|
-
f"[green]Test run created and started with ID: {result['id']}[/green]"
|
|
75
|
+
print_message(
|
|
76
|
+
f"[green]Test run created and started with ID: {result['id']}[/green]", ctx.obj["FORMAT"]
|
|
77
77
|
)
|
|
78
78
|
format_output(result, ctx.obj["FORMAT"])
|
|
79
79
|
|
|
@@ -212,12 +212,12 @@ def cancel_test_run(ctx, test_run_id):
|
|
|
212
212
|
|
|
213
213
|
try:
|
|
214
214
|
result = asyncio.run(_run())
|
|
215
|
-
|
|
216
|
-
f"[green]Test run cancelled successfully: {result['name']}[/green]"
|
|
215
|
+
print_message(
|
|
216
|
+
f"[green]Test run cancelled successfully: {result['name']}[/green]", ctx.obj["FORMAT"]
|
|
217
217
|
)
|
|
218
218
|
format_output(result, ctx.obj["FORMAT"])
|
|
219
219
|
except ValueError as e:
|
|
220
|
-
|
|
220
|
+
print_message(f"[red]Failed to cancel test run:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
221
221
|
exit(1)
|
|
222
222
|
|
|
223
223
|
|
|
@@ -256,19 +256,19 @@ def watch_test_run(ctx, test_run_id, interval):
|
|
|
256
256
|
|
|
257
257
|
if test_run.is_completed():
|
|
258
258
|
progress.update(task, completed=100, total=100)
|
|
259
|
-
|
|
259
|
+
print_message("[green]Test run completed successfully![/green]", ctx.obj["FORMAT"])
|
|
260
260
|
return test_run.data
|
|
261
261
|
elif test_run.is_failed():
|
|
262
262
|
progress.update(task, completed=100, total=100)
|
|
263
|
-
|
|
263
|
+
print_message("[red]Test run failed![/red]", ctx.obj["FORMAT"])
|
|
264
264
|
return test_run.data
|
|
265
265
|
elif test_run.is_crashed():
|
|
266
266
|
progress.update(task, completed=100, total=100)
|
|
267
|
-
|
|
267
|
+
print_message("[red]Test run crashed![/red]", ctx.obj["FORMAT"])
|
|
268
268
|
return test_run.data
|
|
269
269
|
elif test_run.is_cancelled():
|
|
270
270
|
progress.update(task, completed=100, total=100)
|
|
271
|
-
|
|
271
|
+
print_message("[yellow]Test run was cancelled![/yellow]", ctx.obj["FORMAT"])
|
|
272
272
|
return test_run.data
|
|
273
273
|
|
|
274
274
|
# Sleep for the specified interval
|
|
@@ -282,10 +282,10 @@ def watch_test_run(ctx, test_run_id, interval):
|
|
|
282
282
|
if "end_time" in result and "start_time" in result
|
|
283
283
|
else None
|
|
284
284
|
)
|
|
285
|
-
|
|
285
|
+
print_message(f"Test run duration: {duration.total_seconds()} seconds", ctx.obj["FORMAT"])
|
|
286
286
|
format_output(result, ctx.obj["FORMAT"])
|
|
287
287
|
except Exception as e:
|
|
288
|
-
|
|
288
|
+
print_message(f"[red]Error watching test run:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
289
289
|
exit(1)
|
|
290
290
|
|
|
291
291
|
|
|
@@ -327,24 +327,24 @@ def download_attachments(ctx, test_run_id, output_dir):
|
|
|
327
327
|
result = asyncio.run(_run())
|
|
328
328
|
|
|
329
329
|
if not result:
|
|
330
|
-
|
|
331
|
-
"[yellow]No attachments found or downloaded for this test run[/yellow]"
|
|
330
|
+
print_message(
|
|
331
|
+
"[yellow]No attachments found or downloaded for this test run[/yellow]", ctx.obj["FORMAT"]
|
|
332
332
|
)
|
|
333
333
|
return
|
|
334
334
|
|
|
335
|
-
|
|
336
|
-
f"[green]Downloaded {len(result)} attachments to {output_dir}[/green]"
|
|
335
|
+
print_message(
|
|
336
|
+
f"[green]Downloaded {len(result)} attachments to {output_dir}[/green]", ctx.obj["FORMAT"]
|
|
337
337
|
)
|
|
338
338
|
for attachment in result:
|
|
339
|
-
|
|
339
|
+
print_message(f"- {attachment}", ctx.obj["FORMAT"])
|
|
340
340
|
except Exception as e:
|
|
341
341
|
if ctx.obj.get("VERBOSE"):
|
|
342
|
-
|
|
342
|
+
print_message("[red]Failed to download attachments:[/red]", ctx.obj["FORMAT"])
|
|
343
343
|
import traceback
|
|
344
344
|
|
|
345
|
-
|
|
345
|
+
print_message(traceback.format_exc(), ctx.obj["FORMAT"])
|
|
346
346
|
else:
|
|
347
|
-
|
|
347
|
+
print_message(f"[red]Failed to download attachments:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
348
348
|
exit(1)
|
|
349
349
|
|
|
350
350
|
|
|
@@ -381,3 +381,108 @@ def get_test_run_status(ctx, test_run_id):
|
|
|
381
381
|
|
|
382
382
|
result = asyncio.run(_run())
|
|
383
383
|
format_output(result, ctx.obj["FORMAT"])
|
|
384
|
+
|
|
385
|
+
@test_runs_group.command(name="get-ctrf-report")
|
|
386
|
+
@click.argument("test_run_ids_or_names")
|
|
387
|
+
@click.option("--filename", default="ctrf_report.json", help="Filename to save the report")
|
|
388
|
+
@click.option("--include-attachments", is_flag=False, help="Include attachments in the report")
|
|
389
|
+
@click.option("--include-environment", is_flag=False, help="Include environments in the report")
|
|
390
|
+
@click.pass_context
|
|
391
|
+
def get_ctrf_report(ctx, test_run_ids_or_names, filename, include_attachments, include_environment):
|
|
392
|
+
"""Get the CTRF report for a test run by providing a comma separated string of test run IDs or names"""
|
|
393
|
+
|
|
394
|
+
async def _run():
|
|
395
|
+
config, token, _, _ = get_client_config(
|
|
396
|
+
ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL")
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
client = TestZeusClient(**config)
|
|
400
|
+
from testzeus_sdk.utils import CTRFReporter
|
|
401
|
+
ctrf_reporter = CTRFReporter(client=client)
|
|
402
|
+
|
|
403
|
+
async with client:
|
|
404
|
+
if token:
|
|
405
|
+
initialize_client_with_token(client, token)
|
|
406
|
+
else:
|
|
407
|
+
await client.ensure_authenticated()
|
|
408
|
+
|
|
409
|
+
test_runs = test_run_ids_or_names.split(",")
|
|
410
|
+
|
|
411
|
+
result = await ctrf_reporter.generate_and_save_report_from_multiple_runs(
|
|
412
|
+
test_run_ids_or_names=test_runs,
|
|
413
|
+
filename=filename,
|
|
414
|
+
include_attachments=include_attachments,
|
|
415
|
+
include_environment=include_environment
|
|
416
|
+
)
|
|
417
|
+
return {
|
|
418
|
+
"message": "CTRF report generated successfully",
|
|
419
|
+
"report_path": result
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
result = asyncio.run(_run())
|
|
423
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
@test_runs_group.command(name="run-multiple-tests-and-generate-ctrf")
|
|
427
|
+
@click.argument("test_ids_or_names")
|
|
428
|
+
@click.option("--mode", default="lenient", help="Mode to run the tests in (lenient or strict)")
|
|
429
|
+
@click.option("--interval", default=30, help="Interval to check the test run status in seconds")
|
|
430
|
+
@click.option("--filename", default="ctrf_report.json", help="Filename to save the report")
|
|
431
|
+
@click.pass_context
|
|
432
|
+
def run_multiple_tests_and_generate_ctrf(ctx, test_ids_or_names, mode, interval, filename):
|
|
433
|
+
"""Run multiple tests in parallel using comma separated string of test IDs or names"""
|
|
434
|
+
|
|
435
|
+
async def _run():
|
|
436
|
+
config, token, tenant_id, user_id = get_client_config(
|
|
437
|
+
ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL")
|
|
438
|
+
)
|
|
439
|
+
client = TestZeusClient(**config)
|
|
440
|
+
|
|
441
|
+
async with client:
|
|
442
|
+
if token:
|
|
443
|
+
initialize_client_with_token(client, token)
|
|
444
|
+
else:
|
|
445
|
+
await client.ensure_authenticated()
|
|
446
|
+
|
|
447
|
+
test_ids = test_ids_or_names.split(",")
|
|
448
|
+
|
|
449
|
+
if ctx.obj.get("VERBOSE"):
|
|
450
|
+
console.print(f"[blue]Running tests: {test_ids}[/blue]")
|
|
451
|
+
console.print(f"[blue]Mode: {mode}, Interval: {interval}s, Filename: {filename}[/blue]")
|
|
452
|
+
|
|
453
|
+
test_runs_list, report_path = await client.test_runs.run_multiple_tests_and_generate_ctrf_report(
|
|
454
|
+
test_ids = test_ids,
|
|
455
|
+
tenant = tenant_id,
|
|
456
|
+
modified_by = user_id,
|
|
457
|
+
execution_mode = mode,
|
|
458
|
+
ctrf_filename = filename,
|
|
459
|
+
interval = interval
|
|
460
|
+
)
|
|
461
|
+
|
|
462
|
+
return {
|
|
463
|
+
"test_runs": test_runs_list,
|
|
464
|
+
"report_path": report_path,
|
|
465
|
+
"message": f"Successfully ran {len(test_runs_list)} tests and generated CTRF report",
|
|
466
|
+
"status": "success"
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
try:
|
|
470
|
+
result = asyncio.run(_run())
|
|
471
|
+
print_message(
|
|
472
|
+
f"[green]{result['message']}[/green]", ctx.obj["FORMAT"]
|
|
473
|
+
)
|
|
474
|
+
print_message(
|
|
475
|
+
f"[green]Report saved to: {result['report_path']}[/green]", ctx.obj["FORMAT"]
|
|
476
|
+
)
|
|
477
|
+
format_output(result, ctx.obj["FORMAT"])
|
|
478
|
+
except Exception as e:
|
|
479
|
+
if ctx.obj.get("VERBOSE"):
|
|
480
|
+
print_message("[red]Failed to run tests and generate CTRF report:[/red]", ctx.obj["FORMAT"])
|
|
481
|
+
import traceback
|
|
482
|
+
print_message(traceback.format_exc(), ctx.obj["FORMAT"])
|
|
483
|
+
else:
|
|
484
|
+
print_message(f"[red]Failed to run tests and generate CTRF report:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
485
|
+
exit(1)
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
@@ -9,7 +9,7 @@ from rich.console import Console
|
|
|
9
9
|
|
|
10
10
|
from testzeus_sdk import TestZeusClient
|
|
11
11
|
from testzeus_cli.config import get_client_config
|
|
12
|
-
from testzeus_cli.utils.formatters import format_output
|
|
12
|
+
from testzeus_cli.utils.formatters import format_output, print_message
|
|
13
13
|
from testzeus_cli.utils.validators import validate_id, parse_key_value_pairs
|
|
14
14
|
from testzeus_cli.utils.client import run_client_operation
|
|
15
15
|
from testzeus_cli.utils.auth import initialize_client_with_token
|
|
@@ -170,7 +170,7 @@ def create_test(
|
|
|
170
170
|
return new_test.data
|
|
171
171
|
|
|
172
172
|
result = asyncio.run(_run())
|
|
173
|
-
|
|
173
|
+
print_message(f"[green]Test created successfully with ID: {result['id']}[/green]", ctx.obj["FORMAT"])
|
|
174
174
|
format_output(result, ctx.obj["FORMAT"])
|
|
175
175
|
|
|
176
176
|
|
|
@@ -248,7 +248,7 @@ def update_test(
|
|
|
248
248
|
has_updates = True
|
|
249
249
|
|
|
250
250
|
if not has_updates:
|
|
251
|
-
|
|
251
|
+
print_message("[yellow]No updates provided[/yellow]", ctx.obj["FORMAT"])
|
|
252
252
|
return None
|
|
253
253
|
|
|
254
254
|
if ctx.obj.get("VERBOSE"):
|
|
@@ -260,16 +260,16 @@ def update_test(
|
|
|
260
260
|
try:
|
|
261
261
|
result = asyncio.run(_run())
|
|
262
262
|
if result:
|
|
263
|
-
|
|
263
|
+
print_message(f"[green]Test updated successfully: {result['name']}[/green]", ctx.obj["FORMAT"])
|
|
264
264
|
format_output(result, ctx.obj["FORMAT"])
|
|
265
265
|
except Exception as e:
|
|
266
266
|
if ctx.obj.get("VERBOSE"):
|
|
267
|
-
|
|
267
|
+
print_message("[red]Error updating test:[/red]", ctx.obj["FORMAT"])
|
|
268
268
|
import traceback
|
|
269
269
|
|
|
270
|
-
|
|
270
|
+
print_message(traceback.format_exc(), ctx.obj["FORMAT"])
|
|
271
271
|
else:
|
|
272
|
-
|
|
272
|
+
print_message(f"[red]Error updating test:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
273
273
|
exit(1)
|
|
274
274
|
|
|
275
275
|
|
|
@@ -300,7 +300,7 @@ def delete_test(ctx, test_id):
|
|
|
300
300
|
|
|
301
301
|
try:
|
|
302
302
|
result = asyncio.run(_run())
|
|
303
|
-
|
|
303
|
+
print_message(f"[green]Test deleted successfully: {result['id']}[/green]", ctx.obj["FORMAT"])
|
|
304
304
|
except Exception as e:
|
|
305
|
-
|
|
305
|
+
print_message(f"[red]Error deleting test:[/red] {str(e)}", ctx.obj["FORMAT"])
|
|
306
306
|
exit(1)
|
|
@@ -29,7 +29,8 @@ def format_output(data: Any, format_type: str = "table") -> None:
|
|
|
29
29
|
format_type: Output format type ("table", "json", or "yaml")
|
|
30
30
|
"""
|
|
31
31
|
if format_type == "json":
|
|
32
|
-
|
|
32
|
+
# Use regular print() for JSON to avoid Rich console formatting that can corrupt JSON
|
|
33
|
+
print(json.dumps(data, indent=2, default=format_object_for_json))
|
|
33
34
|
elif format_type == "yaml":
|
|
34
35
|
console.print(yaml.dump(data, sort_keys=False, default_flow_style=False))
|
|
35
36
|
else: # table format
|
|
@@ -54,16 +55,46 @@ def format_object_for_json(obj: Any) -> Any:
|
|
|
54
55
|
"""
|
|
55
56
|
# If the object has a data property (like SDK models)
|
|
56
57
|
if hasattr(obj, "data") and isinstance(obj.data, dict):
|
|
57
|
-
return obj.data
|
|
58
|
+
return _ensure_json_serializable(obj.data)
|
|
58
59
|
|
|
59
60
|
# If the object has __dict__
|
|
60
61
|
if hasattr(obj, "__dict__"):
|
|
61
|
-
return obj.__dict__
|
|
62
|
+
return _ensure_json_serializable(obj.__dict__)
|
|
62
63
|
|
|
63
64
|
# Default to string representation
|
|
64
65
|
return str(obj)
|
|
65
66
|
|
|
66
67
|
|
|
68
|
+
def _ensure_json_serializable(obj: Any) -> Any:
|
|
69
|
+
"""
|
|
70
|
+
Recursively ensure an object is JSON serializable
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
obj: Object to make JSON serializable
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
JSON serializable representation
|
|
77
|
+
"""
|
|
78
|
+
if isinstance(obj, dict):
|
|
79
|
+
return {key: _ensure_json_serializable(value) for key, value in obj.items()}
|
|
80
|
+
elif isinstance(obj, (list, tuple)):
|
|
81
|
+
return [_ensure_json_serializable(item) for item in obj]
|
|
82
|
+
elif isinstance(obj, str):
|
|
83
|
+
# Ensure proper string handling - strings should be returned as-is
|
|
84
|
+
# Python's json.dumps will handle proper escaping
|
|
85
|
+
return obj
|
|
86
|
+
elif isinstance(obj, (int, float, bool)) or obj is None:
|
|
87
|
+
# Primitives that are JSON serializable
|
|
88
|
+
return obj
|
|
89
|
+
elif hasattr(obj, "data") and isinstance(obj.data, dict):
|
|
90
|
+
return _ensure_json_serializable(obj.data)
|
|
91
|
+
elif hasattr(obj, "__dict__"):
|
|
92
|
+
return _ensure_json_serializable(obj.__dict__)
|
|
93
|
+
else:
|
|
94
|
+
# Convert everything else to string
|
|
95
|
+
return str(obj)
|
|
96
|
+
|
|
97
|
+
|
|
67
98
|
def format_value_for_display(value: Any) -> str:
|
|
68
99
|
"""
|
|
69
100
|
Format a value for display in table output
|
|
@@ -288,3 +319,28 @@ def format_list_as_table(data: List[Any], title: Optional[str] = None) -> None:
|
|
|
288
319
|
table.add_row(str(item))
|
|
289
320
|
|
|
290
321
|
console.print(table)
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def should_print_message(format_type: str) -> bool:
|
|
325
|
+
"""
|
|
326
|
+
Check if messages should be printed based on format type.
|
|
327
|
+
|
|
328
|
+
Args:
|
|
329
|
+
format_type: Output format type ("table", "json", or "yaml")
|
|
330
|
+
|
|
331
|
+
Returns:
|
|
332
|
+
True if messages should be printed, False if format is json
|
|
333
|
+
"""
|
|
334
|
+
return format_type != "json"
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def print_message(message: str, format_type: str) -> None:
|
|
338
|
+
"""
|
|
339
|
+
Print a message only if the format is not json.
|
|
340
|
+
|
|
341
|
+
Args:
|
|
342
|
+
message: Message to print
|
|
343
|
+
format_type: Output format type
|
|
344
|
+
"""
|
|
345
|
+
if should_print_message(format_type):
|
|
346
|
+
console.print(message)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|