Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
✅ Add test for unique together validation for Verzoek bronorganisatie…
Browse files Browse the repository at this point in the history
… and identificatie

fixes: VNG-Realisatie/gemma-zaken#1696
  • Loading branch information
stevenbal committed Oct 9, 2020
1 parent fc27f8b commit 4326003
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/verzoeken/api/tests/test_verzoek.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from rest_framework import status
from rest_framework.test import APITestCase
from vng_api_common.tests import JWTAuthMixin, reverse
from vng_api_common.tests import JWTAuthMixin, get_validation_errors, reverse

from verzoeken.datamodel.constants import VerzoekStatus
from verzoeken.datamodel.models import Verzoek
Expand Down Expand Up @@ -127,6 +127,20 @@ def test_pagination_page_param(self):
self.assertIsNone(response_data["previous"])
self.assertIsNone(response_data["next"])

def test_update_verzoek_unique_bronorganisatie_and_identificatie(self):
VerzoekFactory.create(bronorganisatie="000000000", identificatie="unique")

# Create verzoek with same identificatie, but different bronorganisatie
verzoek = VerzoekFactory.create(identificatie="unique")
detail_url = reverse(verzoek)

response = self.client.patch(detail_url, {"bronorganisatie": "000000000"})

self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

error = get_validation_errors(response, "identificatie")
self.assertEqual(error["code"], "identificatie-niet-uniek")


class VerzoekFilterTests(JWTAuthMixin, APITestCase):
heeft_alle_autorisaties = True
Expand Down

0 comments on commit 4326003

Please sign in to comment.