diff --git a/src/openklant/components/contactgegevens/api/serializers.py b/src/openklant/components/contactgegevens/api/serializers.py index 5e583af1..e4050719 100644 --- a/src/openklant/components/contactgegevens/api/serializers.py +++ b/src/openklant/components/contactgegevens/api/serializers.py @@ -76,7 +76,7 @@ class Meta: extra_kwargs = { "uuid": {"read_only": True}, "url": { - "view_name": "contactgegevens:organisatie-detail", + "view_name": "contactgegevens:persoon-detail", "lookup_field": "uuid", "help_text": "De unieke URL van deze organisatie binnen deze API.", }, diff --git a/src/openklant/components/contactgegevens/api/tests/test_apis.py b/src/openklant/components/contactgegevens/api/tests/test_apis.py index ab47d877..4e2ebdec 100644 --- a/src/openklant/components/contactgegevens/api/tests/test_apis.py +++ b/src/openklant/components/contactgegevens/api/tests/test_apis.py @@ -9,6 +9,52 @@ class PersoonTests(APITestCase): + def test_persoon_detail(self): + persoon = PersoonFactory.create( + geboortedatum="1980-02-23", + overlijdensdatum="2020-09-05", + geslachtsnaam="Doe", + geslacht="m", + voorvoegsel="", + voornamen="John", + adres_nummeraanduiding_id="nummeraanduiding_id", + adres_adresregel1="adresregel1", + adres_adresregel2="adresregel2", + adres_adresregel3="adresregel3", + adres_land="5001", + land="5001", + ) + detail_url = reverse( + "contactgegevens:persoon-detail", + kwargs={"uuid": str(persoon.uuid)}, + ) + + expected_adres = { + "nummeraanduidingId": "nummeraanduiding_id", + "adresregel1": "adresregel1", + "adresregel2": "adresregel2", + "adresregel3": "adresregel3", + "land": "5001", + } + expected_data = { + "uuid": str(persoon.uuid), + "url": "http://testserver" + detail_url, + "geboortedatum": "1980-02-23", + "overlijdensdatum": "2020-09-05", + "geslachtsnaam": "Doe", + "geslacht": "m", + "voorvoegsel": "", + "voornamen": "John", + "adres": expected_adres, + "land": "5001", + } + + response = self.client.get(detail_url) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data, expected_data) + def test_create_persoon(self): list_url = reverse("contactgegevens:persoon-list") @@ -52,7 +98,7 @@ def test_create_persoon(self): self.assertEqual(data["land"], "5001") def test_update_persoon(self): - persoon = PersoonFactory( + persoon = PersoonFactory.create( geboortedatum="1972-05-05", overlijdensdatum=None, geslachtsnaam="Townsend", @@ -132,7 +178,7 @@ def test_update_persoon(self): self.assertEqual(data["land"], "6713") def test_update_partial_persoon(self): - persoon = PersoonFactory( + persoon = PersoonFactory.create( geboortedatum="1972-05-05", overlijdensdatum=None, geslachtsnaam="Townsend", @@ -214,6 +260,46 @@ def test_list_pagination_pagesize_param(self): class OrganisatiesTests(APITestCase): + def test_organisatie_detail(self): + organisatie = OrganisatieFactory.create( + handelsnaam="Devin Townsend", + oprichtingsdatum="1980-02-23", + opheffingsdatum="2020-09-05", + adres_nummeraanduiding_id="nummeraanduiding_id", + adres_adresregel1="adresregel1", + adres_adresregel2="adresregel2", + adres_adresregel3="adresregel3", + adres_land="5001", + land="5001", + ) + detail_url = reverse( + "contactgegevens:organisatie-detail", + kwargs={"uuid": str(organisatie.uuid)}, + ) + + expected_adres = { + "nummeraanduidingId": "nummeraanduiding_id", + "adresregel1": "adresregel1", + "adresregel2": "adresregel2", + "adresregel3": "adresregel3", + "land": "5001", + } + expected_data = { + "uuid": str(organisatie.uuid), + "url": "http://testserver" + detail_url, + "oprichtingsdatum": "1980-02-23", + "opheffingsdatum": "2020-09-05", + "handelsnaam": "Devin Townsend", + "adres": expected_adres, + "land": "5001", + } + + response = self.client.get(detail_url) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data, expected_data) + def test_create_organisatie(self): list_url = reverse("contactgegevens:organisatie-list") @@ -252,7 +338,7 @@ def test_create_organisatie(self): self.assertEqual(data["land"], "5001") def test_update_organisatie(self): - organisatie = OrganisatieFactory( + organisatie = OrganisatieFactory.create( handelsnaam="Devin Townsend", oprichtingsdatum="1996-03-12", opheffingsdatum=None, @@ -320,7 +406,7 @@ def test_update_organisatie(self): self.assertEqual(data["land"], "6713") def test_update_partial_organisatie(self): - organisatie = OrganisatieFactory( + organisatie = OrganisatieFactory.create( handelsnaam="Devin Townsend", oprichtingsdatum="1996-03-12", opheffingsdatum=None, diff --git a/src/openklant/components/klantinteracties/api/serializers/klantcontacten.py b/src/openklant/components/klantinteracties/api/serializers/klantcontacten.py index 94352b37..5605fba0 100644 --- a/src/openklant/components/klantinteracties/api/serializers/klantcontacten.py +++ b/src/openklant/components/klantinteracties/api/serializers/klantcontacten.py @@ -445,7 +445,7 @@ class Meta: extra_kwargs = { "uuid": {"read_only": True}, "url": { - "view_name": "klantinteracties:klantcontact-detail", + "view_name": "klantinteracties:bijlage-detail", "lookup_field": "uuid", "help_text": _("De unieke URL van dit klantcontact binnen deze API."), }, diff --git a/src/openklant/components/klantinteracties/api/serializers/partijen.py b/src/openklant/components/klantinteracties/api/serializers/partijen.py index d4c31546..e8ed89bf 100644 --- a/src/openklant/components/klantinteracties/api/serializers/partijen.py +++ b/src/openklant/components/klantinteracties/api/serializers/partijen.py @@ -227,7 +227,7 @@ class Meta: extra_kwargs = { "uuid": {"read_only": True}, "url": { - "view_name": "klantinteracties:categorie-detail", + "view_name": "klantinteracties:categorierelatie-detail", "lookup_field": "uuid", "help_text": _("De unieke URL van deze categorie binnen deze API."), }, diff --git a/src/openklant/components/klantinteracties/api/serializers/rekeningnummers.py b/src/openklant/components/klantinteracties/api/serializers/rekeningnummers.py index 4bf3487d..43d4b500 100644 --- a/src/openklant/components/klantinteracties/api/serializers/rekeningnummers.py +++ b/src/openklant/components/klantinteracties/api/serializers/rekeningnummers.py @@ -40,7 +40,7 @@ class RekeningnummerSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Rekeningnummer - fields = ("uuid", "partij", "iban", "bic") + fields = ("uuid", "url", "partij", "iban", "bic") extra_kwargs = { "uuid": {"read_only": True}, "url": { diff --git a/src/openklant/components/klantinteracties/api/tests/test_actoren.py b/src/openklant/components/klantinteracties/api/tests/test_actoren.py index 8422968a..ab288470 100644 --- a/src/openklant/components/klantinteracties/api/tests/test_actoren.py +++ b/src/openklant/components/klantinteracties/api/tests/test_actoren.py @@ -44,6 +44,8 @@ def test_read_actor(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) def test_create_actor_medewerker(self): list_url = reverse("klantinteracties:actor-list") diff --git a/src/openklant/components/klantinteracties/api/tests/test_digitaal_adres.py b/src/openklant/components/klantinteracties/api/tests/test_digitaal_adres.py index 72e6f2eb..d852295d 100644 --- a/src/openklant/components/klantinteracties/api/tests/test_digitaal_adres.py +++ b/src/openklant/components/klantinteracties/api/tests/test_digitaal_adres.py @@ -53,6 +53,8 @@ def test_read_digitaal_adres(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) def test_create_digitaal_adres(self): list_url = reverse("klantinteracties:digitaaladres-list") diff --git a/src/openklant/components/klantinteracties/api/tests/test_internetaken.py b/src/openklant/components/klantinteracties/api/tests/test_internetaken.py index ce258ddb..6a043760 100644 --- a/src/openklant/components/klantinteracties/api/tests/test_internetaken.py +++ b/src/openklant/components/klantinteracties/api/tests/test_internetaken.py @@ -50,6 +50,8 @@ def test_read_internetaak(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) @freeze_time("2024-01-01T12:00:00Z") def test_create_internetaak(self): diff --git a/src/openklant/components/klantinteracties/api/tests/test_klantcontacten.py b/src/openklant/components/klantinteracties/api/tests/test_klantcontacten.py index 6697c97b..bb74129a 100644 --- a/src/openklant/components/klantinteracties/api/tests/test_klantcontacten.py +++ b/src/openklant/components/klantinteracties/api/tests/test_klantcontacten.py @@ -86,6 +86,8 @@ def test_read_klantcontact(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) with self.subTest("test_had_betrokken_actoren"): data = response.json() @@ -397,6 +399,8 @@ def test_read_betrokkene(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) def test_create_betrokkene_with_partij(self): klantcontact = KlantcontactFactory.create() @@ -834,6 +838,8 @@ def test_read_bijlage(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) def test_create_bijlage(self): list_url = reverse("klantinteracties:bijlage-list") @@ -1071,6 +1077,8 @@ def test_read_onderwerpobject(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) def test_create_onderwerpobject(self): list_url = reverse("klantinteracties:onderwerpobject-list") @@ -1349,6 +1357,8 @@ def test_read_actorklantcontact(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) def test_create_actorklantcontact(self): list_url = reverse("klantinteracties:actorklantcontact-list") diff --git a/src/openklant/components/klantinteracties/api/tests/test_partijen.py b/src/openklant/components/klantinteracties/api/tests/test_partijen.py index 9b1af25e..03bc9bf3 100644 --- a/src/openklant/components/klantinteracties/api/tests/test_partijen.py +++ b/src/openklant/components/klantinteracties/api/tests/test_partijen.py @@ -80,6 +80,8 @@ def test_read_partij(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) with self.subTest("test_categorie_relatie_with_categorie_names"): categorie = CategorieFactory.create(naam="test-categorie-naam") @@ -1865,6 +1867,8 @@ def test_read_partij_identificator(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) def test_create_partij_indetificator(self): list_url = reverse("klantinteracties:partijidentificator-list") @@ -2040,6 +2044,8 @@ def test_read_categorie_relatie(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) def test_create_categorie_relatie(self): list_url = reverse("klantinteracties:categorierelatie-list") @@ -2184,6 +2190,8 @@ def test_read_categorie(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) def test_create_categorie(self): list_url = reverse("klantinteracties:categorie-list") @@ -2277,6 +2285,8 @@ def test_read_vertegenwoordigden(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) def test_create_vertegenwoordigden(self): list_url = reverse("klantinteracties:vertegenwoordigden-list") diff --git a/src/openklant/components/klantinteracties/api/tests/test_rekeningnummers.py b/src/openklant/components/klantinteracties/api/tests/test_rekeningnummers.py index c295cc14..2fbf2830 100644 --- a/src/openklant/components/klantinteracties/api/tests/test_rekeningnummers.py +++ b/src/openklant/components/klantinteracties/api/tests/test_rekeningnummers.py @@ -45,6 +45,8 @@ def test_read_rekeningnummer(self): response = self.client.get(detail_url) self.assertEqual(response.status_code, status.HTTP_200_OK) + data = response.json() + self.assertEqual(data["url"], "http://testserver" + detail_url) def test_create_rekeningnummer(self): list_url = reverse("klantinteracties:rekeningnummer-list") diff --git a/src/openklant/components/klantinteracties/openapi.yaml b/src/openklant/components/klantinteracties/openapi.yaml index 68e0fff1..b3214305 100644 --- a/src/openklant/components/klantinteracties/openapi.yaml +++ b/src/openklant/components/klantinteracties/openapi.yaml @@ -5248,6 +5248,11 @@ components: format: uuid readOnly: true description: Unieke (technische) identificatiecode van de interne taak. + url: + type: string + format: uri + readOnly: true + description: De unieke URL van deze rekeningnummer binnen deze API. partij: allOf: - $ref: '#/components/schemas/PartijForeignKey' @@ -5297,6 +5302,11 @@ components: format: uuid readOnly: true description: Unieke (technische) identificatiecode van de interne taak. + url: + type: string + format: uri + readOnly: true + description: De unieke URL van deze rekeningnummer binnen deze API. partij: allOf: - $ref: '#/components/schemas/PartijForeignKey' @@ -5320,6 +5330,7 @@ components: required: - iban - partij + - url - uuid RekeningnummerForeignKey: type: object