Skip to content

Commit 586913c

Browse files
[#233] Fix third level check
1 parent 7a976f9 commit 586913c

File tree

3 files changed

+50
-11
lines changed

3 files changed

+50
-11
lines changed

src/openklant/components/klantinteracties/api/tests/test_partijen.py

+36-3
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,7 @@ def test_invalid_validation_partij_identificator_code_objecttype(self):
21262126
self.assertEqual(response.data["invalid_params"][0]["code"], "invalid")
21272127
self.assertEqual(
21282128
response.data["invalid_params"][0]["reason"],
2129-
"voor `codeRegister` brp zijn alleen deze waarden toegestaan: ['natuurlijk_persoon']",
2129+
"voor `codeRegister` brp zijn alleen deze waarden toegestaan: ['natuurlijk_persoon', 'overig']",
21302130
)
21312131

21322132
def test_invalid_validation_partij_identificator_code_soort_object_id(self):
@@ -2154,7 +2154,7 @@ def test_invalid_validation_partij_identificator_code_soort_object_id(self):
21542154
self.assertEqual(response.data["invalid_params"][0]["code"], "invalid")
21552155
self.assertEqual(
21562156
response.data["invalid_params"][0]["reason"],
2157-
"voor `codeObjecttype` natuurlijk_persoon zijn alleen deze waarden toegestaan: ['bsn']",
2157+
"voor `codeObjecttype` natuurlijk_persoon zijn alleen deze waarden toegestaan: ['bsn', 'overig']",
21582158
)
21592159

21602160
def test_invalid_validation_partij_identificator_object_id(self):
@@ -2217,7 +2217,7 @@ def test_valid_validation_partij_identificator(self):
22172217
"brp",
22182218
)
22192219

2220-
def test_valid_overig_validation_partij_identificator(self):
2220+
def test_valid_overig_code_register_validation_partij_identificator(self):
22212221
# Overig no validation
22222222
url = reverse("klantinteracties:partijidentificator-list")
22232223
partij = PartijFactory.create()
@@ -2249,6 +2249,39 @@ def test_valid_overig_validation_partij_identificator(self):
22492249
"overig",
22502250
)
22512251

2252+
def test_valid_overig_code_objecttype_validation_partij_identificator(self):
2253+
# Overig no validation
2254+
url = reverse("klantinteracties:partijidentificator-list")
2255+
partij = PartijFactory.create()
2256+
data = {
2257+
"identificeerdePartij": {"uuid": str(partij.uuid)},
2258+
"anderePartijIdentificator": "anderePartijIdentificator",
2259+
"partijIdentificator": {
2260+
"codeObjecttype": "overig",
2261+
"codeSoortObjectId": "bsn",
2262+
"objectId": 296648875,
2263+
"codeRegister": "brp",
2264+
},
2265+
}
2266+
response = self.client.post(url, data)
2267+
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
2268+
self.assertEqual(
2269+
response.data["partij_identificator"]["code_objecttype"],
2270+
"overig",
2271+
)
2272+
self.assertEqual(
2273+
response.data["partij_identificator"]["code_soort_object_id"],
2274+
"bsn",
2275+
)
2276+
self.assertEqual(
2277+
response.data["partij_identificator"]["object_id"],
2278+
"296648875",
2279+
)
2280+
self.assertEqual(
2281+
response.data["partij_identificator"]["code_register"],
2282+
"brp",
2283+
)
2284+
22522285

22532286
class CategorieRelatieTests(APITestCase):
22542287
def test_list_categorie_relatie(self):

src/openklant/components/klantinteracties/models/validators.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,33 @@ class PartijIdentificatorValidator:
2121

2222
NATUURLIJK_PERSOON = [
2323
PartijIdentificatorCodeSoortObjectId.bsn.value,
24+
PartijIdentificatorCodeSoortObjectId.overig.value,
2425
]
2526
VESTIGING = [
2627
PartijIdentificatorCodeSoortObjectId.vestigingsnummer.value,
28+
PartijIdentificatorCodeSoortObjectId.overig.value,
2729
]
2830
NIET_NATUURLIJK_PERSOON = [
2931
PartijIdentificatorCodeSoortObjectId.rsin.value,
3032
PartijIdentificatorCodeSoortObjectId.kvk_nummer.value,
33+
PartijIdentificatorCodeSoortObjectId.overig.value,
3134
]
3235

36+
ALLOWED_OBJECT_TYPES_FOR_CODE_OBJECTTYPE = {
37+
PartijIdentificatorCodeObjectType.natuurlijk_persoon.value: NATUURLIJK_PERSOON,
38+
PartijIdentificatorCodeObjectType.vestiging.value: VESTIGING,
39+
PartijIdentificatorCodeObjectType.niet_natuurlijk_persoon.value: NIET_NATUURLIJK_PERSOON,
40+
}
41+
3342
ALLOWED_OBJECT_TYPES_FOR_REGISTRIES = {
3443
PartijIdentificatorCodeRegister.brp: {
3544
PartijIdentificatorCodeObjectType.natuurlijk_persoon.value: NATUURLIJK_PERSOON,
45+
PartijIdentificatorCodeObjectType.overig.value: [],
3646
},
3747
PartijIdentificatorCodeRegister.hr: {
3848
PartijIdentificatorCodeObjectType.vestiging.value: VESTIGING,
3949
PartijIdentificatorCodeObjectType.niet_natuurlijk_persoon.value: NIET_NATUURLIJK_PERSOON,
40-
},
41-
PartijIdentificatorCodeRegister.overig: {
42-
PartijIdentificatorCodeObjectType.natuurlijk_persoon.value: NATUURLIJK_PERSOON,
43-
PartijIdentificatorCodeObjectType.vestiging.value: VESTIGING,
44-
PartijIdentificatorCodeObjectType.niet_natuurlijk_persoon.value: NIET_NATUURLIJK_PERSOON,
50+
PartijIdentificatorCodeObjectType.overig.value: [],
4551
},
4652
}
4753

@@ -102,7 +108,7 @@ def validate_code_soort_object_id(self) -> None:
102108
return
103109

104110
if self.code_soort_object_id not in (
105-
choices := self.ALLOWED_OBJECT_TYPES_FOR_REGISTRIES[self.code_register].get(
111+
choices := self.ALLOWED_OBJECT_TYPES_FOR_CODE_OBJECTTYPE.get(
106112
self.code_objecttype, []
107113
)
108114
):

src/openklant/components/klantinteracties/tests/test_validators.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_invalid_code_objecttype_not_found_in_top_level(self):
6262
details = error.exception.message_dict
6363
self.assertEqual(
6464
details["partij_identificator_code_objecttype"][0],
65-
"voor `codeRegister` brp zijn alleen deze waarden toegestaan: ['natuurlijk_persoon']",
65+
"voor `codeRegister` brp zijn alleen deze waarden toegestaan: ['natuurlijk_persoon', 'overig']",
6666
)
6767

6868
# Start section validate_code_soort_object_id
@@ -105,7 +105,7 @@ def test_invalid_code_soort_object_id_not_found_in_top_level(self):
105105
details = error.exception.message_dict
106106
self.assertEqual(
107107
details["partij_identificator_code_soort_object_id"][0],
108-
"voor `codeObjecttype` natuurlijk_persoon zijn alleen deze waarden toegestaan: ['bsn']",
108+
"voor `codeObjecttype` natuurlijk_persoon zijn alleen deze waarden toegestaan: ['bsn', 'overig']",
109109
)
110110

111111
# Start section validate_object_id

0 commit comments

Comments
 (0)