Skip to content

Commit

Permalink
test(api): test groupX_inpn filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Vergez authored and jacquesfize committed Feb 13, 2024
1 parent 50b753d commit 81ed18a
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions backend/geonature/tests/test_synthese.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,33 +484,29 @@ def test_filter_cor_observers(self, users, synthese_data):
assert response.status_code == 200

@pytest.mark.parametrize(
"additionnal_column",
[("altitude_min"), ("count_min_max"), ("nom_vern_or_lb_nom")],
"group_inpn",
[
("group2_inpn"),
("group3_inpn"),
],
)
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
"""
app.config["SYNTHESE"]["LIST_COLUMNS_FRONTEND"] = [
{
"prop": additionnal_column,
"name": "My label",
}
]

set_logged_user(self.client, users["self_user"])

response = self.client.get(url_for("gn_synthese.get_observations_for_web"))
data = response.get_json()

expected_columns = {"id", "url_source", additionnal_column}
def test_get_observations_for_web_filter_group_inpn(self, users, synthese_data, group_inpn):
obs = synthese_data["obs1"]
taxref_from_cd_nom = Taxref.query.filter_by(cd_nom=obs.cd_nom).one()
group_from_taxref = getattr(taxref_from_cd_nom, group_inpn)
filter_name = "taxonomie_" + group_inpn

assert all(
set(feature["properties"].keys()) == expected_columns for feature in data["features"]
set_logged_user_cookie(self.client, users["self_user"])
response = self.client.get(
url_for("gn_synthese.get_observations_for_web"),
json={
filter_name: [group_from_taxref],
},
)
response_json = response.json
assert obs.id_synthese in {
synthese["properties"]["id"] for synthese in response_json["features"]
}

def test_export(self, users):
set_logged_user(self.client, users["self_user"])
Expand Down

0 comments on commit 81ed18a

Please sign in to comment.