testzeus-cli 0.0.20__tar.gz → 0.0.22__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 (36) hide show
  1. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/PKG-INFO +2 -2
  2. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/pyproject.toml +2 -2
  3. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/cli.py +2 -0
  4. testzeus_cli-0.0.22/testzeus_cli/commands/device_pool.py +106 -0
  5. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/environments.py +248 -42
  6. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/hypermind_code_blocks.py +3 -11
  7. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/test_data.py +31 -32
  8. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/test_run_groups.py +3 -5
  9. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/test_suite_schedules.py +2 -2
  10. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/test_suites.py +2 -2
  11. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/tests.py +34 -6
  12. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/tests_ai_generator.py +17 -1
  13. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/user_integrations.py +5 -3
  14. testzeus_cli-0.0.22/testzeus_cli/utils/files.py +45 -0
  15. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/LICENSE +0 -0
  16. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/README.md +0 -0
  17. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/__init__.py +0 -0
  18. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/auth.py +0 -0
  19. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/__init__.py +0 -0
  20. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/daemon.py +0 -0
  21. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/extensions.py +0 -0
  22. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/knowledge_bases.py +0 -0
  23. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/notification_channels.py +0 -0
  24. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/tags.py +0 -0
  25. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/test_report_schedules.py +0 -0
  26. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/test_runs.py +0 -0
  27. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/test_suite_node_runs.py +0 -0
  28. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/test_suite_runs.py +0 -0
  29. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/commands/tests_authoring.py +0 -0
  30. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/config.py +0 -0
  31. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/utils/__init__.py +0 -0
  32. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/utils/auth.py +0 -0
  33. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/utils/client.py +0 -0
  34. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/utils/formatters.py +0 -0
  35. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/testzeus_cli/utils/profile.py +0 -0
  36. {testzeus_cli-0.0.20 → testzeus_cli-0.0.22}/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.22
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.22"
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,26 +3,31 @@ 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
14
16
  from testzeus_cli.utils.validators import parse_key_value_pairs, validate_tenant_ownership
17
+ from testzeus_cli.utils.files import match_stored_file
15
18
 
16
19
  console = Console()
17
20
 
21
+ MOBILE_DEVICE_TYPES = ("mobile-android", "mobile-ios")
22
+
23
+ DATA_FORMAT_HELP = (
24
+ 'Environment data as JSON: \'{"items": [{"key": "k", "value": "v", "type": "variable|secret"}]}\''
25
+ )
26
+
18
27
 
19
28
  def _read_data_file(file_path: str) -> str:
20
29
  """
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
30
+ Read data content from a JSON file.
26
31
  """
27
32
  data_path = Path(file_path)
28
33
  if not data_path.exists():
@@ -34,10 +39,38 @@ def _read_data_file(file_path: str) -> str:
34
39
  except Exception as e:
35
40
  raise click.BadParameter(f"Failed to read data file: {str(e)}")
36
41
 
37
- # Always return the raw text content
38
42
  return content
39
43
 
40
44
 
45
+ def _validate_and_serialize_data(raw_data: str) -> str:
46
+ """Validate the data string matches the expected format and return serialized JSON."""
47
+ try:
48
+ validated = validate_data_format(raw_data)
49
+ return json.dumps(validated)
50
+ except ValueError as e:
51
+ raise click.BadParameter(str(e))
52
+
53
+
54
+ def _validate_device_type_options(device_type, file, mobile_file, connected_environments):
55
+ """Validate CLI options against device_type constraints."""
56
+ if device_type == "browser":
57
+ if mobile_file:
58
+ raise click.UsageError(
59
+ "--mobile-file cannot be used with --device-type=browser. "
60
+ "Use --file for browser environments."
61
+ )
62
+ elif device_type in MOBILE_DEVICE_TYPES:
63
+ if file:
64
+ raise click.UsageError(
65
+ f"--file cannot be used with --device-type={device_type}. "
66
+ "Use --mobile-file for mobile environments."
67
+ )
68
+ if connected_environments:
69
+ raise click.UsageError(
70
+ f"--connected-environments is not supported for {device_type} environments."
71
+ )
72
+
73
+
41
74
  @click.group()
42
75
  def environments_group():
43
76
  """Manage environments in TestZeus"""
@@ -46,39 +79,73 @@ def environments_group():
46
79
 
47
80
  @environments_group.command(name="create")
48
81
  @click.option("--name", required=True, help="Environment name")
82
+ @click.option(
83
+ "--device-type",
84
+ type=click.Choice(["browser", "mobile-android", "mobile-ios"]),
85
+ default="browser",
86
+ help="Device type (default: browser)",
87
+ )
49
88
  @click.option(
50
89
  "--status", default="draft", help="Environment status (draft, ready, deleted)"
51
90
  )
52
- @click.option("--data", help="Environment data as text")
91
+ @click.option("--data", help=DATA_FORMAT_HELP)
53
92
  @click.option(
54
93
  "--data-file",
55
94
  "-df",
56
95
  type=click.Path(exists=True),
57
- help="Path to text file with environment data",
96
+ help="Path to JSON file with environment data in the required format",
58
97
  )
59
98
  @click.option("--tags", help="Comma-separated list of tags")
60
99
  @click.option(
61
100
  "--connected-environments",
62
- help="Comma-separated list of environment IDs or names to connect",
101
+ help="Comma-separated list of environment IDs or names to connect (browser only)",
63
102
  )
64
103
  @click.option(
65
104
  "--file",
66
105
  "-f",
67
106
  type=click.Path(exists=True),
68
- help="Path to text file with environment data",
107
+ help="Path to supporting data file (browser only)",
108
+ )
109
+ @click.option(
110
+ "--mobile-file",
111
+ type=click.Path(exists=True),
112
+ help="Path to mobile app file - APK/ZIP (mobile only)",
113
+ )
114
+ @click.option(
115
+ "--email-manager",
116
+ help="Comma-separated list of email manager integration IDs or names (browser only)",
117
+ )
118
+ @click.option(
119
+ "--source-code-integrations",
120
+ help="Comma-separated list of source code integration IDs or names",
121
+ )
122
+ @click.option(
123
+ "--agent-grounding-prompt",
124
+ help="Agent grounding prompt (JSON string)",
125
+ )
126
+ @click.option(
127
+ "--device-config",
128
+ help="Device configuration (JSON string)",
69
129
  )
70
130
  @click.pass_context
71
- def create(ctx, name, status, data, data_file, tags, connected_environments, file):
131
+ 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
132
  """Create a new environment"""
73
133
 
74
134
  if data and data_file:
75
135
  raise click.UsageError("Cannot use both --data and --data-file")
76
136
 
77
- if not data and not data_file:
78
- raise click.UsageError("Either --data or --data-file is required")
137
+ is_mobile = device_type in MOBILE_DEVICE_TYPES
138
+ if not is_mobile and not data and not data_file:
139
+ raise click.UsageError("Either --data or --data-file is required for browser environments")
140
+
141
+ _validate_device_type_options(device_type, file, mobile_file, connected_environments)
79
142
 
80
- # Process the data content (from file or directly)
81
- data_content = _read_data_file(data_file) if data_file else data
143
+ data_content = None
144
+ if data_file:
145
+ raw_data = _read_data_file(data_file)
146
+ data_content = _validate_and_serialize_data(raw_data)
147
+ elif data:
148
+ data_content = _validate_and_serialize_data(data)
82
149
 
83
150
  async def _run():
84
151
  config, token, stored_tenant_id, stored_user_id = get_client_config(
@@ -94,10 +161,11 @@ def create(ctx, name, status, data, data_file, tags, connected_environments, fil
94
161
 
95
162
  params = {
96
163
  "name": name,
164
+ "device_type": device_type,
97
165
  "status": status,
98
166
  "tenant": stored_tenant_id,
99
167
  "modified_by": stored_user_id,
100
- "metadata": {},
168
+ "metadata": "{}",
101
169
  }
102
170
 
103
171
  if data_content:
@@ -109,6 +177,18 @@ def create(ctx, name, status, data, data_file, tags, connected_environments, fil
109
177
  if connected_environments:
110
178
  params["connected_environments"] = connected_environments.split(",")
111
179
 
180
+ if email_manager:
181
+ params["email_manager"] = email_manager.split(",")
182
+
183
+ if source_code_integrations:
184
+ params["source_code_integrations"] = source_code_integrations.split(",")
185
+
186
+ if agent_grounding_prompt:
187
+ params["agent_grounding_prompt"] = agent_grounding_prompt
188
+
189
+ if device_config:
190
+ params["device_config"] = device_config
191
+
112
192
  if file:
113
193
  try:
114
194
  params["supporting_data_files"] = FileUpload(file, open(file, "rb"))
@@ -116,6 +196,13 @@ def create(ctx, name, status, data, data_file, tags, connected_environments, fil
116
196
  print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
117
197
  exit(1)
118
198
 
199
+ if mobile_file:
200
+ try:
201
+ params["mobile_supporting_data_file"] = FileUpload(mobile_file, open(mobile_file, "rb"))
202
+ except Exception as e:
203
+ print_message(f"[red]Error reading mobile file:[/red] {str(e)}", ctx.obj["FORMAT"])
204
+ exit(1)
205
+
119
206
  env = await client.environments.create(params)
120
207
  return env.data
121
208
 
@@ -151,10 +238,9 @@ def list(ctx, filters, sort, expand):
151
238
  initialize_client_with_token(client, token)
152
239
  else:
153
240
  await client.ensure_authenticated()
154
- result = await client.environments.get_list(
241
+ return await client.environments.get_list(
155
242
  expand=expand, sort=sort, filters=filter_dict
156
243
  )
157
- return result
158
244
 
159
245
  try:
160
246
  result = asyncio.run(_run())
@@ -181,7 +267,6 @@ def delete(ctx, env_id):
181
267
  else:
182
268
  await client.ensure_authenticated()
183
269
 
184
- # Validate tenant ownership before deleting
185
270
  env = await client.environments.get_one(env_id)
186
271
  validate_tenant_ownership(env.data, stored_tenant_id, "environment")
187
272
 
@@ -227,38 +312,67 @@ def get(ctx, env_id, expand):
227
312
  @environments_group.command(name="update")
228
313
  @click.argument("env_id")
229
314
  @click.option("--name", help="New environment name")
315
+ @click.option(
316
+ "--device-type",
317
+ type=click.Choice(["browser", "mobile-android", "mobile-ios"]),
318
+ help="Device type",
319
+ )
230
320
  @click.option("--status", help="New environment status (draft, ready, deleted)")
231
- @click.option("--data", help="New environment data as text")
321
+ @click.option("--data", help=DATA_FORMAT_HELP)
232
322
  @click.option(
233
323
  "--data-file",
234
324
  "-df",
235
325
  type=click.Path(exists=True),
236
- help="Path to text file with new environment data",
326
+ help="Path to JSON file with new environment data in the required format",
237
327
  )
238
328
  @click.option("--tags", help="Comma-separated list of tags")
239
329
  @click.option(
240
330
  "--connected-environments",
241
- help="Comma-separated list of environment IDs or names to connect",
331
+ help="Comma-separated list of environment IDs or names to connect (browser only)",
242
332
  )
243
333
  @click.option(
244
334
  "--file",
245
335
  "-f",
246
336
  type=click.Path(exists=True),
247
- help="Path to text file with environment data",
337
+ help="Path to supporting data file (browser only)",
338
+ )
339
+ @click.option(
340
+ "--mobile-file",
341
+ type=click.Path(exists=True),
342
+ help="Path to mobile app file - APK/ZIP (mobile only)",
343
+ )
344
+ @click.option(
345
+ "--email-manager",
346
+ help="Comma-separated list of email manager integration IDs or names (browser only, use 'none' to clear)",
347
+ )
348
+ @click.option(
349
+ "--source-code-integrations",
350
+ help="Comma-separated list of source code integration IDs or names (use 'none' to clear)",
351
+ )
352
+ @click.option(
353
+ "--agent-grounding-prompt",
354
+ help="Agent grounding prompt (JSON string, use 'none' to clear)",
355
+ )
356
+ @click.option(
357
+ "--device-config",
358
+ help="Device configuration (JSON string, use 'none' to clear)",
248
359
  )
249
360
  @click.pass_context
250
- def update(ctx, env_id, name, status, data, data_file, tags, connected_environments, file):
361
+ 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
362
  """Update an environment"""
252
363
 
253
364
  if data and data_file:
254
365
  raise click.UsageError("Cannot use both --data and --data-file")
255
366
 
256
- # Process the data content (from file or directly)
367
+ if device_type:
368
+ _validate_device_type_options(device_type, file, mobile_file, connected_environments)
369
+
257
370
  data_content = None
258
371
  if data_file:
259
- data_content = _read_data_file(data_file)
372
+ raw = _read_data_file(data_file)
373
+ data_content = _validate_and_serialize_data(raw)
260
374
  elif data:
261
- data_content = data
375
+ data_content = _validate_and_serialize_data(data)
262
376
 
263
377
  async def _run():
264
378
  config, token, tenant_id, user_id = get_client_config(
@@ -271,10 +385,12 @@ def update(ctx, env_id, name, status, data, data_file, tags, connected_environme
271
385
  else:
272
386
  await client.ensure_authenticated()
273
387
 
274
- # Validate tenant ownership before updating
275
388
  env = await client.environments.get_one(env_id)
276
389
  validate_tenant_ownership(env.data, tenant_id, "environment")
277
390
 
391
+ effective_device_type = device_type or env.device_type
392
+ _validate_device_type_options(effective_device_type, file, mobile_file, connected_environments)
393
+
278
394
  updates = {"tenant": tenant_id, "modified_by": user_id}
279
395
  has_updates = False
280
396
 
@@ -282,6 +398,10 @@ def update(ctx, env_id, name, status, data, data_file, tags, connected_environme
282
398
  updates["name"] = name
283
399
  has_updates = True
284
400
 
401
+ if device_type:
402
+ updates["device_type"] = device_type
403
+ has_updates = True
404
+
285
405
  if status:
286
406
  updates["status"] = status
287
407
  has_updates = True
@@ -305,15 +425,54 @@ def update(ctx, env_id, name, status, data, data_file, tags, connected_environme
305
425
  updates["connected_environments"] = connected_environments.split(",")
306
426
  has_updates = True
307
427
 
428
+ if email_manager:
429
+ if email_manager == "none":
430
+ updates["email_manager"] = None
431
+ else:
432
+ updates["email_manager"] = email_manager.split(",")
433
+ has_updates = True
434
+
435
+ if source_code_integrations:
436
+ if source_code_integrations == "none":
437
+ updates["source_code_integrations"] = None
438
+ else:
439
+ updates["source_code_integrations"] = source_code_integrations.split(",")
440
+ has_updates = True
441
+
442
+ if agent_grounding_prompt:
443
+ if agent_grounding_prompt == "none":
444
+ updates["agent_grounding_prompt"] = None
445
+ else:
446
+ updates["agent_grounding_prompt"] = agent_grounding_prompt
447
+ has_updates = True
448
+
449
+ if device_config:
450
+ if device_config == "none":
451
+ updates["device_config"] = None
452
+ else:
453
+ updates["device_config"] = device_config
454
+ has_updates = True
455
+
308
456
  if file:
309
457
  try:
310
458
  updates["supporting_data_files"] = FileUpload(
311
459
  file, open(file, "rb")
312
460
  )
461
+ has_updates = True
313
462
  except Exception as e:
314
463
  print_message(f"[red]Error reading file:[/red] {str(e)}", ctx.obj["FORMAT"])
315
464
  exit(1)
316
465
 
466
+ if mobile_file:
467
+ try:
468
+ updates["mobile_supporting_data_file"] = FileUpload(
469
+ mobile_file, open(mobile_file, "rb")
470
+ )
471
+ has_updates = True
472
+ except Exception as e:
473
+ print_message(f"[red]Error reading mobile file:[/red] {str(e)}", ctx.obj["FORMAT"])
474
+ exit(1)
475
+
317
476
  if has_updates:
318
477
  updated_env = await client.environments.update(env_id, updates)
319
478
  return updated_env.data
@@ -331,13 +490,13 @@ def update(ctx, env_id, name, status, data, data_file, tags, connected_environme
331
490
 
332
491
 
333
492
  @environments_group.command(
334
- name="upload-file", help="Upload a file to an environment using ID and file path"
493
+ name="upload-file", help="Upload a supporting data file to a browser environment"
335
494
  )
336
495
  @click.argument("env_id")
337
496
  @click.argument("file_path")
338
497
  @click.pass_context
339
498
  def upload_file(ctx, env_id, file_path):
340
- """Upload a file to an environment"""
499
+ """Upload a file to a browser environment"""
341
500
 
342
501
  async def _run():
343
502
  config, token, tenant_id, user_id = get_client_config(
@@ -350,10 +509,15 @@ def upload_file(ctx, env_id, file_path):
350
509
  else:
351
510
  await client.ensure_authenticated()
352
511
 
353
- # Validate tenant ownership before updating
354
512
  env = await client.environments.get_one(env_id)
355
513
  validate_tenant_ownership(env.data, tenant_id, "environment")
356
514
 
515
+ if env.device_type in MOBILE_DEVICE_TYPES:
516
+ raise click.UsageError(
517
+ f"Cannot upload supporting data files to a {env.device_type} environment. "
518
+ "Use 'upload-mobile-file' instead."
519
+ )
520
+
357
521
  file_path_validated = Path(file_path)
358
522
  if not file_path_validated.exists():
359
523
  print_message(f"[red]File not found:[/red] {file_path}", ctx.obj["FORMAT"])
@@ -374,6 +538,55 @@ def upload_file(ctx, env_id, file_path):
374
538
  raise click.Abort()
375
539
 
376
540
 
541
+ @environments_group.command(
542
+ name="upload-mobile-file", help="Upload a mobile app file (APK/ZIP) to a mobile environment"
543
+ )
544
+ @click.argument("env_id")
545
+ @click.argument("file_path")
546
+ @click.pass_context
547
+ def upload_mobile_file(ctx, env_id, file_path):
548
+ """Upload a mobile app file to a mobile environment"""
549
+
550
+ async def _run():
551
+ config, token, tenant_id, user_id = get_client_config(
552
+ ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL")
553
+ )
554
+ client = TestZeusClient(**config)
555
+ async with client:
556
+ if token:
557
+ initialize_client_with_token(client, token)
558
+ else:
559
+ await client.ensure_authenticated()
560
+
561
+ env = await client.environments.get_one(env_id)
562
+ validate_tenant_ownership(env.data, tenant_id, "environment")
563
+
564
+ if env.device_type == "browser":
565
+ raise click.UsageError(
566
+ "Cannot upload mobile app file to a browser environment. "
567
+ "Use 'upload-file' instead."
568
+ )
569
+
570
+ file_path_validated = Path(file_path)
571
+ if not file_path_validated.exists():
572
+ print_message(f"[red]File not found:[/red] {file_path}", ctx.obj["FORMAT"])
573
+ exit(1)
574
+ params = {
575
+ "mobile_supporting_data_file": FileUpload(file_path, open(file_path, "rb")),
576
+ "tenant": tenant_id,
577
+ "modified_by": user_id,
578
+ }
579
+ result = await client.environments.update(env_id, params)
580
+ return result.data
581
+
582
+ try:
583
+ result = asyncio.run(_run())
584
+ format_output(result, ctx.obj["FORMAT"])
585
+ except Exception as e:
586
+ print_message(f"[red]Error uploading mobile file:[/red] {str(e)}", ctx.obj["FORMAT"])
587
+ raise click.Abort()
588
+
589
+
377
590
  @environments_group.command(
378
591
  name="delete-all-files", help="Delete all files from an environment using ID"
379
592
  )
@@ -393,7 +606,6 @@ def delete_all_files(ctx, env_id):
393
606
  else:
394
607
  await client.ensure_authenticated()
395
608
 
396
- # Validate tenant ownership before updating
397
609
  env = await client.environments.get_one(env_id)
398
610
  validate_tenant_ownership(env.data, tenant_id, "environment")
399
611
 
@@ -401,6 +613,7 @@ def delete_all_files(ctx, env_id):
401
613
  env_id,
402
614
  {
403
615
  "supporting_data_files": None,
616
+ "mobile_supporting_data_file": None,
404
617
  "tenant": tenant_id,
405
618
  "modified_by": user_id,
406
619
  },
@@ -437,19 +650,12 @@ def remove_file(ctx, env_id, file_path):
437
650
  else:
438
651
  await client.ensure_authenticated()
439
652
 
440
- # Validate tenant ownership before updating
441
653
  env_data = await client.environments.get_one(env_id)
442
654
  validate_tenant_ownership(env_data.data, tenant_id, "environment")
443
655
 
444
- file_name = None
445
- if env_data.supporting_data_files:
446
- for file in env_data.supporting_data_files:
447
- if (
448
- file_path.split("/")[-1].split(".")[0].lower()
449
- == file.split("_")[0].lower()
450
- ):
451
- file_name = file
452
- break
656
+ file_name = match_stored_file(env_data.supporting_data_files or [], file_path)
657
+ if not file_name:
658
+ raise ValueError(f"File not found in environment: {file_path}")
453
659
  params = {
454
660
  "supporting_data_files-": [file_name],
455
661
  "tenant": tenant_id,
@@ -12,6 +12,7 @@ from testzeus_cli.config import get_client_config
12
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
+ from testzeus_cli.utils.files import match_stored_file
15
16
  from pocketbase.client import FileUpload
16
17
 
17
18
  console = Console()
@@ -378,17 +379,8 @@ def remove_file(ctx, code_block_id, file_path):
378
379
  await client.ensure_authenticated()
379
380
 
380
381
  code_block_data = await client.hypermind_code_blocks.get_one(code_block_id_validated)
381
- file_name = None
382
-
383
- if code_block_data.code_files:
384
- for file in code_block_data.code_files:
385
- if (
386
- file_path.split("/")[-1].split(".")[0].lower()
387
- == file.split("_")[0].lower()
388
- ):
389
- file_name = file
390
- break
391
-
382
+ file_name = match_stored_file(code_block_data.code_files or [], file_path)
383
+
392
384
  if not file_name:
393
385
  print_message(f"[yellow]File not found: {file_path}[/yellow]", ctx.obj["FORMAT"])
394
386
  return None
@@ -3,27 +3,30 @@ 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
14
16
  from testzeus_cli.utils.auth import initialize_client_with_token
17
+ from testzeus_cli.utils.files import match_stored_file
15
18
  from pocketbase.client import FileUpload
16
19
 
17
20
  console = Console()
18
21
 
22
+ DATA_FORMAT_HELP = (
23
+ 'Test data as JSON: \'{"items": [{"key": "k", "value": "v", "type": "variable|secret"}]}\''
24
+ )
25
+
19
26
 
20
27
  def _read_data_file(file_path: str) -> str:
21
28
  """
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
29
+ Read data content from a JSON file.
27
30
  """
28
31
  data_path = Path(file_path)
29
32
  if not data_path.exists():
@@ -35,10 +38,18 @@ def _read_data_file(file_path: str) -> str:
35
38
  except Exception as e:
36
39
  raise click.BadParameter(f"Failed to read data file: {str(e)}")
37
40
 
38
- # Always return the raw text content
39
41
  return content
40
42
 
41
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
+
42
53
  @click.group(name="test-data")
43
54
  def test_data_group():
44
55
  """Manage TestZeus test data"""
@@ -113,18 +124,18 @@ def get_test_data(ctx, test_data_id, expand):
113
124
  @click.option(
114
125
  "--status", default="draft", help="Test data status (draft, ready, deleted)"
115
126
  )
116
- @click.option("--data", "-d", help="Test data content as text")
127
+ @click.option("--data", "-d", help=DATA_FORMAT_HELP)
117
128
  @click.option(
118
129
  "--data-file",
119
130
  "-df",
120
131
  type=click.Path(exists=True),
121
- help="Path to text file with test data",
132
+ help="Path to JSON file with test data in the required format",
122
133
  )
123
134
  @click.option(
124
135
  "--file",
125
136
  "-f",
126
137
  type=click.Path(exists=True),
127
- help="Path to text file with test data",
138
+ help="Path to supporting data file to upload",
128
139
  )
129
140
  @click.pass_context
130
141
  def create_test_data(ctx, name, type, status, data, data_file, file):
@@ -136,8 +147,8 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
136
147
  if data and data_file:
137
148
  raise click.UsageError("Cannot use both --data and --data-file")
138
149
 
139
- # Process the data content (from file or directly)
140
- data_content = _read_data_file(data_file) if data_file else data
150
+ raw_data = _read_data_file(data_file) if data_file else data
151
+ data_content = _validate_and_serialize_data(raw_data)
141
152
 
142
153
  async def _run():
143
154
  config, token, tenant_id, user_id = get_client_config(
@@ -145,7 +156,6 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
145
156
  )
146
157
  client = TestZeusClient(**config)
147
158
 
148
- # Prepare test data
149
159
  test_data = {
150
160
  "name": name,
151
161
  "type": type,
@@ -156,11 +166,6 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
156
166
  "metadata": {},
157
167
  }
158
168
 
159
- # Add data content if provided directly
160
- if data:
161
- test_data["data"] = data
162
-
163
- # Read from file if provided
164
169
  if file:
165
170
  try:
166
171
  test_data["supporting_data_files"] = FileUpload(file, open(file, "rb"))
@@ -190,18 +195,18 @@ def create_test_data(ctx, name, type, status, data, data_file, file):
190
195
  @click.option("--name", help="New test data name")
191
196
  @click.option("--type", help="New test data type")
192
197
  @click.option("--status", help="New test data status (draft, ready, deleted)")
193
- @click.option("--data", "-d", help="New test data content as text")
198
+ @click.option("--data", "-d", help=DATA_FORMAT_HELP)
194
199
  @click.option(
195
200
  "--data-file",
196
201
  "-df",
197
202
  type=click.Path(exists=True),
198
- help="Path to text file with new test data",
203
+ help="Path to JSON file with new test data in the required format",
199
204
  )
200
205
  @click.option(
201
206
  "--file",
202
207
  "-f",
203
208
  type=click.Path(exists=True),
204
- help="Path to text file with new test data",
209
+ help="Path to supporting data file to upload",
205
210
  )
206
211
  @click.pass_context
207
212
  def update_test_data(ctx, test_data_id, name, type, status, data, data_file, file):
@@ -210,12 +215,12 @@ def update_test_data(ctx, test_data_id, name, type, status, data, data_file, fil
210
215
  if data and data_file:
211
216
  raise click.UsageError("Cannot use both --data and --data-file")
212
217
 
213
- # Process the data content (from file or directly)
214
218
  data_content = None
215
219
  if data_file:
216
- data_content = _read_data_file(data_file)
220
+ raw = _read_data_file(data_file)
221
+ data_content = _validate_and_serialize_data(raw)
217
222
  elif data:
218
- data_content = data
223
+ data_content = _validate_and_serialize_data(data)
219
224
 
220
225
  async def _run():
221
226
  config, token, tenant_id, user_id = get_client_config(
@@ -439,15 +444,9 @@ def remove_file(ctx, test_data_id, file_path):
439
444
  test_data_data = await client.test_data.get_one(test_data_id)
440
445
  validate_tenant_ownership(test_data_data.data, tenant_id, "test data")
441
446
 
442
- file_name = None
443
- if test_data_data.supporting_data_files:
444
- for file in test_data_data.supporting_data_files:
445
- if (
446
- file_path.split("/")[-1].split(".")[0].lower()
447
- == file.split("_")[0].lower()
448
- ):
449
- file_name = file
450
- break
447
+ file_name = match_stored_file(test_data_data.supporting_data_files or [], file_path)
448
+ if not file_name:
449
+ raise ValueError(f"File not found in test data: {file_path}")
451
450
  params = {
452
451
  "supporting_data_files-": [file_name],
453
452
  "tenant": tenant_id,
@@ -248,7 +248,7 @@ def cancel_test_run_group(ctx, test_run_group_id):
248
248
 
249
249
  async with client:
250
250
  if token:
251
- initialize_client_with_token(client, token)
251
+ initialize_client_with_token(client, token, stored_tenant_id)
252
252
  else:
253
253
  await client.ensure_authenticated()
254
254
 
@@ -261,10 +261,8 @@ def cancel_test_run_group(ctx, test_run_group_id):
261
261
  f"[blue]Cancelling test run group: {test_run_group_id_validated}[/blue]"
262
262
  )
263
263
 
264
- result = await client.test_run_groups.cancel(
265
- test_run_group_id_validated,
266
- tenant=stored_tenant_id,
267
- modified_by=stored_user_id,
264
+ result = await client.test_run_groups.cancel_group(
265
+ test_run_group_id_validated
268
266
  )
269
267
  return result.data if hasattr(result, "data") else result
270
268
 
@@ -159,10 +159,10 @@ def update_test_suite_schedule(
159
159
  input_values_value = _parse_json_value(input_values, "--input-values") if input_values else None
160
160
 
161
161
  async def _run():
162
- config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
162
+ config, token, tenant_id, user_id = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
163
163
  client = TestZeusClient(**config)
164
164
  schedule_id_validated = validate_id(schedule_id, "test suite schedule")
165
- payload = {}
165
+ payload = {"tenant": tenant_id, "modified_by": user_id}
166
166
  if name is not None:
167
167
  payload["name"] = name
168
168
  if test_suite is not None:
@@ -184,10 +184,10 @@ def update_test_suite(
184
184
  input_schema_value = _parse_json_value(input_schema, "--input-schema") if input_schema else None
185
185
 
186
186
  async def _run():
187
- config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
187
+ config, token, tenant_id, user_id = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
188
188
  client = TestZeusClient(**config)
189
189
  suite_id_validated = validate_id(suite_id, "test suite")
190
- payload = {}
190
+ payload = {"tenant": tenant_id, "modified_by": user_id}
191
191
  if name is not None:
192
192
  payload["name"] = name
193
193
  if workflow_definition_value is not None:
@@ -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:
@@ -108,10 +108,12 @@ def get_first_user_integration(ctx, filters, sort, expand):
108
108
  if token:
109
109
  initialize_client_with_token(client, token)
110
110
 
111
- integration = await client.user_integrations.get_first_item(
112
- expand=expand, sort=sort, filters=filter_dict
111
+ result = await client.user_integrations.get_list(
112
+ expand=expand, sort=sort, filters=filter_dict, per_page=1
113
113
  )
114
-
114
+ items = result.get("items", [])
115
+ integration = items[0] if items else None
116
+
115
117
  if integration:
116
118
  return integration.data
117
119
  else:
@@ -0,0 +1,45 @@
1
+ """
2
+ File-related utilities for TestZeus CLI.
3
+ """
4
+
5
+ import re
6
+ from typing import List, Optional
7
+
8
+
9
+ def match_stored_file(stored_files: List[str], file_path: str) -> Optional[str]:
10
+ """
11
+ Find the stored PocketBase filename matching a user-supplied file path.
12
+
13
+ PocketBase stores uploads as ``<snakecase(basename)>_<random10>.<ext>``,
14
+ so both the exact stored name and the original local filename are accepted.
15
+
16
+ Args:
17
+ stored_files: Stored filenames from the record's file field
18
+ file_path: User-supplied path or filename (local name or stored name)
19
+
20
+ Returns:
21
+ The matching stored filename, or None if nothing matches
22
+ """
23
+ requested = file_path.replace("\\", "/").split("/")[-1]
24
+ if not requested:
25
+ return None
26
+
27
+ for stored in stored_files:
28
+ if stored == requested:
29
+ return stored
30
+
31
+ base, dot, ext = requested.rpartition(".")
32
+ if not dot:
33
+ base, ext = requested, ""
34
+ normalized = re.sub(r"[^a-z0-9]+", "_", base.lower()).strip("_")
35
+
36
+ for stored in stored_files:
37
+ stored_base, stored_dot, stored_ext = stored.rpartition(".")
38
+ if not stored_dot:
39
+ stored_base, stored_ext = stored, ""
40
+ if ext and stored_ext.lower() != ext.lower():
41
+ continue
42
+ if stored_base.lower().rsplit("_", 1)[0] == normalized:
43
+ return stored
44
+
45
+ return None
File without changes
File without changes