Skip to content

Commit 61d8ce6

Browse files
committed
fix: mock UTABase fetch in hgvs_genes test for consistent results
1 parent dee025c commit 61d8ce6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/routers/test_hgvs.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
fastapi = pytest.importorskip("fastapi")
1111
hgvs = pytest.importorskip("hgvs")
1212

13-
from tests.helpers.constants import TEST_NT_CDOT_TRANSCRIPT, VALID_NT_ACCESSION, VALID_GENE
13+
from hgvs.dataproviders.uta import UTABase
14+
15+
from tests.helpers.constants import TEST_NT_CDOT_TRANSCRIPT, VALID_GENE, VALID_NT_ACCESSION
1416

1517
VALID_MAJOR_ASSEMBLY = "GRCh38"
1618
VALID_MINOR_ASSEMBLY = "GRCh38.p3"
@@ -85,9 +87,12 @@ def test_hgvs_accessions_invalid(client, setup_router_db):
8587

8688

8789
def test_hgvs_genes(client, setup_router_db):
88-
response = client.get("/api/v1/hgvs/genes")
89-
assert response.status_code == 200
90-
assert VALID_GENE in response.json()
90+
with patch.object(UTABase, "_fetchall") as mock_fetchall:
91+
mock_fetchall.return_value = (("BRCA1",), ("TP53",), (VALID_GENE,))
92+
93+
response = client.get("/api/v1/hgvs/genes")
94+
assert response.status_code == 200
95+
assert VALID_GENE in response.json()
9196

9297

9398
def test_hgvs_gene_info_valid(client, setup_router_db):

0 commit comments

Comments
 (0)