testzeus-cli 0.0.11__tar.gz → 0.0.13__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.
Files changed (19) hide show
  1. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/PKG-INFO +2 -2
  2. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/pyproject.toml +3 -3
  3. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/commands/environments.py +21 -20
  4. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/commands/tags.py +10 -10
  5. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/commands/test_data.py +16 -15
  6. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/commands/test_runs.py +124 -20
  7. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/commands/tests.py +11 -9
  8. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/utils/formatters.py +59 -3
  9. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/LICENSE +0 -0
  10. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/README.md +0 -0
  11. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/__init__.py +0 -0
  12. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/auth.py +0 -0
  13. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/cli.py +0 -0
  14. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/commands/__init__.py +0 -0
  15. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/config.py +0 -0
  16. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/utils/__init__.py +0 -0
  17. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/utils/auth.py +0 -0
  18. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/testzeus_cli/utils/client.py +0 -0
  19. {testzeus_cli-0.0.11 → testzeus_cli-0.0.13}/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.11
3
+ Version: 0.0.13
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.11,<0.0.12)
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.11"
7
+ version = "0.0.13"
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.11"
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
 
@@ -93,6 +93,7 @@ def create(ctx, name, status, data, data_file, tags, file):
93
93
  "status": status,
94
94
  "tenant": stored_tenant_id,
95
95
  "modified_by": stored_user_id,
96
+ "metadata": {},
96
97
  }
97
98
 
98
99
  if data_content:
@@ -105,7 +106,7 @@ def create(ctx, name, status, data, data_file, tags, file):
105
106
  try:
106
107
  params["supporting_data_files"] = FileUpload(file, open(file, "rb"))
107
108
  except Exception as e:
108
- console.print(f"[red]Error reading file:[/red] {str(e)}")
109
+ print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
109
110
  exit(1)
110
111
 
111
112
  env = await client.environments.create(params)
@@ -113,12 +114,12 @@ def create(ctx, name, status, data, data_file, tags, file):
113
114
 
114
115
  try:
115
116
  result = asyncio.run(_run())
116
- console.print(
117
- 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"]
118
119
  )
119
120
  format_output(result, ctx.obj["FORMAT"])
120
121
  except Exception as e:
121
- console.print(f"[red]Error creating environment: {str(e)}[/red]")
122
+ print_message(f"[red]Error creating environment: {str(e)}[/red]", ctx.obj["FORMAT"])
122
123
  raise click.Abort()
123
124
 
124
125
 
@@ -152,7 +153,7 @@ def list(ctx, filters, sort, expand):
152
153
  result = asyncio.run(_run())
153
154
  format_output(result, ctx.obj["FORMAT"])
154
155
  except Exception as e:
155
- console.print(f"[red]Error listing environments: {str(e)}[/red]")
156
+ print_message(f"[red]Error listing environments: {str(e)}[/red]", ctx.obj["FORMAT"])
156
157
  raise click.Abort()
157
158
 
158
159
 
@@ -177,9 +178,9 @@ def delete(ctx, env_id):
177
178
 
178
179
  try:
179
180
  result = asyncio.run(_run())
180
- console.print(f"[green]Environment {result['id']} deleted successfully[/green]")
181
+ print_message(f"[green]Environment {result['id']} deleted successfully[/green]", ctx.obj["FORMAT"])
181
182
  except Exception as e:
182
- console.print(f"[red]Error deleting environment: {str(e)}[/red]")
183
+ print_message(f"[red]Error deleting environment: {str(e)}[/red]", ctx.obj["FORMAT"])
183
184
  raise click.Abort()
184
185
 
185
186
 
@@ -207,7 +208,7 @@ def get(ctx, env_id, expand):
207
208
  result = asyncio.run(_run())
208
209
  format_output(result, ctx.obj["FORMAT"])
209
210
  except Exception as e:
210
- console.print(f"[red]Error getting environment: {str(e)}[/red]")
211
+ print_message(f"[red]Error getting environment: {str(e)}[/red]", ctx.obj["FORMAT"])
211
212
  raise click.Abort()
212
213
 
213
214
 
@@ -282,22 +283,22 @@ def update(ctx, env_id, name, status, data, data_file, tags, file):
282
283
  file, open(file, "rb")
283
284
  )
284
285
  except Exception as e:
285
- console.print(f"[red]Error reading file:[/red] {str(e)}")
286
+ print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
286
287
  exit(1)
287
288
 
288
289
  if has_updates:
289
290
  updated_env = await client.environments.update(env_id, updates)
290
291
  return updated_env.data
291
292
  else:
292
- console.print("[yellow]No updates provided[/yellow]")
293
+ print_message("[yellow]No updates provided[/yellow]", ctx.obj["FORMAT"])
293
294
  return None
294
295
 
295
296
  try:
296
297
  result = asyncio.run(_run())
297
- console.print("[green]Environment updated successfully[/green]")
298
+ print_message("[green]Environment updated successfully[/green]", ctx.obj["FORMAT"])
298
299
  format_output(result, ctx.obj["FORMAT"])
299
300
  except Exception as e:
300
- console.print(f"[red]Error updating environment: {str(e)}[/red]")
301
+ print_message(f"[red]Error updating environment: {str(e)}[/red]", ctx.obj["FORMAT"])
301
302
  raise click.Abort()
302
303
 
303
304
 
@@ -322,7 +323,7 @@ def upload_file(ctx, env_id, file_path):
322
323
  await client.ensure_authenticated()
323
324
  file_path_validated = Path(file_path)
324
325
  if not file_path_validated.exists():
325
- console.print(f"[red]File not found:[/red] {file_path}")
326
+ print_message(f"[red]File not found:[/red] {file_path}", ctx.obj["FORMAT"])
326
327
  exit(1)
327
328
  params = {
328
329
  "supporting_data_files+": FileUpload(file_path, open(file_path, "rb")),
@@ -336,7 +337,7 @@ def upload_file(ctx, env_id, file_path):
336
337
  result = asyncio.run(_run())
337
338
  format_output(result, ctx.obj["FORMAT"])
338
339
  except Exception as e:
339
- console.print(f"[red]Error uploading file:[/red] {str(e)}")
340
+ print_message(f"[red]Error uploading file:[/red] {str(e)}", ctx.obj["FORMAT"])
340
341
  raise click.Abort()
341
342
 
342
343
 
@@ -370,11 +371,11 @@ def delete_all_files(ctx, env_id):
370
371
 
371
372
  try:
372
373
  result = asyncio.run(_run())
373
- console.print(
374
- 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"]
375
376
  )
376
377
  except Exception as e:
377
- console.print(f"[red]Error deleting files:[/red] {str(e)}")
378
+ print_message(f"[red]Error deleting files:[/red] {str(e)}", ctx.obj["FORMAT"])
378
379
  raise click.Abort()
379
380
 
380
381
 
@@ -417,7 +418,7 @@ def remove_file(ctx, env_id, file_path):
417
418
 
418
419
  try:
419
420
  result = asyncio.run(_run())
420
- console.print(f"[green]File removed from environment {result['id']}[/green]")
421
+ print_message(f"[green]File removed from environment {result['id']}[/green]", ctx.obj["FORMAT"])
421
422
  except Exception as e:
422
- console.print(f"[red]Error removing file:[/red] {str(e)}")
423
+ print_message(f"[red]Error removing file:[/red] {str(e)}", ctx.obj["FORMAT"])
423
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
- console.print(f"[green]Tag '{result['name']}' created successfully[/green]")
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
- console.print(f"[red]Error creating tag: {str(e)}[/red]")
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
- console.print(f"[red]Error listing tags: {str(e)}[/red]")
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
- console.print(f"[red]Error getting tag: {str(e)}[/red]")
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
- console.print("[yellow]No updates provided[/yellow]")
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
- console.print(f"[green]Tag '{result['name']}' updated successfully[/green]")
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
- console.print(f"[red]Error updating tag: {str(e)}[/red]")
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
- console.print(f"[green]Tag '{result['name']}' deleted successfully[/green]")
193
+ print_message(f"[green]Tag '{result['name']}' deleted successfully[/green]", ctx.obj["FORMAT"])
194
194
  except Exception as e:
195
- console.print(f"[red]Error deleting tag: {str(e)}[/red]")
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
@@ -153,6 +153,7 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
153
153
  "data": data_content,
154
154
  "tenant": tenant_id,
155
155
  "modified_by": user_id,
156
+ "metadata": {},
156
157
  }
157
158
 
158
159
  # Add data content if provided directly
@@ -164,7 +165,7 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
164
165
  try:
165
166
  test_data["supporting_data_files"] = FileUpload(file, open(file, "rb"))
166
167
  except Exception as e:
167
- console.print(f"[red]Error reading file:[/red] {str(e)}")
168
+ print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
168
169
  exit(1)
169
170
 
170
171
  async with client:
@@ -178,8 +179,8 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
178
179
  return new_test_data.data
179
180
 
180
181
  result = asyncio.run(_run())
181
- console.print(
182
- 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"]
183
184
  )
184
185
  format_output(result, ctx.obj["FORMAT"])
185
186
 
@@ -259,7 +260,7 @@ def update_test_data(ctx, test_data_id, name, type, status, data, data_file, fil
259
260
  )
260
261
  has_updates = True
261
262
  except Exception as e:
262
- console.print(f"[red]Error reading file:[/red] {str(e)}")
263
+ print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
263
264
  exit(1)
264
265
 
265
266
  if has_updates:
@@ -268,14 +269,14 @@ def update_test_data(ctx, test_data_id, name, type, status, data, data_file, fil
268
269
  )
269
270
  return updated_data.data
270
271
  else:
271
- console.print("[yellow]No updates provided[/yellow]")
272
+ print_message("[yellow]No updates provided[/yellow]", ctx.obj["FORMAT"])
272
273
  return None
273
274
 
274
275
  try:
275
276
  result = asyncio.run(_run())
276
277
  format_output(result, ctx.obj["FORMAT"])
277
278
  except Exception as e:
278
- console.print(f"[red]Error updating test data:[/red] {str(e)}")
279
+ print_message(f"[red]Error updating test data:[/red] {str(e)}", ctx.obj["FORMAT"])
279
280
  raise click.Abort()
280
281
 
281
282
 
@@ -306,11 +307,11 @@ def delete_test_data(ctx, test_data_id):
306
307
 
307
308
  try:
308
309
  result = asyncio.run(_run())
309
- console.print(
310
- 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"]
311
312
  )
312
313
  except Exception as e:
313
- console.print(f"[red]Failed to delete test data:[/red] {str(e)}")
314
+ print_message(f"[red]Failed to delete test data:[/red] {str(e)}", ctx.obj["FORMAT"])
314
315
  exit(1)
315
316
 
316
317
 
@@ -340,7 +341,7 @@ def upload_file(ctx, test_data_id, file_path):
340
341
 
341
342
  file_path_validated = Path(file_path)
342
343
  if not file_path_validated.exists():
343
- console.print(f"[red]File not found:[/red] {file_path}")
344
+ print_message(f"[red]File not found:[/red] {file_path}", ctx.obj["FORMAT"])
344
345
  exit(1)
345
346
  params = {
346
347
  "supporting_data_files+": FileUpload(file_path, open(file_path, "rb")),
@@ -354,7 +355,7 @@ def upload_file(ctx, test_data_id, file_path):
354
355
  result = asyncio.run(_run())
355
356
  format_output(result, ctx.obj["FORMAT"])
356
357
  except Exception as e:
357
- console.print(f"[red]Error uploading file:[/red] {str(e)}")
358
+ print_message(f"[red]Error uploading file:[/red] {str(e)}", ctx.obj["FORMAT"])
358
359
  raise click.Abort()
359
360
 
360
361
 
@@ -394,7 +395,7 @@ def delete_all_files(ctx, test_data_id):
394
395
  result = asyncio.run(_run())
395
396
  format_output(result, ctx.obj["FORMAT"])
396
397
  except Exception as e:
397
- console.print(f"[red]Error deleting all files:[/red] {str(e)}")
398
+ print_message(f"[red]Error deleting all files:[/red] {str(e)}", ctx.obj["FORMAT"])
398
399
  raise click.Abort()
399
400
 
400
401
 
@@ -437,7 +438,7 @@ def remove_file(ctx, test_data_id, file_path):
437
438
 
438
439
  try:
439
440
  result = asyncio.run(_run())
440
- console.print(f"[green]File removed from test data {result['id']}[/green]")
441
+ print_message(f"[green]File removed from test data {result['id']}[/green]", ctx.obj["FORMAT"])
441
442
  except Exception as e:
442
- console.print(f"[red]Error removing file:[/red] {str(e)}")
443
+ print_message(f"[red]Error removing file:[/red] {str(e)}", ctx.obj["FORMAT"])
443
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
- console.print(
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
- console.print(
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
- console.print(f"[red]Failed to cancel test run:[/red] {str(e)}")
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
- console.print("[green]Test run completed successfully![/green]")
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
- console.print("[red]Test run failed![/red]")
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
- console.print("[red]Test run crashed![/red]")
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
- console.print("[yellow]Test run was cancelled![/yellow]")
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
- console.print(f"Test run duration: {duration.total_seconds()} seconds")
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
- console.print(f"[red]Error watching test run:[/red] {str(e)}")
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
- console.print(
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
- console.print(
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
- console.print(f"- {attachment}")
339
+ print_message(f"- {attachment}", ctx.obj["FORMAT"])
340
340
  except Exception as e:
341
341
  if ctx.obj.get("VERBOSE"):
342
- console.print("[red]Failed to download attachments:[/red]")
342
+ print_message("[red]Failed to download attachments:[/red]", ctx.obj["FORMAT"])
343
343
  import traceback
344
344
 
345
- console.print(traceback.format_exc())
345
+ print_message(traceback.format_exc(), ctx.obj["FORMAT"])
346
346
  else:
347
- console.print(f"[red]Failed to download attachments:[/red] {str(e)}")
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,107 @@ 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
+ "status": "success"
466
+ }
467
+
468
+ try:
469
+ result = asyncio.run(_run())
470
+ print_message(
471
+ f"[green]{result['message']}[/green]", ctx.obj["FORMAT"]
472
+ )
473
+ print_message(
474
+ f"[green]Report saved to: {result['report_path']}[/green]", ctx.obj["FORMAT"]
475
+ )
476
+ format_output(result, ctx.obj["FORMAT"])
477
+ except Exception as e:
478
+ if ctx.obj.get("VERBOSE"):
479
+ print_message("[red]Failed to run tests and generate CTRF report:[/red]", ctx.obj["FORMAT"])
480
+ import traceback
481
+ print_message(traceback.format_exc(), ctx.obj["FORMAT"])
482
+ else:
483
+ print_message(f"[red]Failed to run tests and generate CTRF report:[/red] {str(e)}", ctx.obj["FORMAT"])
484
+ exit(1)
485
+
486
+
487
+
@@ -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
@@ -139,6 +139,8 @@ def create_test(
139
139
  "execution_mode": execution_mode,
140
140
  "tenant": stored_tenant_id,
141
141
  "modified_by": stored_user_id,
142
+ "metadata": {},
143
+ "test_params": {},
142
144
  }
143
145
 
144
146
  # Always set feature content as text
@@ -168,7 +170,7 @@ def create_test(
168
170
  return new_test.data
169
171
 
170
172
  result = asyncio.run(_run())
171
- console.print(f"[green]Test created successfully with ID: {result['id']}[/green]")
173
+ print_message(f"[green]Test created successfully with ID: {result['id']}[/green]", ctx.obj["FORMAT"])
172
174
  format_output(result, ctx.obj["FORMAT"])
173
175
 
174
176
 
@@ -246,7 +248,7 @@ def update_test(
246
248
  has_updates = True
247
249
 
248
250
  if not has_updates:
249
- console.print("[yellow]No updates provided[/yellow]")
251
+ print_message("[yellow]No updates provided[/yellow]", ctx.obj["FORMAT"])
250
252
  return None
251
253
 
252
254
  if ctx.obj.get("VERBOSE"):
@@ -258,16 +260,16 @@ def update_test(
258
260
  try:
259
261
  result = asyncio.run(_run())
260
262
  if result:
261
- console.print(f"[green]Test updated successfully: {result['name']}[/green]")
263
+ print_message(f"[green]Test updated successfully: {result['name']}[/green]", ctx.obj["FORMAT"])
262
264
  format_output(result, ctx.obj["FORMAT"])
263
265
  except Exception as e:
264
266
  if ctx.obj.get("VERBOSE"):
265
- console.print("[red]Error updating test:[/red]")
267
+ print_message("[red]Error updating test:[/red]", ctx.obj["FORMAT"])
266
268
  import traceback
267
269
 
268
- console.print(traceback.format_exc())
270
+ print_message(traceback.format_exc(), ctx.obj["FORMAT"])
269
271
  else:
270
- console.print(f"[red]Error updating test:[/red] {str(e)}")
272
+ print_message(f"[red]Error updating test:[/red] {str(e)}", ctx.obj["FORMAT"])
271
273
  exit(1)
272
274
 
273
275
 
@@ -298,7 +300,7 @@ def delete_test(ctx, test_id):
298
300
 
299
301
  try:
300
302
  result = asyncio.run(_run())
301
- console.print(f"[green]Test deleted successfully: {result['id']}[/green]")
303
+ print_message(f"[green]Test deleted successfully: {result['id']}[/green]", ctx.obj["FORMAT"])
302
304
  except Exception as e:
303
- console.print(f"[red]Error deleting test:[/red] {str(e)}")
305
+ print_message(f"[red]Error deleting test:[/red] {str(e)}", ctx.obj["FORMAT"])
304
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
- console.print(json.dumps(data, indent=2, default=format_object_for_json))
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