From f75f41f5dba6aff3aaadc7c468ea4b5947b7e9f8 Mon Sep 17 00:00:00 2001 From: bart-maykin Date: Fri, 15 Nov 2024 16:19:41 +0100 Subject: [PATCH 1/2] :bug: [#254] fix wrongly configured url view_names within the PersoonSerializer and BijlageSerializer. --- src/openklant/components/contactgegevens/api/serializers.py | 2 +- .../klantinteracties/api/serializers/klantcontacten.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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."), }, From e68be8eb3a7a60889ee9f38defb607b83f637ea1 Mon Sep 17 00:00:00 2001 From: bart-maykin Date: Fri, 22 Nov 2024 15:19:26 +0100 Subject: [PATCH 2/2] :white_check_mark: [#254] added tests to see the api url fields are the same as the detail page --- .../contactgegevens/api/tests/test_apis.py | 94 ++++++++++++++++++- .../api/serializers/partijen.py | 2 +- .../api/serializers/rekeningnummers.py | 2 +- .../api/tests/test_actoren.py | 2 + .../api/tests/test_digitaal_adres.py | 2 + .../api/tests/test_internetaken.py | 2 + .../api/tests/test_klantcontacten.py | 10 ++ .../api/tests/test_partijen.py | 10 ++ .../api/tests/test_rekeningnummers.py | 2 + .../components/klantinteracties/openapi.yaml | 11 +++ 10 files changed, 131 insertions(+), 6 deletions(-) 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/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 54d73160..b641f788 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 a4fb7925..df9c81a6 100644 --- a/src/openklant/components/klantinteracties/api/tests/test_digitaal_adres.py +++ b/src/openklant/components/klantinteracties/api/tests/test_digitaal_adres.py @@ -52,6 +52,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 aa196bba..0609d00d 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 171b43f2..355c433d 100644 --- a/src/openklant/components/klantinteracties/api/tests/test_partijen.py +++ b/src/openklant/components/klantinteracties/api/tests/test_partijen.py @@ -78,6 +78,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") @@ -1820,6 +1822,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") @@ -1995,6 +1999,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") @@ -2139,6 +2145,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") @@ -2232,6 +2240,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 6575bb24..dce4e680 100644 --- a/src/openklant/components/klantinteracties/openapi.yaml +++ b/src/openklant/components/klantinteracties/openapi.yaml @@ -5200,6 +5200,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' @@ -5249,6 +5254,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' @@ -5272,6 +5282,7 @@ components: required: - iban - partij + - url - uuid RekeningnummerForeignKey: type: object