-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ [#234] Add test for DigitaalAdres.adres email validation
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from django.utils.translation import gettext as _ | ||
|
||
from rest_framework import status | ||
from vng_api_common.tests import reverse | ||
|
||
|
@@ -90,6 +92,54 @@ def test_create_digitaal_adres(self): | |
self.assertEqual(data["adres"], "[email protected]") | ||
self.assertEqual(data["omschrijving"], "omschrijving") | ||
|
||
def test_create_digitaal_adres_email_validation(self): | ||
list_url = reverse("klantinteracties:digitaaladres-list") | ||
data = { | ||
"verstrektDoorBetrokkene": None, | ||
"verstrektDoorPartij": None, | ||
"soortDigitaalAdres": SoortDigitaalAdres.email, | ||
"adres": "invalid", | ||
"omschrijving": "omschrijving", | ||
} | ||
|
||
response = self.client.post(list_url, data) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
data = response.json() | ||
self.assertEqual( | ||
data["invalidParams"], | ||
[ | ||
{ | ||
"name": "adres", | ||
"code": "invalid", | ||
"reason": _("Voer een geldig e-mailadres in."), | ||
} | ||
], | ||
) | ||
|
||
digitaal_adres = DigitaalAdresFactory.create( | ||
soort_digitaal_adres=SoortDigitaalAdres.email, adres="[email protected]" | ||
) | ||
detail_url = reverse( | ||
"klantinteracties:digitaaladres-detail", | ||
kwargs={"uuid": str(digitaal_adres.uuid)}, | ||
) | ||
|
||
response = self.client.patch(detail_url, {"adres": "invalid"}) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
data = response.json() | ||
self.assertEqual( | ||
data["invalidParams"], | ||
[ | ||
{ | ||
"name": "adres", | ||
"code": "invalid", | ||
"reason": _("Voer een geldig e-mailadres in."), | ||
} | ||
], | ||
) | ||
|
||
def test_update_digitaal_adres(self): | ||
betrokkene, betrokkene2 = BetrokkeneFactory.create_batch(2) | ||
partij, partij2 = PartijFactory.create_batch(2) | ||
|