Skip to content

Commit 8725cde

Browse files
committed
Test every variation on biolink_type query.
1 parent 713b998 commit 8725cde

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

api/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ async def lookup(string: str,
422422
taxa_filters.append(f'taxa:"{taxon}"')
423423

424424
# We also need to include entries that don't have taxa specified.
425-
taxa_filters.append('-taxa:[* TO *]')
425+
taxa_filters.append('taxon_specific:false')
426426

427427
# Combine all taxa filters.
428428
filters.append('(' + " OR ".join(taxa_filters) + ')')
@@ -467,7 +467,7 @@ async def lookup(string: str,
467467
"fields": "*, score",
468468
"params": inner_params,
469469
}
470-
logging.debug(f"Query: {json.dumps(params, indent=2)}")
470+
print(f"Query: {json.dumps(params, indent=2)}")
471471

472472
query_url = f"http://{SOLR_HOST}:{SOLR_PORT}/solr/name_lookup/select"
473473
async with httpx.AsyncClient(timeout=None) as client:

tests/test_service.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,25 @@ def test_only_taxa_queries():
238238
'string': 'FTD',
239239
'only_taxa': 'NCBITaxon:9031',
240240
})
241-
results_all_ftd = response.json()
242-
assert len(results_all_ftd) == 2
243-
assert results_all_ftd[0]['curie'] == 'NCBIGene:378899'
244-
assert results_all_ftd[1]['curie'] == 'MONDO:0010857'
241+
results_ftd_with_only_taxon = response.json()
242+
assert len(results_ftd_with_only_taxon) == 2
243+
assert results_ftd_with_only_taxon[0]['curie'] == 'NCBIGene:378899'
244+
assert results_ftd_with_only_taxon[1]['curie'] == 'MONDO:0010857'
245+
246+
response = client.get("/lookup", params={
247+
'string': 'FTD',
248+
'only_taxa': 'NCBITaxon:9031',
249+
'biolink_type': 'biolink:Gene'
250+
})
251+
results_ftd_gene_with_only_taxon = response.json()
252+
assert len(results_ftd_gene_with_only_taxon) == 1
253+
assert results_ftd_gene_with_only_taxon[0]['curie'] == 'NCBIGene:378899'
254+
255+
response = client.get("/lookup", params={
256+
'string': 'FTD',
257+
'only_taxa': 'NCBITaxon:9031',
258+
'biolink_type': 'biolink:Disease'
259+
})
260+
results_ftd_disease_with_only_taxon = response.json()
261+
assert len(results_ftd_disease_with_only_taxon) == 1
262+
assert results_ftd_disease_with_only_taxon[0]['curie'] == 'MONDO:0010857'

0 commit comments

Comments
 (0)