Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLechemia committed Mar 8, 2024
1 parent 52e7545 commit 5a3ec28
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions backend/geonature/tests/test_synthese.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from geonature.utils.config import config
from geonature.core.gn_permissions.tools import get_permissions
from geonature.core.gn_synthese.utils.blurring import split_blurring_precise_permissions
from geonature.core.gn_synthese.schemas import SyntheseSchema
from geonature.core.gn_synthese.utils.query_select_sqla import remove_accents
from geonature.core.sensitivity.models import cor_sensitivity_area_type
from geonature.core.gn_meta.models import TDatasets
Expand Down Expand Up @@ -163,6 +164,7 @@ class TestSynthese:
def test_required_fields_and_format(self, app, users):
# Test required fields base on VSyntheseForWebAppSchema surrounded by a custom converter : CustomRequiredConverter
# also test geojson serialization (grouped by geometry and not)
app.config["SYNTHESE"]["LIST_COLUMNS_FRONTEND"] += [{"prop": "altitude_min", "name": "Altitude min"}]
url_ungrouped = url_for("gn_synthese.get_observations_for_web")
set_logged_user(self.client, users["admin_user"])
resp = self.client.get(url_ungrouped)
Expand Down Expand Up @@ -490,35 +492,6 @@ def test_filter_cor_observers(self, users, synthese_data):
# le requete doit etre OK marlgré la geom NULL
assert response.status_code == 200

@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
"""
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}

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

@pytest.mark.parametrize(
"group_inpn",
[
Expand Down

0 comments on commit 5a3ec28

Please sign in to comment.