Skip to content

Commit 32be602

Browse files
committed
1 parent 786a0ed commit 32be602

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

datanator_rest_api/routes/taxon.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class canon_rank_distance_by_name:
2323

2424
def get(name):
2525
results = t_manager.get_canon_rank_distance_by_name(name, front_end=True)
26+
if results == [{name: 0}]:
27+
return {"code": 404, "message": "Taxon not found."}, 404
2628
return results
2729

2830

datanator_rest_api/spec/DatanatorAPI.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,6 +1865,12 @@ paths:
18651865
schema:
18661866
$ref: '#/components/schemas/TxnCanonRankDistance'
18671867
description: OK
1868+
'404':
1869+
content:
1870+
application/json:
1871+
schema:
1872+
$ref: '#/components/schemas/GeneralError'
1873+
description: Not found
18681874
summary: |-
18691875
Given the species name, return canonically-ranked ancestors
18701876
along the lineage and their non-canonical distances.

datanator_rest_api/spec/paths/taxon.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ canon_rank_distance_by_name:
3939
application/json:
4040
schema:
4141
$ref: "#/components/schemas/TxnCanonRankDistance"
42+
"404":
43+
description: Not found
44+
content:
45+
application/json:
46+
schema:
47+
$ref: "#/components/schemas/GeneralError"
4248

4349
is_child:
4450
get:

tests/routes/test_taxon.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ def test_canon_rank_distance(self):
2222
def test_canon_rank_distance_by_name(self):
2323
result = self.client.get('/taxon/canon_rank_distance_by_name/?name=homo sapiens')
2424
self.assertEqual(result.status_code, 200)
25+
result = self.client.get('/taxon/canon_rank_distance_by_name/?name=xxxxx')
26+
self.assertEqual(result.status_code, 404)
2527

2628
def test_is_child(self):
2729
result = self.client.get('/taxon/is_child/?src_tax_ids=550690&target_tax_id=523')

0 commit comments

Comments
 (0)