diff --git a/src/taskgraph/util/taskcluster.py b/src/taskgraph/util/taskcluster.py index f1a31511..85f6bc73 100644 --- a/src/taskgraph/util/taskcluster.py +++ b/src/taskgraph/util/taskcluster.py @@ -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): diff --git a/test/test_util_taskcluster.py b/test/test_util_taskcluster.py index 01d38421..bdff659e 100644 --- a/test/test_util_taskcluster.py +++ b/test/test_util_taskcluster.py @@ -110,16 +110,25 @@ 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"} @@ -127,9 +136,15 @@ def test_get_artifact(responses, root_url): # 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