Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed url fields urls. #281

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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")
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 @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
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 @@ -1838,7 +1838,7 @@
description: Maak een KlantContact, Betrokkene en een OnderwerpObject aan.
summary: Maak een KlantContact, Betrokkene en een OnderwerpObject aan.
tags:
- maak-klantcontact

Check warning on line 1841 in src/openklant/components/klantinteracties/openapi.yaml

View workflow job for this annotation

GitHub Actions / open-api-workflow-lint-oas (klantinteracties) / lint-oas-files

operation-tag-defined Operation tags should be defined in global tags.
requestBody:
content:
application/json:
Expand Down Expand Up @@ -4041,7 +4041,7 @@
type: array
items:
$ref: '#/components/schemas/CategorieRelatie'
PaginatedDigitaalAdresList:

Check warning on line 4044 in src/openklant/components/klantinteracties/openapi.yaml

View workflow job for this annotation

GitHub Actions / open-api-workflow-lint-oas (klantinteracties) / lint-oas-files

oas3-unused-components-schema Potentially unused components schema has been detected.
type: object
required:
- count
Expand Down Expand Up @@ -4156,7 +4156,7 @@
type: array
items:
$ref: '#/components/schemas/InterneTaak'
PaginatedKlantcontactList:

Check warning on line 4159 in src/openklant/components/klantinteracties/openapi.yaml

View workflow job for this annotation

GitHub Actions / open-api-workflow-lint-oas (klantinteracties) / lint-oas-files

oas3-unused-components-schema Potentially unused components schema has been detected.
type: object
required:
- count
Expand Down Expand Up @@ -4225,7 +4225,7 @@
type: array
items:
$ref: '#/components/schemas/PartijIdentificator'
PaginatedPartijList:

Check warning on line 4228 in src/openklant/components/klantinteracties/openapi.yaml

View workflow job for this annotation

GitHub Actions / open-api-workflow-lint-oas (klantinteracties) / lint-oas-files

oas3-unused-components-schema Potentially unused components schema has been detected.
type: object
required:
- count
Expand Down Expand Up @@ -5200,6 +5200,11 @@
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 @@ -5249,6 +5254,11 @@
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 @@ -5272,6 +5282,7 @@
required:
- iban
- partij
- url
- uuid
RekeningnummerForeignKey:
type: object
Expand Down
Loading