Skip to content

Commit

Permalink
Merge pull request #281 from maykinmedia/feature/254-fix-api-url-fields
Browse files Browse the repository at this point in the history
Fixed url fields urls.
  • Loading branch information
bart-maykin authored Nov 29, 2024
2 parents bedc8fd + e68be8e commit 2d20f6b
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
Expand Down
94 changes: 90 additions & 4 deletions src/openklant/components/contactgegevens/api/tests/test_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 11 additions & 0 deletions src/openklant/components/klantinteracties/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -5320,6 +5330,7 @@ components:
required:
- iban
- partij
- url
- uuid
RekeningnummerForeignKey:
type: object
Expand Down

0 comments on commit 2d20f6b

Please sign in to comment.