From 52c024d5e899fccdb5843ec4a5cfe00dc66fbc87 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Tue, 27 Jan 2026 09:22:42 -0500 Subject: [PATCH] Fix DRS tests to mock access endpoint The access_id resolution logic now prefers fetching from /access/{id} when present, so tests need to mock that endpoint rather than providing inline access_url in the object response. --- test/unit/files/test_drs.py | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/test/unit/files/test_drs.py b/test/unit/files/test_drs.py index 704631f1047..e00832f681d 100644 --- a/test/unit/files/test_drs.py +++ b/test/unit/files/test_drs.py @@ -28,16 +28,20 @@ def test_file_source_drs_http(): "access_methods": [ { "type": "https", - "access_url": { - "url": "https://my.respository.org/myfile.txt", - "headers": ["Authorization: Basic Z2E0Z2g6ZHJz"], - }, "access_id": "1234", } ], } return (200, {}, json.dumps(data)) + def access_handler(request): + assert request.headers["Authorization"] == "Bearer IBearTokens" + access_data = { + "url": "https://my.respository.org/myfile.txt", + "headers": ["Authorization: Basic Z2E0Z2g6ZHJz"], + } + return (200, {}, json.dumps(access_data)) + responses.add_callback( responses.GET, "https://drs.example.org/ga4gh/drs/v1/objects/314159", @@ -45,6 +49,13 @@ def test_file_source_drs_http(): content_type="application/json", ) + responses.add_callback( + responses.GET, + "https://drs.example.org/ga4gh/drs/v1/objects/314159/access/1234", + callback=access_handler, + content_type="application/json", + ) + test_url = "drs://drs.example.org/314159" def check_specific_header(request, **kwargs): @@ -76,9 +87,6 @@ def test_file_source_drs_s3(): "access_methods": [ { "type": "s3", - "access_url": { - "url": "s3://ga4gh-demo-data/phenopackets/Cao-2018-TGFBR2-Patient_4.json", - }, "access_id": "1234", "region": "us-east-1", } @@ -86,6 +94,13 @@ def test_file_source_drs_s3(): } return (200, {}, json.dumps(data)) + def access_handler(request): + assert request.headers["Authorization"] == "Bearer IBearTokens" + access_data = { + "url": "s3://ga4gh-demo-data/phenopackets/Cao-2018-TGFBR2-Patient_4.json", + } + return (200, {}, json.dumps(access_data)) + responses.add_callback( responses.GET, "https://drs.example.org/ga4gh/drs/v1/objects/314160", @@ -93,6 +108,13 @@ def test_file_source_drs_s3(): content_type="application/json", ) + responses.add_callback( + responses.GET, + "https://drs.example.org/ga4gh/drs/v1/objects/314160/access/1234", + callback=access_handler, + content_type="application/json", + ) + test_url = "drs://drs.example.org/314160" file_sources = configured_file_sources(FILE_SOURCES_CONF) user_context = user_context_fixture(file_sources=file_sources)