Skip to content

Commit

Permalink
fix: taxon stats area_type parameter check
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed Oct 8, 2024
1 parent ef5afb5 commit c8383e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion backend/geonature/core/gn_synthese/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,9 +972,12 @@ def taxon_stats(scope, cd_ref):

area_type = request.args.get("area_type")

if not TaxonSheetUtils.is_valid_area_type(area_type):
if not area_type:
raise BadRequest("Missing area_type parameter")

if not TaxonSheetUtils.is_valid_area_type(area_type):
raise BadRequest("Invalid area_type parameter")

areas_subquery = TaxonSheetUtils.get_area_subquery(area_type)
taxref_cd_nom_list = TaxonSheetUtils.get_cd_nom_list_from_cd_ref(cd_ref)

Expand Down
2 changes: 1 addition & 1 deletion backend/geonature/tests/test_synthese.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ def test_taxon_stats(self, synthese_data, users):
url_for("gn_synthese.taxon_stats", cd_ref=CD_REF_VALID, area_type=AREA_TYPE_INVALID),
)
assert response.status_code == 400
assert response.json["description"] == "Invalid area_type"
assert response.json["description"] == "Invalid area_type parameter"

# Invalid cd_ref parameter
response = self.client.get(
Expand Down

0 comments on commit c8383e8

Please sign in to comment.