Skip to content

Commit 46f0b6f

Browse files
committed
add directed mappings
1 parent 3fff4de commit 46f0b6f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/anyvar/restapi/objects_router.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from http import HTTPStatus
66
from typing import Annotated, cast
77

8-
from fastapi import APIRouter, Body, HTTPException, Request, Response
8+
from fastapi import APIRouter, Body, HTTPException, Query, Request, Response
99
from fastapi.params import Path
1010
from fastapi.responses import JSONResponse, StreamingResponse
1111
from ga4gh.vrs.dataproxy import DataProxyValidationError
@@ -482,7 +482,7 @@ def get_object_mapping(
482482
],
483483
as_source: Annotated[
484484
bool,
485-
Path(
485+
Query(
486486
...,
487487
description="If `true`, get mappings where `vrs_id` corresponds to the mapping source; otherwise, get mappings where `vrs_id` is the mapping destination",
488488
),

tests/integration/restapi/objects_router/test_mappings.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,28 @@ def test_get_mapping_valid_request_found(restapi_client, stored_variation_mappin
161161
]
162162
}
163163

164+
resp = restapi_client.get(
165+
f"/object/{dest_vrs_obj['id']}/mappings/{DEFAULT_MAPPING_TYPE}",
166+
params={"as_source": False},
167+
)
168+
assert resp.status_code == HTTPStatus.OK
169+
assert resp.json() == {
170+
"mappings": [
171+
{
172+
"source_id": source_vrs_id,
173+
"dest_id": dest_vrs_obj["id"],
174+
"mapping_type": DEFAULT_MAPPING_TYPE,
175+
}
176+
]
177+
}
178+
164179

165180
def test_get_mapping_valid_request_not_found(restapi_client, stored_variation_mappings):
166181
"""Test valid request where result is not found for GET method"""
167182
source_vrs_obj, _ = stored_variation_mappings[0]
168183
source_vrs_id = source_vrs_obj["id"]
169184

170-
resp = restapi_client.get(f"/object/{source_vrs_id}/mappings/transcription")
185+
resp = restapi_client.get(f"/object/{source_vrs_id}/mappings/transcribe_to")
171186
assert resp.status_code == HTTPStatus.OK
172187
assert resp.json() == {"mappings": []}
173188

@@ -190,5 +205,5 @@ def test_get_mapping_invalid_mapping(restapi_client, stored_variation_mappings):
190205
assert resp.status_code == HTTPStatus.UNPROCESSABLE_ENTITY
191206
assert (
192207
resp.json()["detail"][0]["msg"]
193-
== "Input should be 'liftover', 'transcription' or 'translation'"
208+
== "Input should be 'liftover_to', 'transcribe_to' or 'translate_to'"
194209
)

0 commit comments

Comments
 (0)