Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLechemia committed Mar 8, 2024
1 parent 240f8a0 commit 52e7545
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions backend/geonature/tests/test_synthese.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ def test_get_observations_for_web(self, app, users, synthese_data, taxon_attribu
r = self.client.post(url, json=filters)
assert r.status_code == 200
assert {synthese_data[k].id_synthese for k in ["p1_af1", "p1_af2"]}.issubset(
{f["properties"]["id"] for f in r.json["features"]}
{f["properties"]["id_synthese"] for f in r.json["features"]}
)
assert {synthese_data[k].id_synthese for k in ["p2_af1", "p2_af2"]}.isdisjoint(
{f["properties"]["id"] for f in r.json["features"]}
{f["properties"]["id_synthese"] for f in r.json["features"]}
)

# test geometry filter with circle radius
Expand All @@ -274,10 +274,10 @@ def test_get_observations_for_web(self, app, users, synthese_data, taxon_attribu
r = self.client.post(url, json=filters)
assert r.status_code == 200
assert {synthese_data[k].id_synthese for k in ["p1_af1", "p1_af2"]}.issubset(
{f["properties"]["id"] for f in r.json["features"]}
{f["properties"]["id_synthese"] for f in r.json["features"]}
)
assert {synthese_data[k].id_synthese for k in ["p2_af1", "p2_af2"]}.isdisjoint(
{f["properties"]["id"] for f in r.json["features"]}
{f["properties"]["id_synthese"] for f in r.json["features"]}
)

# test ref geo area filter
Expand All @@ -289,10 +289,10 @@ def test_get_observations_for_web(self, app, users, synthese_data, taxon_attribu
r = self.client.post(url, json=filters)
assert r.status_code == 200
assert {synthese_data[k].id_synthese for k in ["p1_af1", "p1_af2"]}.issubset(
{f["properties"]["id"] for f in r.json["features"]}
{f["properties"]["id_synthese"] for f in r.json["features"]}
)
assert {synthese_data[k].id_synthese for k in ["p2_af1", "p2_af2"]}.isdisjoint(
{f["properties"]["id"] for f in r.json["features"]}
{f["properties"]["id_synthese"] for f in r.json["features"]}
)

# test organism
Expand Down Expand Up @@ -349,7 +349,7 @@ def test_get_observations_for_web_filter_comment(self, users, synthese_data, tax
filters = {"has_comment": True}
r = self.client.get(url, json=filters)

assert id_synthese in (feature["properties"]["id"] for feature in r.json["features"])
assert id_synthese in (feature["properties"]["id_synthese"] for feature in r.json["features"])

def test_get_observations_for_web_filter_id_source(self, users, synthese_data, source):
set_logged_user(self.client, users["self_user"])
Expand All @@ -364,7 +364,7 @@ def test_get_observations_for_web_filter_id_source(self, users, synthese_data, s
for synthese in synthese_data.values()
if synthese.id_source == id_source
}
response_data = {feature["properties"]["id"] for feature in r.json["features"]}
response_data = {feature["properties"]["id_synthese"] for feature in r.json["features"]}
assert expected_data.issubset(response_data)

@pytest.mark.parametrize(
Expand Down Expand Up @@ -397,7 +397,7 @@ def test_get_observations_for_web_filter_source_by_id_module(
for synthese in synthese_data.values()
if synthese.id_module in id_modules_selected
}
response_data = {feature["properties"]["id"] for feature in r.json["features"]}
response_data = {feature["properties"]["id_synthese"] for feature in r.json["features"]}
assert expected_data.issubset(response_data)
assert len(response_data) == expected_length

Expand Down Expand Up @@ -435,7 +435,7 @@ def test_get_synthese_data_cruved(self, app, users, synthese_data, datasets):
assert len(features) > 0

for feat in features:
assert feat["properties"]["id"] in [synt.id_synthese for synt in synthese_data.values()]
assert feat["properties"]["id_synthese"] in [synt.id_synthese for synt in synthese_data.values()]
assert response.status_code == 200

def test_get_synthese_data_aggregate(self, users, datasets, synthese_data):
Expand Down Expand Up @@ -541,7 +541,7 @@ def test_get_observations_for_web_filter_group_inpn(self, users, synthese_data,
)
response_json = response.json
assert obs.id_synthese in {
synthese["properties"]["id"] for synthese in response_json["features"]
synthese["properties"]["id_synthese"] for synthese in response_json["features"]
}

def test_export(self, users):
Expand Down Expand Up @@ -1409,7 +1409,7 @@ def blur_sensitive_observations(monkeypatch):

def get_one_synthese_reponse_from_id(response: dict, id_synthese: int):
return [
synthese for synthese in response["features"] if synthese["properties"]["id"] == id_synthese
synthese for synthese in response["features"] if synthese["properties"]["id_synthese"] == id_synthese
][0]


Expand Down Expand Up @@ -1537,7 +1537,7 @@ def test_get_observations_for_web_blurring_excluded(
]
)

json_synthese_ids = (feature["properties"]["id"] for feature in response_json["features"])
json_synthese_ids = (feature["properties"]["id_synthese"] for feature in response_json["features"])
assert all(synthese_id not in json_synthese_ids for synthese_id in sensitive_synthese_ids)

def test_get_observations_for_web_blurring_grouped_geom(
Expand Down Expand Up @@ -1584,7 +1584,7 @@ def test_get_observations_for_web_blurring_grouped_geom(
feature["geometry"] is None
for feature in json_resp["features"]
if all(
observation["id"] in sensitive_synthese_ids
observation["id_synthese"] in sensitive_synthese_ids
for observation in feature["properties"]["observations"]
)
)
Expand Down

0 comments on commit 52e7545

Please sign in to comment.