Skip to content

Commit

Permalink
[#233] Fix values partij identificatoren
Browse files Browse the repository at this point in the history
[#233] Fix tests

[#233] Install django-digid-eherkenning

[#233] Fix tests

[#233] Improve Validator

[#233] Fix tests

[#233] Isort and Flake8

[#233] Improvements

[#233] Remove django-digid-eherkenning

[#233] Fix requirements

[#233] Fix requirements 2

[#233] Fix tests

[#233] Flake8

[#233] Fix validation errors

[#233] Update class

[#233] Remove unused import
  • Loading branch information
danielmursa-dev committed Dec 23, 2024
1 parent 1ce6afb commit 634a0f3
Show file tree
Hide file tree
Showing 8 changed files with 908 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
Vertegenwoordigden,
)
from openklant.components.klantinteracties.models.rekeningnummers import Rekeningnummer
from openklant.components.klantinteracties.models.validators import (
PartijIdentificatorValidator,
)
from openklant.utils.serializers import get_field_value


class PartijForeignkeyBaseSerializer(serializers.HyperlinkedModelSerializer):
Expand Down Expand Up @@ -399,6 +403,11 @@ class Meta:
},
}

def validate(self, attrs):
partij_identificator = get_field_value(self, attrs, "partij_identificator")
PartijIdentificatorValidator(**partij_identificator).validate()
return super().validate(attrs)

@transaction.atomic
def update(self, instance, validated_data):
if "partij" in validated_data:
Expand Down
29 changes: 17 additions & 12 deletions src/openklant/components/klantinteracties/api/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,16 +694,17 @@ def test_filter_vertegenwoordigde_partij_url(self):
def test_filter_partij_identificator_code_objecttype(self):
partij, partij2 = PartijFactory.create_batch(2)
PartijIdentificatorFactory.create(
partij=partij, partij_identificator_code_objecttype="one"
partij=partij, partij_identificator_code_objecttype="natuurlijk_persoon"
)
PartijIdentificatorFactory.create(
partij=partij2, partij_identificator_code_objecttype="two"
partij=partij2,
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
)

with self.subTest("happy flow"):
response = self.client.get(
self.url,
{"partijIdentificator__codeObjecttype": "two"},
{"partijIdentificator__codeObjecttype": "niet_natuurlijk_persoon"},
)
self.assertEqual(response.status_code, status.HTTP_200_OK)

Expand All @@ -724,16 +725,16 @@ def test_filter_partij_identificator_code_objecttype(self):
def test_filter_identificator_soort_object_id(self):
partij, partij2 = PartijFactory.create_batch(2)
PartijIdentificatorFactory.create(
partij=partij, partij_identificator_code_soort_object_id="one"
partij=partij, partij_identificator_code_soort_object_id="bsn"
)
PartijIdentificatorFactory.create(
partij=partij2, partij_identificator_code_soort_object_id="two"
partij=partij2, partij_identificator_code_soort_object_id="kvknummer"
)

with self.subTest("happy flow"):
response = self.client.get(
self.url,
{"partijIdentificator__codeSoortObjectId": "one"},
{"partijIdentificator__codeSoortObjectId": "bsn"},
)
self.assertEqual(response.status_code, status.HTTP_200_OK)

Expand All @@ -756,16 +757,20 @@ def test_filter_identificator_soort_object_id(self):
def test_filter_identificator_object_id(self):
partij, partij2 = PartijFactory.create_batch(2)
PartijIdentificatorFactory.create(
partij=partij, partij_identificator_object_id="one"
partij=partij,
partij_identificator_code_soort_object_id="bsn",
partij_identificator_object_id="296648875",
)
PartijIdentificatorFactory.create(
partij=partij2, partij_identificator_object_id="two"
partij=partij2,
partij_identificator_code_soort_object_id="bsn",
partij_identificator_object_id="111222333",
)

with self.subTest("happy flow"):
response = self.client.get(
self.url,
{"partijIdentificator__objectId": "one"},
{"partijIdentificator__objectId": "296648875"},
)
self.assertEqual(response.status_code, status.HTTP_200_OK)

Expand All @@ -786,16 +791,16 @@ def test_filter_identificator_object_id(self):
def test_filter_identificator_code_register(self):
partij, partij2 = PartijFactory.create_batch(2)
PartijIdentificatorFactory.create(
partij=partij, partij_identificator_code_register="one"
partij=partij, partij_identificator_code_register="brp"
)
PartijIdentificatorFactory.create(
partij=partij2, partij_identificator_code_register="two"
partij=partij2, partij_identificator_code_register="hr"
)

with self.subTest("happy flow"):
response = self.client.get(
self.url,
{"partijIdentificator__code_register": "two"},
{"partijIdentificator__code_register": "hr"},
)
self.assertEqual(response.status_code, status.HTTP_200_OK)

Expand Down
Loading

0 comments on commit 634a0f3

Please sign in to comment.