itqan-cli 0.7.0__tar.gz → 0.8.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.
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/CHANGELOG.md +17 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/PKG-INFO +1 -1
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/pyproject.toml +1 -1
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/browse.py +5 -2
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/client.py +43 -3
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/main.py +10 -2
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_browse.py +36 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_cli_integration.py +34 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_client.py +96 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/.gitignore +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/LICENSE +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/README.md +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/RELEASING.md +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/dart/.gitignore +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/dart/README.md +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/dart/analysis_options.yaml +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/dart/bin/itqan.dart +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/dart/lib/itqan_cli.dart +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/dart/lib/src/launcher.dart +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/dart/lib/src/version.dart +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/dart/pubspec.yaml +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/dart/test/launcher_test.dart +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/npm/README.md +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/npm/bin/itqan.js +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/scripts/dart_package.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/scripts/homebrew_formula.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/scripts/npm_packages.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/__init__.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/__main__.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/add.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/autoupdate.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/columns_comment.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/credentials.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/downloader.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/exceptions.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/flutter.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/init_template.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/lockfile.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/manifest.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/progress.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/semver.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/updates.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/src/itqan_cli/usage.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/__init__.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/conftest.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_access.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_add.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_assets_dir.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_autoupdate.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_columns_comment.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_dart_package.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_downloader.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_entry_points.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_flutter.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_homebrew_formula.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_init.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_install_progress.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_languages.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_lockfile.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_login.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_manifest.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_npm_packages.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_progress.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_updates.py +0 -0
- {itqan_cli-0.7.0 → itqan_cli-0.8.0}/tests/test_usage.py +0 -0
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## v0.8.0 (2026-11-29)
|
|
2
|
+
|
|
3
|
+
### Feat
|
|
4
|
+
|
|
5
|
+
- `itqan browse` shows a recitation's timing level when the registry sends it: the CATEGORY column
|
|
6
|
+
reads `recitation (ayah timing)`, and `--json` includes `"timing_level"`. Nothing changes when
|
|
7
|
+
the registry doesn't send the field.
|
|
8
|
+
|
|
9
|
+
### Fix
|
|
10
|
+
|
|
11
|
+
- when the registry rejects your API key (not valid, revoked or expired), every command now says
|
|
12
|
+
so in one message and tells you to run `itqan login` with a new key, or `itqan logout` (and drop
|
|
13
|
+
`--api-key` / `ITQAN_API_KEY`) to continue without one. A failed `itqan install` no longer makes
|
|
14
|
+
a second catalog call that would fail on the same key.
|
|
15
|
+
- "Cannot satisfy version constraints" is now picked from the registry's error name, so it still
|
|
16
|
+
shows when the registry reports these errors with status 400 instead of 422.
|
|
17
|
+
|
|
1
18
|
## v0.7.0 (2026-11-14)
|
|
2
19
|
|
|
3
20
|
### BREAKING CHANGE
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: itqan-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: Itqan Quranic Asset Manager: install and pin Itqan Quranic assets in your project.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Itqan-community/itqan-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/Itqan-community/itqan-cli
|
|
@@ -208,8 +208,10 @@ def access_footer(packages: list[CatalogPackage], has_api_key: bool) -> list[str
|
|
|
208
208
|
|
|
209
209
|
|
|
210
210
|
def kind_text(package: CatalogPackage) -> str:
|
|
211
|
-
"""The category, narrowed by the tags of a text asset
|
|
212
|
-
|
|
211
|
+
"""The category, narrowed by the tags of a text asset (`text: tafsir`) and the
|
|
212
|
+
timing level of a timed recitation (`recitation (ayah timing)`)."""
|
|
213
|
+
kind = f"{package.category}: {', '.join(package.tags)}" if package.tags else package.category
|
|
214
|
+
return f"{kind} ({package.timing_level} timing)" if package.timing_level else kind
|
|
213
215
|
|
|
214
216
|
|
|
215
217
|
def render_table(packages: list[CatalogPackage], targets: set[Target]) -> str:
|
|
@@ -237,6 +239,7 @@ def to_json(packages: list[CatalogPackage], targets: set[Target]) -> list[dict]:
|
|
|
237
239
|
"name": package.name,
|
|
238
240
|
"category": package.category,
|
|
239
241
|
"tags": list(package.tags),
|
|
242
|
+
"timing_level": package.timing_level,
|
|
240
243
|
"is_open_access": package.is_open_access,
|
|
241
244
|
"access": package.access,
|
|
242
245
|
"access_request_url": package.access_request_url,
|
|
@@ -65,6 +65,9 @@ class CatalogPackage:
|
|
|
65
65
|
access_request_url: str | None = None
|
|
66
66
|
# Text assets: what kind of text it holds (tafsir, translation, ...). Slugs only.
|
|
67
67
|
tags: tuple[str, ...] = ()
|
|
68
|
+
# Recitations: the finest timing they have (ayah | word | sentence); None without
|
|
69
|
+
# timings, for other categories, or from a registry that predates it.
|
|
70
|
+
timing_level: str | None = None
|
|
68
71
|
|
|
69
72
|
|
|
70
73
|
@dataclass(frozen=True, slots=True)
|
|
@@ -124,6 +127,39 @@ def _error_detail(response: requests.Response) -> str:
|
|
|
124
127
|
return f": {reason}" if reason else ""
|
|
125
128
|
|
|
126
129
|
|
|
130
|
+
INVALID_API_KEY = "invalid_api_key"
|
|
131
|
+
INVALID_API_KEY_MESSAGE = (
|
|
132
|
+
"The registry rejected your API key: it is not valid, was revoked or has expired. "
|
|
133
|
+
"Run `itqan login` with a new key, or `itqan logout` (and drop --api-key / ITQAN_API_KEY) "
|
|
134
|
+
"to continue without one."
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# The registry's version-resolution errors. Older registries sent them with 422,
|
|
139
|
+
# newer ones with 400 (like every other validation error), so key on the name.
|
|
140
|
+
VERSION_CONSTRAINT_ERRORS = frozenset(
|
|
141
|
+
{
|
|
142
|
+
"invalid_version_constraint",
|
|
143
|
+
"unsatisfiable_version_constraint",
|
|
144
|
+
"no_eligible_package_versions",
|
|
145
|
+
"canonical_version_collision",
|
|
146
|
+
"category_not_installable",
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def _raise_if_invalid_key(response: requests.Response) -> None:
|
|
152
|
+
"""Turn the registry's `401 invalid_api_key` into one clear, actionable error."""
|
|
153
|
+
if response.status_code != 401:
|
|
154
|
+
return
|
|
155
|
+
try:
|
|
156
|
+
body = response.json()
|
|
157
|
+
except ValueError:
|
|
158
|
+
return
|
|
159
|
+
if isinstance(body, dict) and body.get("error_name") == INVALID_API_KEY:
|
|
160
|
+
raise RegistryApiError(INVALID_API_KEY_MESSAGE, status_code=401, error_name=INVALID_API_KEY)
|
|
161
|
+
|
|
162
|
+
|
|
127
163
|
class RegistryClient:
|
|
128
164
|
"""HTTP Client for Itqan Package Registry API."""
|
|
129
165
|
|
|
@@ -232,6 +268,7 @@ class RegistryClient:
|
|
|
232
268
|
)
|
|
233
269
|
except requests.RequestException as exc:
|
|
234
270
|
raise RegistryApiError(f"Failed to connect to package registry at {self.base_url}: {exc}") from exc
|
|
271
|
+
_raise_if_invalid_key(response)
|
|
235
272
|
if response.status_code != 200:
|
|
236
273
|
raise RegistryApiError(
|
|
237
274
|
f"Registry catalog request failed with status {response.status_code}{_error_detail(response)}",
|
|
@@ -249,6 +286,7 @@ class RegistryClient:
|
|
|
249
286
|
access=item.get("access"),
|
|
250
287
|
access_request_url=item.get("access_request_url"),
|
|
251
288
|
tags=tuple(tag_item["slug"] for tag_item in item.get("tags") or ()),
|
|
289
|
+
timing_level=item.get("timing_level"),
|
|
252
290
|
languages=tuple(
|
|
253
291
|
CatalogLanguage(
|
|
254
292
|
language=lang["language"],
|
|
@@ -276,6 +314,7 @@ class RegistryClient:
|
|
|
276
314
|
response = self.session.get(f"{self.base_url}/packages/me/", headers=self._headers(), timeout=self.timeout)
|
|
277
315
|
except requests.RequestException as exc:
|
|
278
316
|
raise RegistryApiError(f"Failed to connect to package registry at {self.base_url}: {exc}") from exc
|
|
317
|
+
_raise_if_invalid_key(response)
|
|
279
318
|
if response.status_code != 200:
|
|
280
319
|
raise RegistryApiError(
|
|
281
320
|
f"API key check failed with status {response.status_code}{_error_detail(response)}",
|
|
@@ -359,6 +398,7 @@ class RegistryClient:
|
|
|
359
398
|
raise RegistryApiError(f"Failed to parse registry API response: {exc}") from exc
|
|
360
399
|
|
|
361
400
|
# Handle API Error responses
|
|
401
|
+
_raise_if_invalid_key(response)
|
|
362
402
|
status_code = response.status_code
|
|
363
403
|
error_name: str | None = None
|
|
364
404
|
message = f"Registry request failed with status {status_code}"
|
|
@@ -371,7 +411,9 @@ class RegistryClient:
|
|
|
371
411
|
except Exception:
|
|
372
412
|
message = response.text or message
|
|
373
413
|
|
|
374
|
-
if status_code ==
|
|
414
|
+
if error_name in VERSION_CONSTRAINT_ERRORS or status_code == 422:
|
|
415
|
+
friendly_msg = f"Cannot satisfy version constraints: {message}"
|
|
416
|
+
elif status_code == 401:
|
|
375
417
|
friendly_msg = f"Authentication required (API key missing or invalid): {message}"
|
|
376
418
|
elif status_code == 403:
|
|
377
419
|
friendly_msg = f"Access denied for requested assets (approved access required): {message}"
|
|
@@ -382,8 +424,6 @@ class RegistryClient:
|
|
|
382
424
|
f"Version removed from the registry: {message} "
|
|
383
425
|
"Run `itqan install --force` to resolve another version, or change it in your manifest."
|
|
384
426
|
)
|
|
385
|
-
elif status_code == 422:
|
|
386
|
-
friendly_msg = f"Cannot satisfy version constraints: {message}"
|
|
387
427
|
else:
|
|
388
428
|
friendly_msg = f"Registry API error [{status_code}]: {message}"
|
|
389
429
|
|
|
@@ -13,7 +13,14 @@ import tempfile
|
|
|
13
13
|
import click
|
|
14
14
|
|
|
15
15
|
from itqan_cli import add, autoupdate, browse, credentials, flutter as flutter_pubspec, progress, updates
|
|
16
|
-
from itqan_cli.client import
|
|
16
|
+
from itqan_cli.client import (
|
|
17
|
+
DEFAULT_REGISTRY_URL,
|
|
18
|
+
INVALID_API_KEY,
|
|
19
|
+
CatalogLanguage,
|
|
20
|
+
CatalogPackage,
|
|
21
|
+
RegistryClient,
|
|
22
|
+
ResolvedAssetPayload,
|
|
23
|
+
)
|
|
17
24
|
from itqan_cli.columns_comment import refresh_blocks
|
|
18
25
|
from itqan_cli.downloader import AssetDownloader
|
|
19
26
|
from itqan_cli.exceptions import ItqanCliError, ManifestError, RegistryApiError
|
|
@@ -309,7 +316,8 @@ def install_command(
|
|
|
309
316
|
sys.exit(exit_code)
|
|
310
317
|
except ItqanCliError as exc:
|
|
311
318
|
click.echo(f"Error: {exc.message}", err=True)
|
|
312
|
-
|
|
319
|
+
# A rejected key fails every catalog call too, so there is nothing more to explain.
|
|
320
|
+
if isinstance(exc, RegistryApiError) and exc.status_code in (401, 403) and exc.error_name != INVALID_API_KEY:
|
|
313
321
|
_explain_access(Path(manifest_path), registry_url, api_key)
|
|
314
322
|
sys.exit(exc.exit_code)
|
|
315
323
|
except Exception as exc:
|
|
@@ -198,6 +198,42 @@ def test_render_table_where_no_published_version_should_not_mark_it_in_manifest(
|
|
|
198
198
|
assert "* " not in row
|
|
199
199
|
|
|
200
200
|
|
|
201
|
+
def test_kind_text_where_recitation_has_timing_level_should_show_it():
|
|
202
|
+
# Arrange
|
|
203
|
+
package = CatalogPackage(
|
|
204
|
+
slug="husary", name="Husary", category="recitation", is_open_access=True, languages=(), timing_level="ayah"
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
# Act
|
|
208
|
+
kind = browse.kind_text(package)
|
|
209
|
+
|
|
210
|
+
# Assert
|
|
211
|
+
assert kind == "recitation (ayah timing)"
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def test_kind_text_where_no_timing_level_should_show_only_the_category():
|
|
215
|
+
# Arrange
|
|
216
|
+
package = _package(SINGLE)
|
|
217
|
+
|
|
218
|
+
# Act
|
|
219
|
+
kind = browse.kind_text(package)
|
|
220
|
+
|
|
221
|
+
# Assert
|
|
222
|
+
assert kind == "mushaf"
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
@responses.activate
|
|
226
|
+
def test_list_packages_where_catalog_reports_timing_level_should_parse_it():
|
|
227
|
+
# Arrange
|
|
228
|
+
_mock_catalog([{**SINGLE, "timing_level": "ayah"}, MULTILINGUAL])
|
|
229
|
+
|
|
230
|
+
# Act
|
|
231
|
+
packages = RegistryClient(REGISTRY).list_packages(page_size=50)
|
|
232
|
+
|
|
233
|
+
# Assert
|
|
234
|
+
assert [p.timing_level for p in packages] == ["ayah", None]
|
|
235
|
+
|
|
236
|
+
|
|
201
237
|
# --- editing the manifest -------------------------------------------------------
|
|
202
238
|
|
|
203
239
|
|
|
@@ -154,6 +154,40 @@ assets:
|
|
|
154
154
|
assert "Authentication required" in result.output
|
|
155
155
|
|
|
156
156
|
|
|
157
|
+
@responses.activate
|
|
158
|
+
def test_install_command_where_api_key_rejected_should_tell_how_to_fix_it_without_more_calls(
|
|
159
|
+
runner: CliRunner, tmp_path: Path
|
|
160
|
+
):
|
|
161
|
+
manifest_path = tmp_path / "itqan-assets.yaml"
|
|
162
|
+
manifest_path.write_bytes(b"""schema_version: 1
|
|
163
|
+
assets:
|
|
164
|
+
quran-uthmani-hafs:
|
|
165
|
+
version: "^2.1.0"
|
|
166
|
+
""")
|
|
167
|
+
registry_url = "https://api.itqan.dev/api"
|
|
168
|
+
responses.add(
|
|
169
|
+
responses.POST,
|
|
170
|
+
f"{registry_url}/packages/resolve/manifest/",
|
|
171
|
+
json={
|
|
172
|
+
"error_name": "invalid_api_key",
|
|
173
|
+
"message": "The API key is not valid or has been revoked.",
|
|
174
|
+
"extra": None,
|
|
175
|
+
},
|
|
176
|
+
status=401,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
result = runner.invoke(
|
|
180
|
+
cli,
|
|
181
|
+
["install", "--manifest", str(manifest_path), "--registry-url", registry_url, "--api-key", "stale.key"],
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
assert result.exit_code == 1
|
|
185
|
+
assert "rejected your API key" in result.output
|
|
186
|
+
assert "itqan login" in result.output
|
|
187
|
+
# No catalog lookup to explain access: it would fail on the same key.
|
|
188
|
+
assert [call.request.method for call in responses.calls] == ["POST"]
|
|
189
|
+
|
|
190
|
+
|
|
157
191
|
@responses.activate
|
|
158
192
|
def test_install_command_where_locked_version_withdrawn_should_install_it_and_warn(runner: CliRunner, tmp_path: Path):
|
|
159
193
|
manifest_path = tmp_path / "itqan-assets.yaml"
|
|
@@ -60,6 +60,46 @@ def test_resolve_manifest_where_api_key_missing_should_raise_registry_api_error_
|
|
|
60
60
|
assert "Authentication required" in exc_info.value.message
|
|
61
61
|
|
|
62
62
|
|
|
63
|
+
@responses.activate
|
|
64
|
+
def test_resolve_manifest_where_api_key_rejected_should_raise_invalid_api_key_error():
|
|
65
|
+
base_url = "https://api.itqan.dev/api"
|
|
66
|
+
responses.add(
|
|
67
|
+
responses.POST,
|
|
68
|
+
f"{base_url}/packages/resolve/manifest/",
|
|
69
|
+
json={"error_name": "invalid_api_key", "message": "The API key has expired.", "extra": None},
|
|
70
|
+
status=401,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
client = RegistryClient(base_url=base_url, api_key="stale.key")
|
|
74
|
+
with pytest.raises(RegistryApiError) as exc_info:
|
|
75
|
+
client.resolve_manifest({"quran": "1.0.0"})
|
|
76
|
+
|
|
77
|
+
assert (exc_info.value.status_code, exc_info.value.error_name) == (401, "invalid_api_key")
|
|
78
|
+
assert "itqan login" in exc_info.value.message
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@responses.activate
|
|
82
|
+
def test_list_all_packages_where_api_key_rejected_should_raise_invalid_api_key_error():
|
|
83
|
+
base_url = "https://api.itqan.dev/api"
|
|
84
|
+
responses.add(
|
|
85
|
+
responses.GET,
|
|
86
|
+
f"{base_url}/packages/",
|
|
87
|
+
json={
|
|
88
|
+
"error_name": "invalid_api_key",
|
|
89
|
+
"message": "The API key is not valid or has been revoked.",
|
|
90
|
+
"extra": None,
|
|
91
|
+
},
|
|
92
|
+
status=401,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
client = RegistryClient(base_url=base_url, api_key="stale.key")
|
|
96
|
+
with pytest.raises(RegistryApiError) as exc_info:
|
|
97
|
+
client.list_all_packages()
|
|
98
|
+
|
|
99
|
+
assert (exc_info.value.status_code, exc_info.value.error_name) == (401, "invalid_api_key")
|
|
100
|
+
assert "rejected your API key" in exc_info.value.message
|
|
101
|
+
|
|
102
|
+
|
|
63
103
|
@responses.activate
|
|
64
104
|
def test_resolve_manifest_where_asset_access_denied_should_raise_registry_api_error_403():
|
|
65
105
|
base_url = "https://api.itqan.dev/api"
|
|
@@ -96,6 +136,62 @@ def test_resolve_manifest_where_no_version_satisfies_constraint_should_raise_reg
|
|
|
96
136
|
assert "Cannot satisfy version constraints" in exc_info.value.message
|
|
97
137
|
|
|
98
138
|
|
|
139
|
+
@pytest.mark.parametrize("status", [400, 422])
|
|
140
|
+
@pytest.mark.parametrize(
|
|
141
|
+
"error_name",
|
|
142
|
+
[
|
|
143
|
+
"invalid_version_constraint",
|
|
144
|
+
"unsatisfiable_version_constraint",
|
|
145
|
+
"no_eligible_package_versions",
|
|
146
|
+
"canonical_version_collision",
|
|
147
|
+
"category_not_installable",
|
|
148
|
+
],
|
|
149
|
+
)
|
|
150
|
+
@responses.activate
|
|
151
|
+
def test_resolve_manifest_where_version_constraint_error_should_explain_it_on_old_and_new_registries(
|
|
152
|
+
error_name, status
|
|
153
|
+
):
|
|
154
|
+
# Arrange: the registry moved these errors from 422 to 400; the name stays the same
|
|
155
|
+
base_url = "https://api.itqan.dev/api"
|
|
156
|
+
responses.add(
|
|
157
|
+
responses.POST,
|
|
158
|
+
f"{base_url}/packages/resolve/manifest/",
|
|
159
|
+
json={"error_name": error_name, "message": "No matching version", "extra": None},
|
|
160
|
+
status=status,
|
|
161
|
+
)
|
|
162
|
+
client = RegistryClient(base_url=base_url)
|
|
163
|
+
|
|
164
|
+
# Act
|
|
165
|
+
with pytest.raises(RegistryApiError) as exc_info:
|
|
166
|
+
client.resolve_manifest({"quran": "^99.0.0"})
|
|
167
|
+
|
|
168
|
+
# Assert
|
|
169
|
+
assert exc_info.value.message == "Cannot satisfy version constraints: No matching version"
|
|
170
|
+
assert exc_info.value.status_code == status
|
|
171
|
+
assert exc_info.value.error_name == error_name
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
@responses.activate
|
|
175
|
+
def test_resolve_manifest_where_other_400_error_should_not_blame_version_constraints():
|
|
176
|
+
# Arrange
|
|
177
|
+
base_url = "https://api.itqan.dev/api"
|
|
178
|
+
responses.add(
|
|
179
|
+
responses.POST,
|
|
180
|
+
f"{base_url}/packages/resolve/manifest/",
|
|
181
|
+
json={"error_name": "validation_error", "message": "Invalid Input", "extra": None},
|
|
182
|
+
status=400,
|
|
183
|
+
)
|
|
184
|
+
client = RegistryClient(base_url=base_url)
|
|
185
|
+
|
|
186
|
+
# Act
|
|
187
|
+
with pytest.raises(RegistryApiError) as exc_info:
|
|
188
|
+
client.resolve_manifest({"quran": "^1.0.0"})
|
|
189
|
+
|
|
190
|
+
# Assert
|
|
191
|
+
assert exc_info.value.message == "Registry API error [400]: Invalid Input"
|
|
192
|
+
assert exc_info.value.error_name == "validation_error"
|
|
193
|
+
|
|
194
|
+
|
|
99
195
|
def test_registry_client_where_no_base_url_given_should_default_to_production():
|
|
100
196
|
# Arrange / Act
|
|
101
197
|
client = RegistryClient()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|