allure-cli 0.2.4__tar.gz → 0.4.0__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.
@@ -0,0 +1,540 @@
1
+ Metadata-Version: 2.4
2
+ Name: allure-cli
3
+ Version: 0.4.0
4
+ Summary: CLI for Allure TestOps: search, create and delete test cases, inspect launch failures
5
+ Author: Allure CLI Contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/teka1905/allure_cli
8
+ Project-URL: Repository, https://github.com/teka1905/allure_cli
9
+ Project-URL: Bug Tracker, https://github.com/teka1905/allure_cli/issues
10
+ Keywords: allure,testops,testing,qa,cli
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Testing
19
+ Classifier: Topic :: Utilities
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ # Allure CLI
26
+
27
+ A CLI for Allure TestOps. Its main job is looking up a test case's Allure ID by name; it can also create, delete and audit test cases, and show why a launch failed — messages, traces and attachments.
28
+
29
+ [![PyPI version](https://badge.fury.io/py/allure-cli.svg)](https://pypi.org/project/allure-cli/)
30
+ [![Python](https://img.shields.io/pypi/pyversions/allure-cli.svg)](https://pypi.org/project/allure-cli/)
31
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
32
+
33
+ ## Requirements
34
+
35
+ - Python 3.10+
36
+ - No external dependencies (stdlib only)
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ pip install allure-cli
42
+ ```
43
+
44
+ After installation the `allure-cli` command is available in your PATH.
45
+
46
+ ## Configuration
47
+
48
+ Environment variables (or the `--url`, `--token`, `--project` arguments):
49
+
50
+ | Variable | Description |
51
+ |----------|-------------|
52
+ | `ALLURE_ENDPOINT` or `ALLURE_TESTOPS_URL` | Allure TestOps base URL (e.g. `https://allure-testops.example.com`) |
53
+ | `ALLURE_TOKEN` | API token (created in Allure: profile → API Tokens) |
54
+ | `ALLURE_PROJECT_ID` | Project ID (e.g. `211`) |
55
+
56
+ **To persist them (zsh/bash),** add this to `~/.zshrc` or `~/.bashrc`:
57
+
58
+ ```bash
59
+ # Allure TestOps CLI
60
+ export ALLURE_ENDPOINT="https://allure-testops.example.com"
61
+ export ALLURE_PROJECT_ID="YOUR_PROJECT_ID"
62
+ export ALLURE_TOKEN="<YOUR_TOKEN>"
63
+ ```
64
+
65
+ ## Usage
66
+
67
+ The CLI has seven commands:
68
+
69
+ 1. **`search`** (the default) — find test cases by ID or name
70
+ 2. **`find-orphaned`** — find orphaned (stale) tests
71
+ 3. **`delete`** — delete test cases by ID
72
+ 4. **`create`** — create test cases, one by one or in bulk from a file
73
+ 5. **`launches`** — list launches, optionally filtered by name
74
+ 6. **`failures`** — failed and broken tests of a launch: message, trace, attachments
75
+ 7. **`attachments`** — list or download the attachments of a test result
76
+
77
+ **Help:**
78
+
79
+ ```bash
80
+ # General help
81
+ allure-cli
82
+ allure-cli --help
83
+
84
+ # Per-command help
85
+ allure-cli search --help
86
+ allure-cli find-orphaned --help
87
+ allure-cli delete --help
88
+ allure-cli create --help
89
+ allure-cli failures --help
90
+ ```
91
+
92
+ ### `search` — find tests
93
+
94
+ ```bash
95
+ export ALLURE_ENDPOINT=https://allure-testops.example.com
96
+ export ALLURE_PROJECT_ID=211
97
+ export ALLURE_TOKEN=<your_token>
98
+
99
+ # Search by a substring of the name
100
+ allure-cli search "User login"
101
+
102
+ # The old syntax (no command) still works
103
+ allure-cli "User login"
104
+
105
+ # Search by ID (a number)
106
+ allure-cli search 12345
107
+
108
+ # IDs only, one per line (no colors)
109
+ allure-cli search -q "User login"
110
+
111
+ # Pass the settings as arguments
112
+ allure-cli search --url https://allure-testops.example.com --project 211 --token $ALLURE_TOKEN "query"
113
+ ```
114
+
115
+ **Options:**
116
+
117
+ | Option | Description | Default |
118
+ |--------|-------------|---------|
119
+ | `--size` | Maximum number of results | 50 |
120
+ | `-q, --quiet` | Print IDs only, one per line | false |
121
+ | `--no-color` | Disable colored output | false |
122
+
123
+ **Output:**
124
+
125
+ - Normal mode: index, ID (blue), name (cyan) and `fullName` (grey) when it differs
126
+ - Quiet mode (`-q`): IDs only, one per line, no colors
127
+
128
+ **Example output:**
129
+
130
+ ```
131
+ Found 2 test cases:
132
+
133
+ 1. ID 12345 User login with valid credentials
134
+ └─ tests.auth.test_login.test_user_login_valid
135
+ 2. ID 12389 User login with OAuth provider
136
+ └─ tests.auth.oauth.test_login_oauth
137
+ ```
138
+
139
+ Where:
140
+
141
+ - `12345`, `12389` — blue, bold (the ID)
142
+ - `User login...` — cyan (the name)
143
+ - `tests.auth...` — grey (the `fullName`)
144
+
145
+ **Note:** the **ID** is the Allure ID for the `@allure.id("...")` decorator in your test code.
146
+
147
+ ### `find-orphaned` — find stale tests
148
+
149
+ Finds test cases that look orphaned: not updated for a long time, and having similar active tests (likely the same scenario under a new ID).
150
+
151
+ **The problem:** when a step title or scenario name changes in the automated tests, Allure generates a new ID. The old test stays in the database, no longer executed or maintained.
152
+
153
+ **The solution:** `find-orphaned` looks for such tests by two criteria:
154
+
155
+ 1. The test has not been updated for N days (30 by default)
156
+ 2. Other tests have similar names (similarity >= 0.75)
157
+
158
+ ```bash
159
+ # Find orphaned tests (default: inactive for 30+ days and similarity >= 0.75)
160
+ allure-cli find-orphaned
161
+
162
+ # Inactive tests only (no similarity check)
163
+ allure-cli find-orphaned --days 60
164
+
165
+ # Similar names only (no inactivity check)
166
+ allure-cli find-orphaned --similarity 0.8
167
+
168
+ # Both criteria at once
169
+ allure-cli find-orphaned --days 60 --similarity 0.8
170
+
171
+ # IDs only (for scripts)
172
+ allure-cli find-orphaned -q
173
+
174
+ # Delete the found tests interactively
175
+ allure-cli find-orphaned --delete
176
+
177
+ # Delete every found test without asking about each one
178
+ allure-cli find-orphaned --delete --yes
179
+ ```
180
+
181
+ **Options:**
182
+
183
+ | Option | Description | Default |
184
+ |--------|-------------|---------|
185
+ | `--days` | Inactivity threshold in days. On its own, filters by age only | 30 (when `--similarity` is not given) |
186
+ | `--similarity` | Name similarity threshold, 0.0-1.0. On its own, filters by similarity only | 0.75 (when `--days` is not given) |
187
+ | `--no-normalize` | Disable smart name normalization (see below) | false (normalization is on) |
188
+ | `--no-color` | Disable colored output | false |
189
+ | `--delete` | Delete the found tests interactively | false |
190
+ | `-y, --yes` | With `--delete`: delete every found test without asking | false |
191
+ | `-q, --quiet` | Print IDs only | false |
192
+
193
+ **How the flags combine:**
194
+
195
+ - No flags: both criteria apply (`--days 30 --similarity 0.75`)
196
+ - `--days N` only: finds tests inactive for N+ days, without the similarity check
197
+ - `--similarity X` only: finds tests with similar names, without the inactivity check
198
+ - Both flags: both criteria apply at once
199
+
200
+ **Smart name normalization:**
201
+
202
+ Name normalization is on by default, so duplicates are matched more reliably. The "noise" it strips:
203
+
204
+ - **Dates**: `2024-01-15`, `15/01/2024`, `20240115`
205
+ - **Timestamps**: `14:30:45`, Unix timestamps
206
+ - **Versions**: `v1.2.3`, `version 2`
207
+ - **IDs and numbers**: `test-123`, `[ID-456]`, `#789`, standalone numbers
208
+ - **Stop words**: `test`, `check`, `verify`, `should`, `when`, `then`, `given`
209
+
210
+ **Examples:**
211
+
212
+ ```
213
+ Original: "Test [TC-123] User login verification 2024-01-15"
214
+ Normalized: "user login"
215
+
216
+ Original: "Check user login #456 v2.0"
217
+ Normalized: "user login"
218
+
219
+ Result: similarity = 1.0 (identical after normalization)
220
+ ```
221
+
222
+ To turn normalization off and compare names as they are:
223
+
224
+ ```bash
225
+ allure-cli find-orphaned --no-normalize
226
+ ```
227
+
228
+ **Colored output:**
229
+
230
+ Results are colored by default for readability:
231
+
232
+ - 🟢 **Green** — high similarity (≥0.9) or fresh tests (<7 days)
233
+ - 🟡 **Yellow** — medium similarity (0.75-0.9) or medium age (7-30 days)
234
+ - 🔴 **Red** — low similarity or old tests (30+ days)
235
+ - 🔵 **Blue** — test IDs
236
+ - 🟣 **Magenta** — section headings
237
+ - ⚪ **Grey** — secondary details
238
+
239
+ Colors are disabled automatically when:
240
+
241
+ - The output is redirected to a file
242
+ - The `NO_COLOR` environment variable is set
243
+ - The `--no-color` flag is given
244
+
245
+ ```bash
246
+ # Disable colors
247
+ allure-cli find-orphaned --no-color
248
+
249
+ # Or via the environment variable
250
+ NO_COLOR=1 allure-cli find-orphaned
251
+ ```
252
+
253
+ **Example output:**
254
+
255
+ ```
256
+ Searching for orphaned tests (inactive for 30+ days, similarity >= 0.75)...
257
+
258
+ Found 2 potentially orphaned test(s):
259
+
260
+ 1. ID 12345 User login test [TC-123] 2024-01-15 (45 days)
261
+ └─ tests.auth.test_login
262
+ Similar tests:
263
+ • ID 12389 (1.00, 2d) Check user login #456 v2.0
264
+
265
+ 2. ID 11234 Payment flow test v1.2 (67 days)
266
+ └─ tests.pay.test_flow
267
+ Similar tests:
268
+ • ID 12500 (1.00, 1d) Payment flow test v2.0
269
+ ```
270
+
271
+ **Interactive deletion:**
272
+
273
+ ```bash
274
+ allure-cli find-orphaned --delete
275
+ ```
276
+
277
+ For every test found you are asked:
278
+
279
+ - `y` — delete the test
280
+ - `n` — skip it
281
+ - `a` — delete this one and all the remaining tests, without asking again
282
+ - `q` — stop
283
+
284
+ To skip the prompting entirely, add `--yes`: the list of found tests is printed first, and then all of them are deleted.
285
+
286
+ ```bash
287
+ allure-cli find-orphaned --delete --yes
288
+ ```
289
+
290
+ ### `delete` — delete tests
291
+
292
+ Deletes test cases by ID. The IDs can be given as arguments, read from a file, or both.
293
+
294
+ **File format** — either a plain text file with one ID per line, or a CSV file with an `allure_id` column (`,` and `;` separators are both detected):
295
+
296
+ ```
297
+ allure_id,name
298
+ 12345,User login with valid credentials
299
+ 12999,Payment flow test
300
+ ```
301
+
302
+ **Usage:**
303
+
304
+ ```bash
305
+ # Delete by IDs given as arguments
306
+ allure-cli delete 12345 12999
307
+
308
+ # Delete the IDs listed in a file
309
+ allure-cli delete --file test_cases.csv
310
+
311
+ # Show what would be deleted and exit
312
+ allure-cli delete --file test_cases.csv --dry-run
313
+
314
+ # Skip the confirmation prompt (dangerous!)
315
+ allure-cli delete --file test_cases.csv --yes
316
+
317
+ # Show the full list instead of truncating it
318
+ allure-cli delete --file test_cases.csv --verbose
319
+
320
+ # Skip fetching test details before deleting (faster)
321
+ allure-cli delete --file test_cases.csv --no-fetch
322
+ ```
323
+
324
+ **Options:**
325
+
326
+ | Option | Description | Default |
327
+ |--------|-------------|---------|
328
+ | `-f, --file` | Path to a file with IDs (plain text or CSV with an `allure_id` column) | — |
329
+ | `--dry-run` | Only show what would be deleted | false |
330
+ | `-y, --yes` | Skip the confirmation prompt | false |
331
+ | `-v, --verbose` | Show every test case (lists over 50 are truncated otherwise) | false |
332
+ | `--no-fetch` | Don't fetch test details, just show the IDs | false |
333
+ | `--no-color` | Disable colored output | false |
334
+
335
+ **How the deletion is sent:** when the project is known (`--project` or `ALLURE_PROJECT_ID`) and there is more than one ID, the whole batch goes out as a single bulk request. The API confirms the batch as a whole rather than each ID, so the summary says "Submitted". Without a project — and if the bulk request fails — the IDs are deleted one at a time, which costs a request per test case but reports the exact status of each.
336
+
337
+ **Example output** (bulk, the project is known):
338
+
339
+ ```
340
+ About to delete 2 test case(s):
341
+
342
+ 1. ID 12345 User login with valid credentials
343
+ └─ tests.auth.test_login.test_user_login_valid
344
+ 2. ID 12999 (not found)
345
+
346
+ Are you sure? [y/N] y
347
+ ✓ Submitted 2 test case(s) in one request
348
+
349
+ Done. Submitted: 2
350
+ ```
351
+
352
+ **Example output** (one by one, no project given):
353
+
354
+ ```
355
+ Are you sure? [y/N] y
356
+ ✓ 12345 deleted
357
+ – 12999 not found
358
+
359
+ Done. Deleted: 1, Not found: 1, Failed: 0
360
+ ```
361
+
362
+ ### `create` — create tests
363
+
364
+ Creates a single test case from the command line, or many at once from a CSV or JSON file. The two modes are mutually exclusive: pass either a name or `--file`.
365
+
366
+ **A single test case:**
367
+
368
+ ```bash
369
+ allure-cli create "User login with valid credentials" \
370
+ -d "The user signs in with a correct login and password" \
371
+ --full-name tests.auth.test_login.test_user_login_valid \
372
+ -t smoke -t regression
373
+ ```
374
+
375
+ The new ID is printed to stdout, so it can be piped further.
376
+
377
+ **CSV file** (columns: `name`, optional `description`, `full_name`, `tags`; tags are separated by `;`):
378
+
379
+ ```
380
+ name,description,tags
381
+ New test case 1,Description for test case 1,tag1;tag2
382
+ New test case 2,Description for test case 2,tag3
383
+ ```
384
+
385
+ **JSON file:**
386
+
387
+ ```json
388
+ [
389
+ {
390
+ "name": "New test case 1",
391
+ "description": "Description for test case 1",
392
+ "tags": ["tag1", "tag2"]
393
+ },
394
+ {
395
+ "name": "New test case 2",
396
+ "description": "Description for test case 2",
397
+ "tags": ["tag3"]
398
+ }
399
+ ]
400
+ ```
401
+
402
+ **Usage:**
403
+
404
+ ```bash
405
+ # Create test cases from a CSV file
406
+ allure-cli create --file test_cases.csv
407
+
408
+ # Create test cases from a JSON file
409
+ allure-cli create --file test_cases.json
410
+
411
+ # Show what would be created and exit
412
+ allure-cli create --file test_cases.csv --dry-run
413
+ ```
414
+
415
+ **Options:**
416
+
417
+ | Option | Description | Default |
418
+ |--------|-------------|---------|
419
+ | `-f, --file` | Path to a CSV or JSON file for bulk creation | — |
420
+ | `-d, --description` | Description (single test case only) | — |
421
+ | `--full-name` | Full name / path (single test case only) | — |
422
+ | `-t, --tag` | Tag, repeatable (single test case only; in bulk mode tags come from the file) | — |
423
+ | `--dry-run` | Only show what would be created | false |
424
+ | `--no-color` | Disable colored output | false |
425
+
426
+ **Example output — a single test case:**
427
+
428
+ ```
429
+ Creating test case:
430
+ Name: New test case 1
431
+ Description: Description for test case 1
432
+
433
+ ✓ Created test case:
434
+ ID 12347 New test case 1
435
+ ```
436
+
437
+ **Example output — bulk creation:**
438
+
439
+ ```
440
+ About to create 1 test case(s):
441
+
442
+ 1. New test case 1
443
+ desc: Description for test case 1
444
+ tags: tag1, tag2
445
+ ✓ 12347 New test case 1
446
+
447
+ Done. Created: 1, Failed: 0
448
+ ```
449
+
450
+ ### `launches` — list launches
451
+
452
+ ```bash
453
+ # The 10 most recent launches of the project
454
+ allure-cli launches
455
+
456
+ # Launches whose name contains a substring (newest first)
457
+ allure-cli launches "pr_15967418"
458
+
459
+ # IDs only / JSON for scripts
460
+ allure-cli launches "nightly" -q
461
+ allure-cli launches "nightly" --json
462
+ ```
463
+
464
+ | Option | Description | Default |
465
+ |--------|-------------|---------|
466
+ | `--size` | Maximum number of launches | 10 |
467
+ | `-q, --quiet` | Print IDs only, one per line | false |
468
+ | `--json` | Print launches as JSON | false |
469
+ | `--no-color` | Disable colored output | false |
470
+
471
+ **Example output:**
472
+
473
+ ```
474
+ ID 748636 2026-09-23 18:11 open user-pr_15967418-37790018 --seed d8002021
475
+ ```
476
+
477
+ ### `failures` — why a launch is red
478
+
479
+ Shows every `failed` and `broken` test result of a launch with its error message.
480
+ The launch is given by ID or by a substring of its name; the newest matching launch is used.
481
+ A number is tried as a launch ID first and then as a name, so a PR or build number found
482
+ in launch names works as is.
483
+
484
+ ```bash
485
+ # By launch ID
486
+ allure-cli failures 748636
487
+
488
+ # By a part of the launch name (e.g. a PR number)
489
+ allure-cli failures 15967418
490
+
491
+ # Full traces instead of messages
492
+ allure-cli failures 748636 --trace
493
+
494
+ # Also save the attachments (screenshots, logs) to ./allure/<test result id>/
495
+ allure-cli failures 748636 --download ./allure
496
+
497
+ # Everything, traces included, as JSON — handy for scripts and AI agents
498
+ allure-cli failures 748636 --json
499
+ ```
500
+
501
+ | Option | Description | Default |
502
+ |--------|-------------|---------|
503
+ | `--trace` | Print the full trace of every failure | false |
504
+ | `--download DIR` | Save attachments of every failure to `DIR/<test result id>/` | — |
505
+ | `--json` | Print launch, status counts and failures (with traces) as JSON | false |
506
+ | `--no-color` | Disable colored output | false |
507
+
508
+ **Example output:**
509
+
510
+ ```
511
+ Launch 748636 · 2026-09-23 18:11 · open
512
+ user-pr_15967418-37790018 --seed d8002021
513
+ failed 2 · passed 344
514
+
515
+ 1. [failed] Link a knowledge article to a ticket
516
+ └─ scenarios/admin/ticket_page/link_knowledge.py::Scenario
517
+ result 1399454750 · 40.7s
518
+ AssertionError: the knowledge base widget did not show the service
519
+ attachments: 12 → allure/1399454750
520
+ ```
521
+
522
+ ### `attachments` — files of a test result
523
+
524
+ ```bash
525
+ # List the attachments of a test result (the ID comes from `failures`)
526
+ allure-cli attachments 1399454750
527
+
528
+ # Download them
529
+ allure-cli attachments 1399454750 --download ./allure/1399454750
530
+ ```
531
+
532
+ Attachment files keep their names from Allure; when a name repeats within a test result,
533
+ the attachment ID is appended (`shot.png`, `shot_1723967328.png`). Downloading again
534
+ overwrites the same files. `--project` is not needed for this command.
535
+
536
+ ## Authorization
537
+
538
+ The scheme comes from the [TestOps documentation](https://docs.qatools.ru/api): the API token is exchanged for a JWT via `POST /api/uaa/oauth/token`, and API requests then carry an `Authorization: Bearer <jwt>` header.
539
+
540
+ The JWT is cached on disk (`~/.cache/allure_cli/` or `$XDG_CACHE_HOME/allure_cli/`) so a new one isn't requested on every call. When the API answers 401, the cache is dropped and the token is re-issued automatically.