diff --git a/georiviere/portal/tests/test_views/test_observations.py b/georiviere/portal/tests/test_views/test_observations.py index bf0ff039..7e3555ad 100644 --- a/georiviere/portal/tests/test_views/test_observations.py +++ b/georiviere/portal/tests/test_views/test_observations.py @@ -1,7 +1,7 @@ from rest_framework.reverse import reverse from rest_framework.test import APITestCase -from georiviere.contribution.tests.factories import CustomContributionTypeFactory +from georiviere.contribution.tests.factories import CustomContributionTypeFactory, CustomContributionFactory from georiviere.observations.tests.factories import StationFactory from georiviere.portal.tests.factories import PortalFactory @@ -64,3 +64,25 @@ def test_detail_geojson(self): data = response.json() self.assertIn("properties", data) self.assertIn("geometry", data) + + def test_contributions(self): + validated = CustomContributionFactory(custom_type=self.custom_contribution_type, + station=self.station_linked_to_type, validated=True) + unvalidated = CustomContributionFactory(custom_type=self.custom_contribution_type, + station=self.station_linked_to_type, validated=False) + response = self.client.get( + reverse( + "api_portal:stations-custom-contributions", + kwargs={ + "portal_pk": 1, + "lang": "fr", + "pk": self.station_linked_to_type.pk, + }, + ) + ) + self.assertEqual(response.status_code, 200) + ids = [c["id"] for c in response.json()] + # validated conbtrib in results + self.assertIn(validated.pk, ids) + # unvalidated contrib not in results + self.assertNotIn(unvalidated.pk, ids)