Skip to content

Commit

Permalink
test(api): parametrize to test several params
Browse files Browse the repository at this point in the history
Especially params like 'count_min_max' or 'nom_vern_or_lb_nom' that are
in if clauses
  • Loading branch information
Maxime Vergez committed Oct 20, 2023
1 parent a38db8e commit dc72400
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions backend/geonature/tests/test_synthese.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,16 +460,21 @@ def test_filter_cor_observers(self, users, synthese_data):
# le requete doit etre OK marlgré la geom NULL
assert response.status_code == 200

def test_get_observations_for_web_param_column_frontend(self, app, users, synthese_data):
@pytest.mark.parametrize(
"additionnal_column",
[("altitude_min"), ("count_min_max"), ("nom_vern_or_lb_nom")],
)
def test_get_observations_for_web_param_column_frontend(
self, app, users, synthese_data, additionnal_column
):
"""
Test de renseigner le paramètre LIST_COLUMNS_FRONTEND pour renvoyer uniquement
les colonnes souhaitées
"""
expected_additionnal_column = "altitude_min"
app.config["SYNTHESE"]["LIST_COLUMNS_FRONTEND"] = [
{
"prop": expected_additionnal_column,
"name": "Altitude min",
"prop": additionnal_column,
"name": "My label",
}
]

Expand All @@ -478,7 +483,7 @@ def test_get_observations_for_web_param_column_frontend(self, app, users, synthe
response = self.client.get(url_for("gn_synthese.get_observations_for_web"))
data = response.get_json()

expected_columns = {"id", "url_source", expected_additionnal_column}
expected_columns = {"id", "url_source", additionnal_column}

assert all(
set(feature["properties"].keys()) == expected_columns for feature in data["features"]
Expand Down

0 comments on commit dc72400

Please sign in to comment.