testzeus-cli 0.0.20__tar.gz → 0.0.21__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 (35) hide show
  1. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/PKG-INFO +2 -2
  2. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/pyproject.toml +2 -2
  3. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/cli.py +2 -0
  4. testzeus_cli-0.0.21/testzeus_cli/commands/device_pool.py +106 -0
  5. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/environments.py +244 -33
  6. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/test_data.py +27 -23
  7. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/tests.py +34 -6
  8. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/tests_ai_generator.py +17 -1
  9. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/LICENSE +0 -0
  10. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/README.md +0 -0
  11. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/__init__.py +0 -0
  12. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/auth.py +0 -0
  13. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/__init__.py +0 -0
  14. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/daemon.py +0 -0
  15. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/extensions.py +0 -0
  16. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/hypermind_code_blocks.py +0 -0
  17. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/knowledge_bases.py +0 -0
  18. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/notification_channels.py +0 -0
  19. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/tags.py +0 -0
  20. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/test_report_schedules.py +0 -0
  21. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/test_run_groups.py +0 -0
  22. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/test_runs.py +0 -0
  23. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/test_suite_node_runs.py +0 -0
  24. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/test_suite_runs.py +0 -0
  25. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/test_suite_schedules.py +0 -0
  26. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/test_suites.py +0 -0
  27. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/tests_authoring.py +0 -0
  28. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/commands/user_integrations.py +0 -0
  29. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/config.py +0 -0
  30. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/utils/__init__.py +0 -0
  31. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/utils/auth.py +0 -0
  32. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/utils/client.py +0 -0
  33. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/utils/formatters.py +0 -0
  34. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/utils/profile.py +0 -0
  35. {testzeus_cli-0.0.20 → testzeus_cli-0.0.21}/testzeus_cli/utils/validators.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testzeus-cli
3
- Version: 0.0.20
3
+ Version: 0.0.21
4
4
  Summary: Command-line interface for TestZeus testing platform
5
5
  License-File: LICENSE
6
6
  Author: Shriyansh Agnihotri
@@ -22,7 +22,7 @@ Requires-Dist: pocketbase (>=0.15.0,<0.16.0)
22
22
  Requires-Dist: pydantic (>=2.0.0,<3.0.0)
23
23
  Requires-Dist: pyyaml (>=6.0,<7.0)
24
24
  Requires-Dist: rich (>=13.3.1,<14.0.0)
25
- Requires-Dist: testzeus-sdk (>=0.0.19,<0.0.20)
25
+ Requires-Dist: testzeus-sdk (>=0.0.19,<0.1.0)
26
26
  Requires-Dist: toml (>=0.10.2,<0.11.0)
27
27
  Project-URL: Repository, https://github.com/test-zeus-ai/testzeus-cli
28
28
  Description-Content-Type: text/markdown
@@ -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.20"
7
+ version = "0.0.21"
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.19"
25
+ testzeus-sdk = ">=0.0.19,<0.1.0"
26
26
  pocketbase = "^0.15.0"
27
27
  toml = "^0.10.2"
28
28
  aiohttp = "3.13.4"
@@ -25,6 +25,7 @@ from testzeus_cli.commands.test_suites import test_suites_group
25
25
  from testzeus_cli.commands.test_run_groups import test_run_groups_group
26
26
  from testzeus_cli.commands.test_data import test_data_group
27
27
  from testzeus_cli.commands.tags import tags_group
28
+ from testzeus_cli.commands.device_pool import device_pool_group
28
29
  from testzeus_cli.commands.environments import environments_group
29
30
  from testzeus_cli.commands.test_report_schedules import test_report_schedules_group
30
31
  from testzeus_cli.commands.notification_channels import notification_channels_group
@@ -89,6 +90,7 @@ cli.add_command(test_suite_schedules_group)
89
90
  cli.add_command(test_run_groups_group)
90
91
  cli.add_command(test_data_group)
91
92
  cli.add_command(tags_group)
93
+ cli.add_command(device_pool_group)
92
94
  cli.add_command(environments_group)
93
95
  cli.add_command(test_report_schedules_group)
94
96
  cli.add_command(notification_channels_group)
@@ -0,0 +1,106 @@
1
+ """
2
+ Device pool commands for TestZeus CLI.
3
+
4
+ Device pool is read-only -- only list and get operations are supported.
5
+ """
6
+
7
+ import asyncio
8
+ import click
9
+ from rich.console import Console
10
+
11
+ from testzeus_sdk import TestZeusClient
12
+ from testzeus_cli.config import get_client_config
13
+ from testzeus_cli.utils.formatters import format_output, print_message
14
+ from testzeus_cli.utils.validators import validate_id, parse_key_value_pairs
15
+ from testzeus_cli.utils.auth import initialize_client_with_token
16
+
17
+ console = Console()
18
+
19
+
20
+ @click.group(name="device-pool")
21
+ def device_pool_group():
22
+ """Browse available devices in the device pool (read-only)"""
23
+ pass
24
+
25
+
26
+ @device_pool_group.command(name="list")
27
+ @click.option(
28
+ "--filters", "-f", multiple=True, help="Filter results (format: key=value, e.g. platform=android)"
29
+ )
30
+ @click.option("--sort", help="Sort by field (e.g. device_name, -platform_version)")
31
+ @click.option("--page", default=1, help="Page number")
32
+ @click.option("--per-page", default=50, help="Items per page")
33
+ @click.pass_context
34
+ def list_devices(ctx, filters, sort, page, per_page):
35
+ """List available devices in the pool"""
36
+
37
+ async def _run():
38
+ config, token, _, _ = get_client_config(
39
+ ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL")
40
+ )
41
+ client = TestZeusClient(**config)
42
+
43
+ filter_dict = parse_key_value_pairs(filters) if filters else {}
44
+
45
+ async with client:
46
+ if token:
47
+ initialize_client_with_token(client, token)
48
+ else:
49
+ await client.ensure_authenticated()
50
+
51
+ result = await client.device_pool.get_list(
52
+ sort=sort, filters=filter_dict, page=page, per_page=per_page
53
+ )
54
+ items = result.get("items", [])
55
+ shaped_items = []
56
+ for device in items:
57
+ d = device.data if hasattr(device, "data") else device
58
+ shaped_items.append({
59
+ "id": d.get("id"),
60
+ "name": d.get("device_name"),
61
+ "platform": d.get("platform"),
62
+ "platform_version": d.get("platform_version"),
63
+ "cloud_provider": d.get("cloud_provider"),
64
+ "device_type": d.get("device_type"),
65
+ "status": "active" if d.get("is_active") else "inactive",
66
+ })
67
+ result["items"] = shaped_items
68
+ return result
69
+
70
+ try:
71
+ result = asyncio.run(_run())
72
+ format_output(result, ctx.obj["FORMAT"])
73
+ except Exception as e:
74
+ print_message(f"[red]Error listing devices: {str(e)}[/red]", ctx.obj["FORMAT"])
75
+ raise click.Abort()
76
+
77
+
78
+ @device_pool_group.command(name="get")
79
+ @click.argument("device_id")
80
+ @click.pass_context
81
+ def get_device(ctx, device_id):
82
+ """Get a device by ID"""
83
+
84
+ async def _run():
85
+ config, token, _, _ = get_client_config(
86
+ ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL")
87
+ )
88
+ client = TestZeusClient(**config)
89
+
90
+ device_id_validated = validate_id(device_id, "device")
91
+
92
+ async with client:
93
+ if token:
94
+ initialize_client_with_token(client, token)
95
+ else:
96
+ await client.ensure_authenticated()
97
+
98
+ device = await client.device_pool.get_one(device_id_validated)
99
+ return device.data
100
+
101
+ try:
102
+ result = asyncio.run(_run())
103
+ format_output(result, ctx.obj["FORMAT"])
104
+ except Exception as e:
105
+ print_message(f"[red]Error getting device: {str(e)}[/red]", ctx.obj["FORMAT"])
106
+ raise click.Abort()
@@ -3,11 +3,13 @@ Environment management commands for TestZeus CLI.
3
3
  """
4
4
 
5
5
  import asyncio
6
+ import json
6
7
  import click
7
8
  from pathlib import Path
8
9
  from rich.console import Console
9
10
  from pocketbase.client import FileUpload
10
11
  from testzeus_sdk import TestZeusClient
12
+ from testzeus_sdk.utils.helpers import validate_data_format
11
13
  from testzeus_cli.config import get_client_config
12
14
  from testzeus_cli.utils.formatters import format_output, print_message
13
15
  from testzeus_cli.utils.auth import initialize_client_with_token
@@ -15,14 +17,16 @@ from testzeus_cli.utils.validators import parse_key_value_pairs, validate_tenant
15
17
 
16
18
  console = Console()
17
19
 
20
+ MOBILE_DEVICE_TYPES = ("mobile-android", "mobile-ios")
21
+
22
+ DATA_FORMAT_HELP = (
23
+ 'Environment data as JSON: \'{"items": [{"key": "k", "value": "v", "type": "variable|secret"}]}\''
24
+ )
25
+
18
26
 
19
27
  def _read_data_file(file_path: str) -> str:
20
28
  """
21
- Read data content from a file as plain text
22
- Args:
23
- file_path: Path to the data file
24
- Returns:
25
- The raw text content of the file
29
+ Read data content from a JSON file.
26
30
  """
27
31
  data_path = Path(file_path)
28
32
  if not data_path.exists():
@@ -34,10 +38,38 @@ def _read_data_file(file_path: str) -> str:
34
38
  except Exception as e:
35
39
  raise click.BadParameter(f"Failed to read data file: {str(e)}")
36
40
 
37
- # Always return the raw text content
38
41
  return content
39
42
 
40
43
 
44
+ def _validate_and_serialize_data(raw_data: str) -> str:
45
+ """Validate the data string matches the expected format and return serialized JSON."""
46
+ try:
47
+ validated = validate_data_format(raw_data)
48
+ return json.dumps(validated)
49
+ except ValueError as e:
50
+ raise click.BadParameter(str(e))
51
+
52
+
53
+ def _validate_device_type_options(device_type, file, mobile_file, connected_environments):
54
+ """Validate CLI options against device_type constraints."""
55
+ if device_type == "browser":
56
+ if mobile_file:
57
+ raise click.UsageError(
58
+ "--mobile-file cannot be used with --device-type=browser. "
59
+ "Use --file for browser environments."
60
+ )
61
+ elif device_type in MOBILE_DEVICE_TYPES:
62
+ if file:
63
+ raise click.UsageError(
64
+ f"--file cannot be used with --device-type={device_type}. "
65
+ "Use --mobile-file for mobile environments."
66
+ )
67
+ if connected_environments:
68
+ raise click.UsageError(
69
+ f"--connected-environments is not supported for {device_type} environments."
70
+ )
71
+
72
+
41
73
  @click.group()
42
74
  def environments_group():
43
75
  """Manage environments in TestZeus"""
@@ -46,39 +78,73 @@ def environments_group():
46
78
 
47
79
  @environments_group.command(name="create")
48
80
  @click.option("--name", required=True, help="Environment name")
81
+ @click.option(
82
+ "--device-type",
83
+ type=click.Choice(["browser", "mobile-android", "mobile-ios"]),
84
+ default="browser",
85
+ help="Device type (default: browser)",
86
+ )
49
87
  @click.option(
50
88
  "--status", default="draft", help="Environment status (draft, ready, deleted)"
51
89
  )
52
- @click.option("--data", help="Environment data as text")
90
+ @click.option("--data", help=DATA_FORMAT_HELP)
53
91
  @click.option(
54
92
  "--data-file",
55
93
  "-df",
56
94
  type=click.Path(exists=True),
57
- help="Path to text file with environment data",
95
+ help="Path to JSON file with environment data in the required format",
58
96
  )
59
97
  @click.option("--tags", help="Comma-separated list of tags")
60
98
  @click.option(
61
99
  "--connected-environments",
62
- help="Comma-separated list of environment IDs or names to connect",
100
+ help="Comma-separated list of environment IDs or names to connect (browser only)",
63
101
  )
64
102
  @click.option(
65
103
  "--file",
66
104
  "-f",
67
105
  type=click.Path(exists=True),
68
- help="Path to text file with environment data",
106
+ help="Path to supporting data file (browser only)",
107
+ )
108
+ @click.option(
109
+ "--mobile-file",
110
+ type=click.Path(exists=True),
111
+ help="Path to mobile app file - APK/ZIP (mobile only)",
112
+ )
113
+ @click.option(
114
+ "--email-manager",
115
+ help="Comma-separated list of email manager integration IDs or names (browser only)",
116
+ )
117
+ @click.option(
118
+ "--source-code-integrations",
119
+ help="Comma-separated list of source code integration IDs or names",
120
+ )
121
+ @click.option(
122
+ "--agent-grounding-prompt",
123
+ help="Agent grounding prompt (JSON string)",
124
+ )
125
+ @click.option(
126
+ "--device-config",
127
+ help="Device configuration (JSON string)",
69
128
  )
70
129
  @click.pass_context
71
- def create(ctx, name, status, data, data_file, tags, connected_environments, file):
130
+ def create(ctx, name, device_type, status, data, data_file, tags, connected_environments, file, mobile_file, email_manager, source_code_integrations, agent_grounding_prompt, device_config):
72
131
  """Create a new environment"""
73
132
 
74
133
  if data and data_file:
75
134
  raise click.UsageError("Cannot use both --data and --data-file")
76
135
 
77
- if not data and not data_file:
78
- raise click.UsageError("Either --data or --data-file is required")
136
+ is_mobile = device_type in MOBILE_DEVICE_TYPES
137
+ if not is_mobile and not data and not data_file:
138
+ raise click.UsageError("Either --data or --data-file is required for browser environments")
139
+
140
+ _validate_device_type_options(device_type, file, mobile_file, connected_environments)
79
141
 
80
- # Process the data content (from file or directly)
81
- data_content = _read_data_file(data_file) if data_file else data
142
+ data_content = None
143
+ if data_file:
144
+ raw_data = _read_data_file(data_file)
145
+ data_content = _validate_and_serialize_data(raw_data)
146
+ elif data:
147
+ data_content = _validate_and_serialize_data(data)
82
148
 
83
149
  async def _run():
84
150
  config, token, stored_tenant_id, stored_user_id = get_client_config(
@@ -94,10 +160,11 @@ def create(ctx, name, status, data, data_file, tags, connected_environments, fil
94
160
 
95
161
  params = {
96
162
  "name": name,
163
+ "device_type": device_type,
97
164
  "status": status,
98
165
  "tenant": stored_tenant_id,
99
166
  "modified_by": stored_user_id,
100
- "metadata": {},
167
+ "metadata": "{}",
101
168
  }
102
169
 
103
170
  if data_content:
@@ -109,6 +176,18 @@ def create(ctx, name, status, data, data_file, tags, connected_environments, fil
109
176
  if connected_environments:
110
177
  params["connected_environments"] = connected_environments.split(",")
111
178
 
179
+ if email_manager:
180
+ params["email_manager"] = email_manager.split(",")
181
+
182
+ if source_code_integrations:
183
+ params["source_code_integrations"] = source_code_integrations.split(",")
184
+
185
+ if agent_grounding_prompt:
186
+ params["agent_grounding_prompt"] = agent_grounding_prompt
187
+
188
+ if device_config:
189
+ params["device_config"] = device_config
190
+
112
191
  if file:
113
192
  try:
114
193
  params["supporting_data_files"] = FileUpload(file, open(file, "rb"))
@@ -116,6 +195,13 @@ def create(ctx, name, status, data, data_file, tags, connected_environments, fil
116
195
  print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
117
196
  exit(1)
118
197
 
198
+ if mobile_file:
199
+ try:
200
+ params["mobile_supporting_data_file"] = FileUpload(mobile_file, open(mobile_file, "rb"))
201
+ except Exception as e:
202
+ print_message(f"[red]Error reading mobile file:[/red] {str(e)}", ctx.obj["FORMAT"])
203
+ exit(1)
204
+
119
205
  env = await client.environments.create(params)
120
206
  return env.data
121
207
 
@@ -151,10 +237,9 @@ def list(ctx, filters, sort, expand):
151
237
  initialize_client_with_token(client, token)
152
238
  else:
153
239
  await client.ensure_authenticated()
154
- result = await client.environments.get_list(
240
+ return await client.environments.get_list(
155
241
  expand=expand, sort=sort, filters=filter_dict
156
242
  )
157
- return result
158
243
 
159
244
  try:
160
245
  result = asyncio.run(_run())
@@ -181,7 +266,6 @@ def delete(ctx, env_id):
181
266
  else:
182
267
  await client.ensure_authenticated()
183
268
 
184
- # Validate tenant ownership before deleting
185
269
  env = await client.environments.get_one(env_id)
186
270
  validate_tenant_ownership(env.data, stored_tenant_id, "environment")
187
271
 
@@ -227,38 +311,67 @@ def get(ctx, env_id, expand):
227
311
  @environments_group.command(name="update")
228
312
  @click.argument("env_id")
229
313
  @click.option("--name", help="New environment name")
314
+ @click.option(
315
+ "--device-type",
316
+ type=click.Choice(["browser", "mobile-android", "mobile-ios"]),
317
+ help="Device type",
318
+ )
230
319
  @click.option("--status", help="New environment status (draft, ready, deleted)")
231
- @click.option("--data", help="New environment data as text")
320
+ @click.option("--data", help=DATA_FORMAT_HELP)
232
321
  @click.option(
233
322
  "--data-file",
234
323
  "-df",
235
324
  type=click.Path(exists=True),
236
- help="Path to text file with new environment data",
325
+ help="Path to JSON file with new environment data in the required format",
237
326
  )
238
327
  @click.option("--tags", help="Comma-separated list of tags")
239
328
  @click.option(
240
329
  "--connected-environments",
241
- help="Comma-separated list of environment IDs or names to connect",
330
+ help="Comma-separated list of environment IDs or names to connect (browser only)",
242
331
  )
243
332
  @click.option(
244
333
  "--file",
245
334
  "-f",
246
335
  type=click.Path(exists=True),
247
- help="Path to text file with environment data",
336
+ help="Path to supporting data file (browser only)",
337
+ )
338
+ @click.option(
339
+ "--mobile-file",
340
+ type=click.Path(exists=True),
341
+ help="Path to mobile app file - APK/ZIP (mobile only)",
342
+ )
343
+ @click.option(
344
+ "--email-manager",
345
+ help="Comma-separated list of email manager integration IDs or names (browser only, use 'none' to clear)",
346
+ )
347
+ @click.option(
348
+ "--source-code-integrations",
349
+ help="Comma-separated list of source code integration IDs or names (use 'none' to clear)",
350
+ )
351
+ @click.option(
352
+ "--agent-grounding-prompt",
353
+ help="Agent grounding prompt (JSON string, use 'none' to clear)",
354
+ )
355
+ @click.option(
356
+ "--device-config",
357
+ help="Device configuration (JSON string, use 'none' to clear)",
248
358
  )
249
359
  @click.pass_context
250
- def update(ctx, env_id, name, status, data, data_file, tags, connected_environments, file):
360
+ def update(ctx, env_id, name, device_type, status, data, data_file, tags, connected_environments, file, mobile_file, email_manager, source_code_integrations, agent_grounding_prompt, device_config):
251
361
  """Update an environment"""
252
362
 
253
363
  if data and data_file:
254
364
  raise click.UsageError("Cannot use both --data and --data-file")
255
365
 
256
- # Process the data content (from file or directly)
366
+ if device_type:
367
+ _validate_device_type_options(device_type, file, mobile_file, connected_environments)
368
+
257
369
  data_content = None
258
370
  if data_file:
259
- data_content = _read_data_file(data_file)
371
+ raw = _read_data_file(data_file)
372
+ data_content = _validate_and_serialize_data(raw)
260
373
  elif data:
261
- data_content = data
374
+ data_content = _validate_and_serialize_data(data)
262
375
 
263
376
  async def _run():
264
377
  config, token, tenant_id, user_id = get_client_config(
@@ -271,10 +384,12 @@ def update(ctx, env_id, name, status, data, data_file, tags, connected_environme
271
384
  else:
272
385
  await client.ensure_authenticated()
273
386
 
274
- # Validate tenant ownership before updating
275
387
  env = await client.environments.get_one(env_id)
276
388
  validate_tenant_ownership(env.data, tenant_id, "environment")
277
389
 
390
+ effective_device_type = device_type or env.device_type
391
+ _validate_device_type_options(effective_device_type, file, mobile_file, connected_environments)
392
+
278
393
  updates = {"tenant": tenant_id, "modified_by": user_id}
279
394
  has_updates = False
280
395
 
@@ -282,6 +397,10 @@ def update(ctx, env_id, name, status, data, data_file, tags, connected_environme
282
397
  updates["name"] = name
283
398
  has_updates = True
284
399
 
400
+ if device_type:
401
+ updates["device_type"] = device_type
402
+ has_updates = True
403
+
285
404
  if status:
286
405
  updates["status"] = status
287
406
  has_updates = True
@@ -305,15 +424,54 @@ def update(ctx, env_id, name, status, data, data_file, tags, connected_environme
305
424
  updates["connected_environments"] = connected_environments.split(",")
306
425
  has_updates = True
307
426
 
427
+ if email_manager:
428
+ if email_manager == "none":
429
+ updates["email_manager"] = None
430
+ else:
431
+ updates["email_manager"] = email_manager.split(",")
432
+ has_updates = True
433
+
434
+ if source_code_integrations:
435
+ if source_code_integrations == "none":
436
+ updates["source_code_integrations"] = None
437
+ else:
438
+ updates["source_code_integrations"] = source_code_integrations.split(",")
439
+ has_updates = True
440
+
441
+ if agent_grounding_prompt:
442
+ if agent_grounding_prompt == "none":
443
+ updates["agent_grounding_prompt"] = None
444
+ else:
445
+ updates["agent_grounding_prompt"] = agent_grounding_prompt
446
+ has_updates = True
447
+
448
+ if device_config:
449
+ if device_config == "none":
450
+ updates["device_config"] = None
451
+ else:
452
+ updates["device_config"] = device_config
453
+ has_updates = True
454
+
308
455
  if file:
309
456
  try:
310
457
  updates["supporting_data_files"] = FileUpload(
311
458
  file, open(file, "rb")
312
459
  )
460
+ has_updates = True
313
461
  except Exception as e:
314
462
  print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
315
463
  exit(1)
316
464
 
465
+ if mobile_file:
466
+ try:
467
+ updates["mobile_supporting_data_file"] = FileUpload(
468
+ mobile_file, open(mobile_file, "rb")
469
+ )
470
+ has_updates = True
471
+ except Exception as e:
472
+ print_message(f"[red]Error reading mobile file:[/red] {str(e)}", ctx.obj["FORMAT"])
473
+ exit(1)
474
+
317
475
  if has_updates:
318
476
  updated_env = await client.environments.update(env_id, updates)
319
477
  return updated_env.data
@@ -331,13 +489,13 @@ def update(ctx, env_id, name, status, data, data_file, tags, connected_environme
331
489
 
332
490
 
333
491
  @environments_group.command(
334
- name="upload-file", help="Upload a file to an environment using ID and file path"
492
+ name="upload-file", help="Upload a supporting data file to a browser environment"
335
493
  )
336
494
  @click.argument("env_id")
337
495
  @click.argument("file_path")
338
496
  @click.pass_context
339
497
  def upload_file(ctx, env_id, file_path):
340
- """Upload a file to an environment"""
498
+ """Upload a file to a browser environment"""
341
499
 
342
500
  async def _run():
343
501
  config, token, tenant_id, user_id = get_client_config(
@@ -350,10 +508,15 @@ def upload_file(ctx, env_id, file_path):
350
508
  else:
351
509
  await client.ensure_authenticated()
352
510
 
353
- # Validate tenant ownership before updating
354
511
  env = await client.environments.get_one(env_id)
355
512
  validate_tenant_ownership(env.data, tenant_id, "environment")
356
513
 
514
+ if env.device_type in MOBILE_DEVICE_TYPES:
515
+ raise click.UsageError(
516
+ f"Cannot upload supporting data files to a {env.device_type} environment. "
517
+ "Use 'upload-mobile-file' instead."
518
+ )
519
+
357
520
  file_path_validated = Path(file_path)
358
521
  if not file_path_validated.exists():
359
522
  print_message(f"[red]File not found:[/red] {file_path}", ctx.obj["FORMAT"])
@@ -374,6 +537,55 @@ def upload_file(ctx, env_id, file_path):
374
537
  raise click.Abort()
375
538
 
376
539
 
540
+ @environments_group.command(
541
+ name="upload-mobile-file", help="Upload a mobile app file (APK/ZIP) to a mobile environment"
542
+ )
543
+ @click.argument("env_id")
544
+ @click.argument("file_path")
545
+ @click.pass_context
546
+ def upload_mobile_file(ctx, env_id, file_path):
547
+ """Upload a mobile app file to a mobile environment"""
548
+
549
+ async def _run():
550
+ config, token, tenant_id, user_id = get_client_config(
551
+ ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL")
552
+ )
553
+ client = TestZeusClient(**config)
554
+ async with client:
555
+ if token:
556
+ initialize_client_with_token(client, token)
557
+ else:
558
+ await client.ensure_authenticated()
559
+
560
+ env = await client.environments.get_one(env_id)
561
+ validate_tenant_ownership(env.data, tenant_id, "environment")
562
+
563
+ if env.device_type == "browser":
564
+ raise click.UsageError(
565
+ "Cannot upload mobile app file to a browser environment. "
566
+ "Use 'upload-file' instead."
567
+ )
568
+
569
+ file_path_validated = Path(file_path)
570
+ if not file_path_validated.exists():
571
+ print_message(f"[red]File not found:[/red] {file_path}", ctx.obj["FORMAT"])
572
+ exit(1)
573
+ params = {
574
+ "mobile_supporting_data_file": FileUpload(file_path, open(file_path, "rb")),
575
+ "tenant": tenant_id,
576
+ "modified_by": user_id,
577
+ }
578
+ result = await client.environments.update(env_id, params)
579
+ return result.data
580
+
581
+ try:
582
+ result = asyncio.run(_run())
583
+ format_output(result, ctx.obj["FORMAT"])
584
+ except Exception as e:
585
+ print_message(f"[red]Error uploading mobile file:[/red] {str(e)}", ctx.obj["FORMAT"])
586
+ raise click.Abort()
587
+
588
+
377
589
  @environments_group.command(
378
590
  name="delete-all-files", help="Delete all files from an environment using ID"
379
591
  )
@@ -393,7 +605,6 @@ def delete_all_files(ctx, env_id):
393
605
  else:
394
606
  await client.ensure_authenticated()
395
607
 
396
- # Validate tenant ownership before updating
397
608
  env = await client.environments.get_one(env_id)
398
609
  validate_tenant_ownership(env.data, tenant_id, "environment")
399
610
 
@@ -401,6 +612,7 @@ def delete_all_files(ctx, env_id):
401
612
  env_id,
402
613
  {
403
614
  "supporting_data_files": None,
615
+ "mobile_supporting_data_file": None,
404
616
  "tenant": tenant_id,
405
617
  "modified_by": user_id,
406
618
  },
@@ -437,7 +649,6 @@ def remove_file(ctx, env_id, file_path):
437
649
  else:
438
650
  await client.ensure_authenticated()
439
651
 
440
- # Validate tenant ownership before updating
441
652
  env_data = await client.environments.get_one(env_id)
442
653
  validate_tenant_ownership(env_data.data, tenant_id, "environment")
443
654
 
@@ -3,11 +3,13 @@ Commands for managing test data in TestZeus CLI.
3
3
  """
4
4
 
5
5
  import asyncio
6
+ import json
6
7
  import click
7
8
  from rich.console import Console
8
9
  from pathlib import Path
9
10
 
10
11
  from testzeus_sdk import TestZeusClient
12
+ from testzeus_sdk.utils.helpers import validate_data_format
11
13
  from testzeus_cli.config import get_client_config
12
14
  from testzeus_cli.utils.formatters import format_output, print_message
13
15
  from testzeus_cli.utils.validators import validate_id, validate_tenant_ownership, parse_key_value_pairs
@@ -16,14 +18,14 @@ from pocketbase.client import FileUpload
16
18
 
17
19
  console = Console()
18
20
 
21
+ DATA_FORMAT_HELP = (
22
+ 'Test data as JSON: \'{"items": [{"key": "k", "value": "v", "type": "variable|secret"}]}\''
23
+ )
24
+
19
25
 
20
26
  def _read_data_file(file_path: str) -> str:
21
27
  """
22
- Read data content from a file as plain text
23
- Args:
24
- file_path: Path to the data file
25
- Returns:
26
- The raw text content of the file
28
+ Read data content from a JSON file.
27
29
  """
28
30
  data_path = Path(file_path)
29
31
  if not data_path.exists():
@@ -35,10 +37,18 @@ def _read_data_file(file_path: str) -> str:
35
37
  except Exception as e:
36
38
  raise click.BadParameter(f"Failed to read data file: {str(e)}")
37
39
 
38
- # Always return the raw text content
39
40
  return content
40
41
 
41
42
 
43
+ def _validate_and_serialize_data(raw_data: str) -> str:
44
+ """Validate the data string matches the expected format and return serialized JSON."""
45
+ try:
46
+ validated = validate_data_format(raw_data)
47
+ return json.dumps(validated)
48
+ except ValueError as e:
49
+ raise click.BadParameter(str(e))
50
+
51
+
42
52
  @click.group(name="test-data")
43
53
  def test_data_group():
44
54
  """Manage TestZeus test data"""
@@ -113,18 +123,18 @@ def get_test_data(ctx, test_data_id, expand):
113
123
  @click.option(
114
124
  "--status", default="draft", help="Test data status (draft, ready, deleted)"
115
125
  )
116
- @click.option("--data", "-d", help="Test data content as text")
126
+ @click.option("--data", "-d", help=DATA_FORMAT_HELP)
117
127
  @click.option(
118
128
  "--data-file",
119
129
  "-df",
120
130
  type=click.Path(exists=True),
121
- help="Path to text file with test data",
131
+ help="Path to JSON file with test data in the required format",
122
132
  )
123
133
  @click.option(
124
134
  "--file",
125
135
  "-f",
126
136
  type=click.Path(exists=True),
127
- help="Path to text file with test data",
137
+ help="Path to supporting data file to upload",
128
138
  )
129
139
  @click.pass_context
130
140
  def create_test_data(ctx, name, type, status, data, data_file, file):
@@ -136,8 +146,8 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
136
146
  if data and data_file:
137
147
  raise click.UsageError("Cannot use both --data and --data-file")
138
148
 
139
- # Process the data content (from file or directly)
140
- data_content = _read_data_file(data_file) if data_file else data
149
+ raw_data = _read_data_file(data_file) if data_file else data
150
+ data_content = _validate_and_serialize_data(raw_data)
141
151
 
142
152
  async def _run():
143
153
  config, token, tenant_id, user_id = get_client_config(
@@ -145,7 +155,6 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
145
155
  )
146
156
  client = TestZeusClient(**config)
147
157
 
148
- # Prepare test data
149
158
  test_data = {
150
159
  "name": name,
151
160
  "type": type,
@@ -156,11 +165,6 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
156
165
  "metadata": {},
157
166
  }
158
167
 
159
- # Add data content if provided directly
160
- if data:
161
- test_data["data"] = data
162
-
163
- # Read from file if provided
164
168
  if file:
165
169
  try:
166
170
  test_data["supporting_data_files"] = FileUpload(file, open(file, "rb"))
@@ -190,18 +194,18 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
190
194
  @click.option("--name", help="New test data name")
191
195
  @click.option("--type", help="New test data type")
192
196
  @click.option("--status", help="New test data status (draft, ready, deleted)")
193
- @click.option("--data", "-d", help="New test data content as text")
197
+ @click.option("--data", "-d", help=DATA_FORMAT_HELP)
194
198
  @click.option(
195
199
  "--data-file",
196
200
  "-df",
197
201
  type=click.Path(exists=True),
198
- help="Path to text file with new test data",
202
+ help="Path to JSON file with new test data in the required format",
199
203
  )
200
204
  @click.option(
201
205
  "--file",
202
206
  "-f",
203
207
  type=click.Path(exists=True),
204
- help="Path to text file with new test data",
208
+ help="Path to supporting data file to upload",
205
209
  )
206
210
  @click.pass_context
207
211
  def update_test_data(ctx, test_data_id, name, type, status, data, data_file, file):
@@ -210,12 +214,12 @@ def update_test_data(ctx, test_data_id, name, type, status, data, data_file, fil
210
214
  if data and data_file:
211
215
  raise click.UsageError("Cannot use both --data and --data-file")
212
216
 
213
- # Process the data content (from file or directly)
214
217
  data_content = None
215
218
  if data_file:
216
- data_content = _read_data_file(data_file)
219
+ raw = _read_data_file(data_file)
220
+ data_content = _validate_and_serialize_data(raw)
217
221
  elif data:
218
- data_content = data
222
+ data_content = _validate_and_serialize_data(data)
219
223
 
220
224
  async def _run():
221
225
  config, token, tenant_id, user_id = get_client_config(
@@ -34,16 +34,13 @@ def tests_group():
34
34
  def list_tests(ctx, filters, sort, expand):
35
35
  """List tests with optional filters and sorting"""
36
36
 
37
- # Parse filters
38
37
  filter_dict = parse_key_value_pairs(filters) if filters else {}
39
38
 
40
- # Define the operation to run with the authenticated client
41
39
  async def _list_tests(client: TestZeusClient):
42
40
  return await client.tests.get_list(
43
41
  expand=expand, sort=sort, filters=filter_dict
44
42
  )
45
43
 
46
- # Run the operation and format the result
47
44
  result = run_client_operation(ctx, _list_tests)
48
45
  format_output(result, ctx.obj["FORMAT"])
49
46
 
@@ -160,11 +157,17 @@ def _resolve_json_input(
160
157
  @click.option("--status", default="draft", help="Test status (draft, ready, deleted)")
161
158
  @click.option("--data", multiple=True, help="Test data IDs")
162
159
  @click.option("--tags", multiple=True, help="Tag IDs")
163
- @click.option("--environment", help="Environment ID")
160
+ @click.option("--environment", help="Environment ID (required for mobile tests)")
164
161
  @click.option("--hypermind-code-blocks", help="Comma-separated list of Hypermind code block IDs")
165
162
  @click.option(
166
163
  "--execution-mode", default="lenient", help="Execution mode (lenient, strict)"
167
164
  )
165
+ @click.option(
166
+ "--testing-type",
167
+ type=click.Choice(["web", "mobile"]),
168
+ default="web",
169
+ help="Testing type (default: web). Environment is required for mobile.",
170
+ )
168
171
  @click.pass_context
169
172
  def create_test(
170
173
  ctx,
@@ -181,6 +184,7 @@ def create_test(
181
184
  environment,
182
185
  hypermind_code_blocks,
183
186
  execution_mode,
187
+ testing_type,
184
188
  ):
185
189
  """Create a new test with feature content from text or file"""
186
190
 
@@ -190,6 +194,11 @@ def create_test(
190
194
  if feature and feature_file:
191
195
  raise click.UsageError("Cannot use both --feature and --feature-file")
192
196
 
197
+ if testing_type == "mobile" and not environment:
198
+ raise click.UsageError(
199
+ "--environment is required when --testing-type is 'mobile'"
200
+ )
201
+
193
202
  # Process the feature content (from file or directly)
194
203
  feature_content = _read_feature_file(feature_file) if feature_file else feature
195
204
  test_params_value = _resolve_json_input(
@@ -216,13 +225,13 @@ def create_test(
216
225
  "name": name,
217
226
  "status": status,
218
227
  "execution_mode": execution_mode,
228
+ "testing_type": testing_type,
219
229
  "tenant": stored_tenant_id,
220
230
  "modified_by": stored_user_id,
221
231
  "metadata": {},
222
232
  "test_params": {},
223
233
  }
224
234
 
225
- # Always set feature content as text
226
235
  test_data["test_feature"] = feature_content
227
236
 
228
237
  if data:
@@ -274,8 +283,13 @@ def create_test(
274
283
  @click.option("--status", help="New test status (draft, ready, deleted)")
275
284
  @click.option("--data", multiple=True, help="Test data IDs")
276
285
  @click.option("--tags", multiple=True, help="Tag IDs")
277
- @click.option("--environment", help="Environment ID")
286
+ @click.option("--environment", help="Environment ID (required for mobile tests)")
278
287
  @click.option("--hypermind-code-blocks", help="Comma-separated list of Hypermind code block IDs (use 'none' to clear)")
288
+ @click.option(
289
+ "--testing-type",
290
+ type=click.Choice(["web", "mobile"]),
291
+ help="Testing type. Environment is required for mobile.",
292
+ )
279
293
  @click.pass_context
280
294
  def update_test(
281
295
  ctx,
@@ -292,6 +306,7 @@ def update_test(
292
306
  tags,
293
307
  environment,
294
308
  hypermind_code_blocks,
309
+ testing_type,
295
310
  ):
296
311
  """Update an existing test with feature content from text or file"""
297
312
 
@@ -375,6 +390,19 @@ def update_test(
375
390
  update_data["hypermind_code_blocks"] = hypermind_code_blocks.split(",")
376
391
  has_updates = True
377
392
 
393
+ if testing_type:
394
+ update_data["testing_type"] = testing_type
395
+ if (
396
+ testing_type == "mobile"
397
+ and not environment
398
+ and not test.data.get("environment")
399
+ ):
400
+ raise click.UsageError(
401
+ "--environment is required when --testing-type is 'mobile' "
402
+ "and the test has no environment assigned"
403
+ )
404
+ has_updates = True
405
+
378
406
  if test_params_value is not None:
379
407
  update_data["test_params"] = test_params_value
380
408
  has_updates = True
@@ -103,6 +103,17 @@ def get_ai_generator(ctx, generator_id, expand):
103
103
  help="AI reasoning effort level (default: low)",
104
104
  )
105
105
  @click.option("--num-testcases", type=click.IntRange(1, 20), default=3, help="Number of test cases to generate (1-20, default: 3)")
106
+ @click.option(
107
+ "--testing-type",
108
+ type=click.Choice(["web", "mobile"]),
109
+ default="web",
110
+ help="Testing type (default: web)",
111
+ )
112
+ @click.option(
113
+ "--knowledge-base",
114
+ multiple=True,
115
+ help="Knowledge base IDs or names (can be specified multiple times)",
116
+ )
106
117
  @click.pass_context
107
118
  def create_ai_generator(
108
119
  ctx,
@@ -115,6 +126,8 @@ def create_ai_generator(
115
126
  user_prompt_file,
116
127
  reasoning_effort,
117
128
  num_testcases,
129
+ testing_type,
130
+ knowledge_base,
118
131
  ):
119
132
  """Create a new AI test generator request"""
120
133
 
@@ -161,6 +174,7 @@ def create_ai_generator(
161
174
 
162
175
  generator_data = {
163
176
  "test": test_id,
177
+ "testing_type": testing_type,
164
178
  "tenant": stored_tenant_id,
165
179
  "modified_by": stored_user_id,
166
180
  }
@@ -183,7 +197,9 @@ def create_ai_generator(
183
197
  if num_testcases is not None:
184
198
  generator_data["num_of_testcases"] = num_testcases
185
199
 
186
- # Always set submit to true
200
+ if knowledge_base:
201
+ generator_data["knowledge_base"] = list(knowledge_base)
202
+
187
203
  generator_data["submit"] = True
188
204
 
189
205
  async with client:
File without changes
File without changes