Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/taskgraph/util/taskcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def get_artifact(task_id, path):
"""
queue = get_taskcluster_client("queue")
response = queue.getLatestArtifact(task_id, path)
return _handle_artifact(path, response)
artifact_response = requests.get(response["url"])
return _handle_artifact(path, artifact_response)


def list_artifacts(task_id):
Expand Down
21 changes: 18 additions & 3 deletions test/test_util_taskcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,41 @@ def test_get_artifact(responses, root_url):

# Test text artifact
responses.get(
f"{root_url}/api/queue/v1/task/{tid}/artifacts/artifact.txt",
"http://foo.bar/artifact.txt",
body=b"foobar",
)
responses.get(
f"{root_url}/api/queue/v1/task/{tid}/artifacts/artifact.txt",
body=b'{"type": "s3", "url": "http://foo.bar/artifact.txt"}',
status=303,
headers={"Location": "http://foo.bar/artifact.txt"},
)
raw = tc.get_artifact(tid, "artifact.txt")
assert raw.read() == b"foobar"

# Test JSON artifact
responses.get("http://foo.bar/artifact.json", json={"foo": "bar"})
responses.get(
f"{root_url}/api/queue/v1/task/{tid}/artifacts/artifact.json",
json={"foo": "bar"},
body=b'{"type": "s3", "url": "http://foo.bar/artifact.json"}',
status=303,
headers={"Location": "http://foo.bar/artifact.json"},
)
result = tc.get_artifact(tid, "artifact.json")
assert result == {"foo": "bar"}

# Test YAML artifact
expected_result = {"foo": b"\xe2\x81\x83".decode()}
responses.get(
f"{root_url}/api/queue/v1/task/{tid}/artifacts/artifact.yml",
"http://foo.bar/artifact.yml",
body=b'foo: "\xe2\x81\x83"',
)
responses.get(
f"{root_url}/api/queue/v1/task/{tid}/artifacts/artifact.yml",
body=b'{"type": "s3", "url": "http://foo.bar/artifact.yml"}',
status=303,
headers={"Location": "http://foo.bar/artifact.yml"},
)
result = tc.get_artifact(tid, "artifact.yml")
assert result == expected_result

Expand Down
Loading