Skip to content

Commit 9aedb21

Browse files
committed
Add test for statistics mapped target gene counts
1 parent c6a53ba commit 9aedb21

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/mavedb/routers/statistics.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ def target_genes_uniprot_identifier_counts(db: Session = Depends(get_db)) -> dic
448448
return _count_for_identifier_in_query(db, query)
449449

450450

451-
# TODO: Test coverage for this route.
452451
@router.get("/target/mapped/gene")
453452
def mapped_target_gene_counts(db: Session = Depends(get_db)) -> dict[str, int]:
454453
"""

tests/routers/test_statistics.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
TEST_MINIMAL_ACC_SCORESET,
1313
TEST_MINIMAL_SEQ_SCORESET,
1414
TEST_PUBMED_IDENTIFIER,
15+
VALID_GENE,
1516
)
1617
from tests.helpers.util import (
1718
create_acc_score_set_with_variants,
@@ -238,6 +239,20 @@ def test_target_gene_empty_field(client):
238239
assert response.status_code == 404
239240

240241

242+
####################################################################################################
243+
# Test mapped target gene statistics
244+
####################################################################################################
245+
246+
247+
def test_mapped_target_gene_counts(client, setup_router_db, setup_seq_scoreset):
248+
"""Test mapped target gene counts endpoint for published score sets."""
249+
response = client.get("/api/v1/statistics/target/mapped/gene")
250+
assert response.status_code == 200
251+
assert isinstance(response.json(), dict)
252+
assert len(response.json().keys()) == 1
253+
assert response.json()[VALID_GENE] == 1
254+
255+
241256
####################################################################################################
242257
# Test record statistics
243258
####################################################################################################
@@ -473,7 +488,7 @@ def test_mapped_variant_counts_groups(client, group_value, setup_router_db, setu
473488

474489
for key, value in response.json().items():
475490
assert isinstance(key, str)
476-
assert isinstance(value, int)
491+
assert value == 3
477492

478493

479494
@pytest.mark.parametrize("group_value", ["month", "year", None])
@@ -499,7 +514,7 @@ def test_mapped_variant_counts_current(client, current_value, setup_router_db, s
499514

500515
for key, value in response.json().items():
501516
assert isinstance(key, str)
502-
assert isinstance(value, int)
517+
assert value == 3
503518

504519

505520
@pytest.mark.parametrize("current_value", [True, False])

0 commit comments

Comments
 (0)