From e912771a94dd8eb7efcf12f1777cdb754c545c8f Mon Sep 17 00:00:00 2001 From: Daniel Mursa Date: Thu, 19 Dec 2024 16:32:53 +0100 Subject: [PATCH] [#233] Check tests --- .../klantinteracties/api/tests/test_partijen.py | 17 ++++++++++------- .../klantinteracties/models/validators.py | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/openklant/components/klantinteracties/api/tests/test_partijen.py b/src/openklant/components/klantinteracties/api/tests/test_partijen.py index 28ae51eb..aa3ad374 100644 --- a/src/openklant/components/klantinteracties/api/tests/test_partijen.py +++ b/src/openklant/components/klantinteracties/api/tests/test_partijen.py @@ -1,6 +1,6 @@ import datetime -from django.core.exceptions import ValidationError +from rest_framework.serializers import ValidationError from django.utils.translation import gettext as _ from rest_framework import status @@ -2118,8 +2118,9 @@ def test_invalid_validation_partij_identificator_code_objecttype(self): } # ValidationError, "ObjectType keuzes zijn beperkt op basis van CodeRegister." - with self.assertRaises(ValidationError) as error: - self.client.post(url, data) + with self.subTest("doesn'actor_is_wrong_instance"): + with self.assertRaises(ValidationError): + self.client.post(url, data) def test_invalid_validation_partij_identificator_code_soort_object_id(self): url = reverse("klantinteracties:partijidentificator-list") @@ -2135,8 +2136,9 @@ def test_invalid_validation_partij_identificator_code_soort_object_id(self): }, } # "CodeSoortObjectId keuzes zijn beperkt op basis van CodeObjectType.", - with self.assertRaises(ValidationError) as error: - self.client.post(url, data) + with self.subTest("doesn'actor_is_wrong_instance"): + with self.assertRaises(ValidationError): + self.client.post(url, data) def test_invalid_validation_partij_identificator_object_id(self): url = reverse("klantinteracties:partijidentificator-list") @@ -2152,8 +2154,9 @@ def test_invalid_validation_partij_identificator_object_id(self): }, } # "De lengte van de ObjectId moet tussen 8 en 9 liggen." - with self.assertRaises(ValidationError) as error: - self.client.post(url, data) + with self.subTest("doesn'actor_is_wrong_instance"): + with self.assertRaises(ValidationError): + self.client.post(url, data) def test_valid_validation_partij_identificator(self): # All validations pass diff --git a/src/openklant/components/klantinteracties/models/validators.py b/src/openklant/components/klantinteracties/models/validators.py index cbc55b17..991a6ac2 100644 --- a/src/openklant/components/klantinteracties/models/validators.py +++ b/src/openklant/components/klantinteracties/models/validators.py @@ -1,4 +1,4 @@ -from django.core.exceptions import ValidationError +from rest_framework.serializers import ValidationError from django.utils.translation import gettext_lazy as _ from .constants import (