Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed May 15, 2024
1 parent d43071f commit fbf3aa1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion georiviere/portal/tests/test_views/test_observations.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)

0 comments on commit fbf3aa1

Please sign in to comment.