Skip to content

Commit

Permalink
chore: use artifact in fetch-service context
Browse files Browse the repository at this point in the history
Signed-off-by: Dariusz Duda <[email protected]>
  • Loading branch information
dariuszd21 committed Dec 10, 2024
1 parent 46ee540 commit 628c248
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion craft_application/models/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def from_session_report(cls, report: dict[str, Any]) -> list[Self]:
"""Create session manifests from a fetch-session report."""
artifacts: list[Self] = []

for artifact in report["artefacts"]:
for artifact in report["artifacts"]:
# Figure out if the artifact was rejected, and for which reasons
rejected = artifact.get("result") == "Rejected"
reasons: set[str] = set()
Expand Down
8 changes: 4 additions & 4 deletions tests/data/manifest/session-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"comment": "Metadata format is unstable and may change without prior notice.",
"session-id": "f17e28e952c84d7c955a1eb5277de201",
"policy": "",
"artefacts": [
"artifacts": [
{
"metadata": {
"type": "application/x.apt.translation",
Expand Down Expand Up @@ -65,7 +65,7 @@
},
{
"A NON-SHALLOW GIT CLONE": true,
"artefact-metadata-version": "0.1",
"artifact-metadata-version": "0.1",
"request-inspection": {
"git.upload-pack": {
"opinion": "Rejected",
Expand Down Expand Up @@ -107,7 +107,7 @@
},
{
"A GO BUILD WITHOUT GOPROXY=DIRECT": true,
"artefact-metadata-version": "0.1",
"artifact-metadata-version": "0.1",
"request-inspection": {
"default": {
"opinion": "Unknown",
Expand All @@ -117,7 +117,7 @@
"response-inspection": {
"default": {
"opinion": "Unknown",
"reason": "the artefact format is unknown"
"reason": "the artifact format is unknown"
}
},
"result": "Rejected",
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/services/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_create_teardown_session(
report = app_service.teardown_session()
assert len(fetch.get_service_status()["active-sessions"]) == 0

assert "artefacts" in report
assert "artifacts" in report


def test_service_logging(app_service, mocker, tmp_path, monkeypatch, mock_instance):
Expand Down Expand Up @@ -315,19 +315,19 @@ def test_build_instance_integration(
finally:
report = app_service.teardown_session()

artefacts_and_types: list[tuple[str, str]] = []
artifacts_and_types: list[tuple[str, str]] = []

for artefact in report["artefacts"]:
metadata_name = artefact["metadata"]["name"]
metadata_type = artefact["metadata"]["type"]
for artifact in report["artifacts"]:
metadata_name = artifact["metadata"]["name"]
metadata_type = artifact["metadata"]["type"]

artefacts_and_types.append((metadata_name, metadata_type))
artifacts_and_types.append((metadata_name, metadata_type))

# Check that the installation of the "hello" deb went through the inspector.
assert ("hello", "application/vnd.debian.binary-package") in artefacts_and_types
assert ("hello", "application/vnd.debian.binary-package") in artifacts_and_types

# Check that the fetching of the "craft-application" wheel went through the inspector.
assert ("craft-application", "application/x.python.wheel") in artefacts_and_types
assert ("craft-application", "application/x.python.wheel") in artifacts_and_types

manifest_path = tmp_path / f"{fake_project.name}_{fake_project.version}_foo.json"
assert manifest_path.is_file()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/models/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ def test_session_report_rejections(session_report):
"git repository does not contain a go.mod file",
]
assert rejected[1].rejection_reasons == [
"the artefact format is unknown",
"the artifact format is unknown",
"the request was not recognized by any format inspector",
]
2 changes: 1 addition & 1 deletion tests/unit/services/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def temporarily_pull_file(*, source, missing_ok):
- git repository does not contain a go.mod file
- url: https://proxy.golang.org:443/github.com/go-mmap/mmap/@v/v0.7.0.mod
reasons:
- the artefact format is unknown
- the artifact format is unknown
- the request was not recognized by any format inspector
This build will fail on 'strict' fetch-service sessions.
"""
Expand Down

0 comments on commit 628c248

Please sign in to comment.