Skip to content

Commit

Permalink
Feat/taxref group3 inpn (#447)
Browse files Browse the repository at this point in the history
* fix(db): add group3_inpn to taxref model

* feat(api): specific route to get a list of group3

* Add group3 to taxon info

* Test test_get_groupe3_inpn and format of taxrefDetail response

* Changelog

---------

Co-authored-by: Maxime Vergez <[email protected]>
  • Loading branch information
amandine-sahl and Maxime Vergez authored Oct 26, 2023
1 parent b84ade0 commit a7f4dd0
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions apptax/taxonomie/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class Taxref(db.Model):
nom_vern_eng = db.Column(db.Unicode)
group1_inpn = db.Column(db.Unicode)
group2_inpn = db.Column(db.Unicode)
group3_inpn = db.Column(db.Unicode)
url = db.Column(db.Unicode)

@hybrid_property
Expand Down
15 changes: 15 additions & 0 deletions apptax/taxonomie/routestaxref.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def getTaxrefDetail(id):
Taxref.nom_vern,
Taxref.group1_inpn,
Taxref.group2_inpn,
Taxref.group3_inpn,
Taxref.id_rang,
BibTaxrefRangs.nom_rang,
BibTaxrefStatus.nom_statut,
Expand Down Expand Up @@ -330,6 +331,20 @@ def get_regneGroup2Inpn_taxref():
return results


@adresses.route("/groupe3_inpn", methods=["GET"])
@json_resp
def get_group3_inpn_taxref():
"""
Retourne la liste des groupes 3 inpn
"""
data = (
db.session.query(Taxref.group3_inpn)
.distinct(Taxref.group3_inpn)
.filter(Taxref.group3_inpn != None)
).all()
return [d[0] for d in data]


@adresses.route("/allnamebylist/<string:code_liste>", methods=["GET"])
@adresses.route("/allnamebylist", methods=["GET"])
@json_resp
Expand Down
42 changes: 42 additions & 0 deletions apptax/tests/test_taxref.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,37 @@ class TestAPITaxref:
]
)

schema_taxref_detail = Schema(
{
"cd_nom": int,
"cd_ref": int,
"cd_sup": int,
"cd_taxsup": int,
"phylum": str,
"regne": str,
Optional("classe"): str,
"ordre": str,
"famille": str,
"group1_inpn": str,
"group2_inpn": str,
"group3_inpn": str,
"id_rang": str,
"nom_complet": str,
"nom_habitat": str,
"nom_rang": str,
"nom_statut": str,
"nom_valide": str,
"nom_vern": str,
"status": dict,
"synonymes": [
{
"cd_nom": int,
"nom_complet": str,
}
],
}
)

def test_get_allnamebyListe_routes(self):
query_string = {"limit": 10}
response = self.client.get(
Expand Down Expand Up @@ -103,6 +134,9 @@ def test_searchfield_routes(self):
def test_taxrefDetail_routes(self):
response = self.client.get(url_for("taxref.getTaxrefDetail", id=29708))
assert response.status_code == 200
data = response.json
if data:
assert self.schema_taxref_detail.is_valid(data)

def test_searchTaxref_routes(self):
query_string = {"ilike-classe": "hex", "page": 1, "limit": 10}
Expand All @@ -125,3 +159,11 @@ def test_taxrefversion_routes(self):
response = self.client.get(url_for("taxref.getTaxrefVersion"))
assert response.status_code == 200
assert json.loads(response.data)["version"] == 16

def test_get_groupe3_inpn(self):
response = self.client.get(url_for("taxref.get_group3_inpn_taxref"))

assert response.status_code == 200
response_json = response.json
assert "Coléoptères" in response_json
assert "Autres" in response_json
9 changes: 9 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
1.13.1 (unrelease)
===================


**🚀 Nouveautés**

* Ajout de la colonne `group3_inpn` à la table taxref et à la réponse de la route `getTaxonDetail` (#447)
* Ajout d'une route listant les group3 `/groupe3_inpn` (#447)

1.13.0 (2023-10-25)
===================

Expand Down

0 comments on commit a7f4dd0

Please sign in to comment.