-
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.
✨ [#246] Only allow is_standaard_adres if partij is set
- Loading branch information
Showing
2 changed files
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
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 |
---|---|---|
|
@@ -203,6 +203,41 @@ def test_create_digitaal_adres_is_standaard_adres(self): | |
self.assertEqual(existing_adres.is_standaard_adres, False) | ||
self.assertEqual(new_adres.is_standaard_adres, True) | ||
|
||
def test_create_digitaal_adres_is_standaard_adres_without_partij_not_possible(self): | ||
""" | ||
Creating a DigitaalAdres with isStandaardAdres=True should not be possible with | ||
verstrektDoorPartij=None | ||
""" | ||
betrokkene = BetrokkeneFactory.create() | ||
|
||
list_url = reverse("klantinteracties:digitaaladres-list") | ||
data = { | ||
"verstrektDoorBetrokkene": {"uuid": str(betrokkene.uuid)}, | ||
"verstrektDoorPartij": None, | ||
"soortDigitaalAdres": "email", | ||
"adres": "[email protected]", | ||
"omschrijving": "omschrijving", | ||
"isStandaardAdres": True, | ||
} | ||
|
||
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": "isStandaardAdres", | ||
"code": "invalid", | ||
"reason": _( | ||
"`is_standaard_adres` kan alleen gezet worden als `verstrekt_door_partij` niet leeg is." | ||
), | ||
} | ||
], | ||
) | ||
self.assertEqual(DigitaalAdres.objects.count(), 0) | ||
|
||
def test_update_digitaal_adres(self): | ||
betrokkene, betrokkene2 = BetrokkeneFactory.create_batch(2) | ||
partij, partij2 = PartijFactory.create_batch(2) | ||
|