allure-cli 0.2.2__tar.gz → 0.3.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,450 @@
1
+ Metadata-Version: 2.4
2
+ Name: allure-cli
3
+ Version: 0.3.0
4
+ Summary: CLI for Allure TestOps: search, create and delete test cases
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.
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 four 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
+
74
+ **Help:**
75
+
76
+ ```bash
77
+ # General help
78
+ allure-cli
79
+ allure-cli --help
80
+
81
+ # Per-command help
82
+ allure-cli search --help
83
+ allure-cli find-orphaned --help
84
+ allure-cli delete --help
85
+ allure-cli create --help
86
+ ```
87
+
88
+ ### `search` — find tests
89
+
90
+ ```bash
91
+ export ALLURE_ENDPOINT=https://allure-testops.example.com
92
+ export ALLURE_PROJECT_ID=211
93
+ export ALLURE_TOKEN=<your_token>
94
+
95
+ # Search by a substring of the name
96
+ allure-cli search "User login"
97
+
98
+ # The old syntax (no command) still works
99
+ allure-cli "User login"
100
+
101
+ # Search by ID (a number)
102
+ allure-cli search 12345
103
+
104
+ # IDs only, one per line (no colors)
105
+ allure-cli search -q "User login"
106
+
107
+ # Pass the settings as arguments
108
+ allure-cli search --url https://allure-testops.example.com --project 211 --token $ALLURE_TOKEN "query"
109
+ ```
110
+
111
+ **Options:**
112
+
113
+ | Option | Description | Default |
114
+ |--------|-------------|---------|
115
+ | `--size` | Maximum number of results | 50 |
116
+ | `-q, --quiet` | Print IDs only, one per line | false |
117
+ | `--no-color` | Disable colored output | false |
118
+
119
+ **Output:**
120
+
121
+ - Normal mode: index, ID (blue), name (cyan) and `fullName` (grey) when it differs
122
+ - Quiet mode (`-q`): IDs only, one per line, no colors
123
+
124
+ **Example output:**
125
+
126
+ ```
127
+ Found 2 test cases:
128
+
129
+ 1. ID 12345 User login with valid credentials
130
+ └─ tests.auth.test_login.test_user_login_valid
131
+ 2. ID 12389 User login with OAuth provider
132
+ └─ tests.auth.oauth.test_login_oauth
133
+ ```
134
+
135
+ Where:
136
+
137
+ - `12345`, `12389` — blue, bold (the ID)
138
+ - `User login...` — cyan (the name)
139
+ - `tests.auth...` — grey (the `fullName`)
140
+
141
+ **Note:** the **ID** is the Allure ID for the `@allure.id("...")` decorator in your test code.
142
+
143
+ ### `find-orphaned` — find stale tests
144
+
145
+ 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).
146
+
147
+ **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.
148
+
149
+ **The solution:** `find-orphaned` looks for such tests by two criteria:
150
+
151
+ 1. The test has not been updated for N days (30 by default)
152
+ 2. Other tests have similar names (similarity >= 0.75)
153
+
154
+ ```bash
155
+ # Find orphaned tests (default: inactive for 30+ days and similarity >= 0.75)
156
+ allure-cli find-orphaned
157
+
158
+ # Inactive tests only (no similarity check)
159
+ allure-cli find-orphaned --days 60
160
+
161
+ # Similar names only (no inactivity check)
162
+ allure-cli find-orphaned --similarity 0.8
163
+
164
+ # Both criteria at once
165
+ allure-cli find-orphaned --days 60 --similarity 0.8
166
+
167
+ # IDs only (for scripts)
168
+ allure-cli find-orphaned -q
169
+
170
+ # Delete the found tests interactively
171
+ allure-cli find-orphaned --delete
172
+
173
+ # Delete every found test without asking about each one
174
+ allure-cli find-orphaned --delete --yes
175
+ ```
176
+
177
+ **Options:**
178
+
179
+ | Option | Description | Default |
180
+ |--------|-------------|---------|
181
+ | `--days` | Inactivity threshold in days. On its own, filters by age only | 30 (when `--similarity` is not given) |
182
+ | `--similarity` | Name similarity threshold, 0.0-1.0. On its own, filters by similarity only | 0.75 (when `--days` is not given) |
183
+ | `--no-normalize` | Disable smart name normalization (see below) | false (normalization is on) |
184
+ | `--no-color` | Disable colored output | false |
185
+ | `--delete` | Delete the found tests interactively | false |
186
+ | `-y, --yes` | With `--delete`: delete every found test without asking | false |
187
+ | `-q, --quiet` | Print IDs only | false |
188
+
189
+ **How the flags combine:**
190
+
191
+ - No flags: both criteria apply (`--days 30 --similarity 0.75`)
192
+ - `--days N` only: finds tests inactive for N+ days, without the similarity check
193
+ - `--similarity X` only: finds tests with similar names, without the inactivity check
194
+ - Both flags: both criteria apply at once
195
+
196
+ **Smart name normalization:**
197
+
198
+ Name normalization is on by default, so duplicates are matched more reliably. The "noise" it strips:
199
+
200
+ - **Dates**: `2024-01-15`, `15/01/2024`, `20240115`
201
+ - **Timestamps**: `14:30:45`, Unix timestamps
202
+ - **Versions**: `v1.2.3`, `version 2`
203
+ - **IDs and numbers**: `test-123`, `[ID-456]`, `#789`, standalone numbers
204
+ - **Stop words**: `test`, `check`, `verify`, `should`, `when`, `then`, `given`
205
+
206
+ **Examples:**
207
+
208
+ ```
209
+ Original: "Test [TC-123] User login verification 2024-01-15"
210
+ Normalized: "user login"
211
+
212
+ Original: "Check user login #456 v2.0"
213
+ Normalized: "user login"
214
+
215
+ Result: similarity = 1.0 (identical after normalization)
216
+ ```
217
+
218
+ To turn normalization off and compare names as they are:
219
+
220
+ ```bash
221
+ allure-cli find-orphaned --no-normalize
222
+ ```
223
+
224
+ **Colored output:**
225
+
226
+ Results are colored by default for readability:
227
+
228
+ - 🟢 **Green** — high similarity (≥0.9) or fresh tests (<7 days)
229
+ - 🟡 **Yellow** — medium similarity (0.75-0.9) or medium age (7-30 days)
230
+ - 🔴 **Red** — low similarity or old tests (30+ days)
231
+ - 🔵 **Blue** — test IDs
232
+ - 🟣 **Magenta** — section headings
233
+ - ⚪ **Grey** — secondary details
234
+
235
+ Colors are disabled automatically when:
236
+
237
+ - The output is redirected to a file
238
+ - The `NO_COLOR` environment variable is set
239
+ - The `--no-color` flag is given
240
+
241
+ ```bash
242
+ # Disable colors
243
+ allure-cli find-orphaned --no-color
244
+
245
+ # Or via the environment variable
246
+ NO_COLOR=1 allure-cli find-orphaned
247
+ ```
248
+
249
+ **Example output:**
250
+
251
+ ```
252
+ Searching for orphaned tests (inactive for 30+ days, similarity >= 0.75)...
253
+
254
+ Found 2 potentially orphaned test(s):
255
+
256
+ 1. ID 12345 User login test [TC-123] 2024-01-15 (45 days)
257
+ └─ tests.auth.test_login
258
+ Similar tests:
259
+ • ID 12389 (1.00, 2d) Check user login #456 v2.0
260
+
261
+ 2. ID 11234 Payment flow test v1.2 (67 days)
262
+ └─ tests.pay.test_flow
263
+ Similar tests:
264
+ • ID 12500 (1.00, 1d) Payment flow test v2.0
265
+ ```
266
+
267
+ **Interactive deletion:**
268
+
269
+ ```bash
270
+ allure-cli find-orphaned --delete
271
+ ```
272
+
273
+ For every test found you are asked:
274
+
275
+ - `y` — delete the test
276
+ - `n` — skip it
277
+ - `a` — delete this one and all the remaining tests, without asking again
278
+ - `q` — stop
279
+
280
+ To skip the prompting entirely, add `--yes`: the list of found tests is printed first, and then all of them are deleted.
281
+
282
+ ```bash
283
+ allure-cli find-orphaned --delete --yes
284
+ ```
285
+
286
+ ### `delete` — delete tests
287
+
288
+ Deletes test cases by ID. The IDs can be given as arguments, read from a file, or both.
289
+
290
+ **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):
291
+
292
+ ```
293
+ allure_id,name
294
+ 12345,User login with valid credentials
295
+ 12999,Payment flow test
296
+ ```
297
+
298
+ **Usage:**
299
+
300
+ ```bash
301
+ # Delete by IDs given as arguments
302
+ allure-cli delete 12345 12999
303
+
304
+ # Delete the IDs listed in a file
305
+ allure-cli delete --file test_cases.csv
306
+
307
+ # Show what would be deleted and exit
308
+ allure-cli delete --file test_cases.csv --dry-run
309
+
310
+ # Skip the confirmation prompt (dangerous!)
311
+ allure-cli delete --file test_cases.csv --yes
312
+
313
+ # Show the full list instead of truncating it
314
+ allure-cli delete --file test_cases.csv --verbose
315
+
316
+ # Skip fetching test details before deleting (faster)
317
+ allure-cli delete --file test_cases.csv --no-fetch
318
+ ```
319
+
320
+ **Options:**
321
+
322
+ | Option | Description | Default |
323
+ |--------|-------------|---------|
324
+ | `-f, --file` | Path to a file with IDs (plain text or CSV with an `allure_id` column) | — |
325
+ | `--dry-run` | Only show what would be deleted | false |
326
+ | `-y, --yes` | Skip the confirmation prompt | false |
327
+ | `-v, --verbose` | Show every test case (lists over 50 are truncated otherwise) | false |
328
+ | `--no-fetch` | Don't fetch test details, just show the IDs | false |
329
+ | `--no-color` | Disable colored output | false |
330
+
331
+ **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.
332
+
333
+ **Example output** (bulk, the project is known):
334
+
335
+ ```
336
+ About to delete 2 test case(s):
337
+
338
+ 1. ID 12345 User login with valid credentials
339
+ └─ tests.auth.test_login.test_user_login_valid
340
+ 2. ID 12999 (not found)
341
+
342
+ Are you sure? [y/N] y
343
+ ✓ Submitted 2 test case(s) in one request
344
+
345
+ Done. Submitted: 2
346
+ ```
347
+
348
+ **Example output** (one by one, no project given):
349
+
350
+ ```
351
+ Are you sure? [y/N] y
352
+ ✓ 12345 deleted
353
+ – 12999 not found
354
+
355
+ Done. Deleted: 1, Not found: 1, Failed: 0
356
+ ```
357
+
358
+ ### `create` — create tests
359
+
360
+ 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`.
361
+
362
+ **A single test case:**
363
+
364
+ ```bash
365
+ allure-cli create "User login with valid credentials" \
366
+ -d "The user signs in with a correct login and password" \
367
+ --full-name tests.auth.test_login.test_user_login_valid \
368
+ -t smoke -t regression
369
+ ```
370
+
371
+ The new ID is printed to stdout, so it can be piped further.
372
+
373
+ **CSV file** (columns: `name`, optional `description`, `full_name`, `tags`; tags are separated by `;`):
374
+
375
+ ```
376
+ name,description,tags
377
+ New test case 1,Description for test case 1,tag1;tag2
378
+ New test case 2,Description for test case 2,tag3
379
+ ```
380
+
381
+ **JSON file:**
382
+
383
+ ```json
384
+ [
385
+ {
386
+ "name": "New test case 1",
387
+ "description": "Description for test case 1",
388
+ "tags": ["tag1", "tag2"]
389
+ },
390
+ {
391
+ "name": "New test case 2",
392
+ "description": "Description for test case 2",
393
+ "tags": ["tag3"]
394
+ }
395
+ ]
396
+ ```
397
+
398
+ **Usage:**
399
+
400
+ ```bash
401
+ # Create test cases from a CSV file
402
+ allure-cli create --file test_cases.csv
403
+
404
+ # Create test cases from a JSON file
405
+ allure-cli create --file test_cases.json
406
+
407
+ # Show what would be created and exit
408
+ allure-cli create --file test_cases.csv --dry-run
409
+ ```
410
+
411
+ **Options:**
412
+
413
+ | Option | Description | Default |
414
+ |--------|-------------|---------|
415
+ | `-f, --file` | Path to a CSV or JSON file for bulk creation | — |
416
+ | `-d, --description` | Description (single test case only) | — |
417
+ | `--full-name` | Full name / path (single test case only) | — |
418
+ | `-t, --tag` | Tag, repeatable (single test case only; in bulk mode tags come from the file) | — |
419
+ | `--dry-run` | Only show what would be created | false |
420
+ | `--no-color` | Disable colored output | false |
421
+
422
+ **Example output — a single test case:**
423
+
424
+ ```
425
+ Creating test case:
426
+ Name: New test case 1
427
+ Description: Description for test case 1
428
+
429
+ ✓ Created test case:
430
+ ID 12347 New test case 1
431
+ ```
432
+
433
+ **Example output — bulk creation:**
434
+
435
+ ```
436
+ About to create 1 test case(s):
437
+
438
+ 1. New test case 1
439
+ desc: Description for test case 1
440
+ tags: tag1, tag2
441
+ ✓ 12347 New test case 1
442
+
443
+ Done. Created: 1, Failed: 0
444
+ ```
445
+
446
+ ## Authorization
447
+
448
+ 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.
449
+
450
+ 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.