-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#232] use an enum for
soortDigitaalAdres
- Loading branch information
Showing
7 changed files
with
106 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from rest_framework import status | ||
from vng_api_common.tests import reverse | ||
|
||
from openklant.components.klantinteracties.constants import SoortDigitaalAdres | ||
from openklant.components.klantinteracties.models.tests.factories.digitaal_adres import ( | ||
DigitaalAdresFactory, | ||
) | ||
|
@@ -54,8 +55,8 @@ def test_create_digitaal_adres(self): | |
data = { | ||
"verstrektDoorBetrokkene": None, | ||
"verstrektDoorPartij": None, | ||
"soortDigitaalAdres": "soortDigitaalAdres", | ||
"adres": "adres", | ||
"soortDigitaalAdres": SoortDigitaalAdres.email, | ||
"adres": "[email protected]", | ||
"omschrijving": "omschrijving", | ||
} | ||
|
||
|
@@ -65,9 +66,9 @@ def test_create_digitaal_adres(self): | |
data = response.json() | ||
|
||
self.assertIsNone(data["verstrektDoorBetrokkene"]) | ||
self.assertEqual(data["soortDigitaalAdres"], "soortDigitaalAdres") | ||
self.assertEqual(data["soortDigitaalAdres"], SoortDigitaalAdres.email) | ||
self.assertEqual(data["verstrektDoorPartij"], None) | ||
self.assertEqual(data["adres"], "adres") | ||
self.assertEqual(data["adres"], "[email protected]") | ||
self.assertEqual(data["omschrijving"], "omschrijving") | ||
|
||
with self.subTest("with_betrokkene_and_partij"): | ||
|
@@ -85,8 +86,8 @@ def test_create_digitaal_adres(self): | |
data["verstrektDoorBetrokkene"]["uuid"], str(betrokkene.uuid) | ||
) | ||
self.assertEqual(data["verstrektDoorPartij"]["uuid"], str(partij.uuid)) | ||
self.assertEqual(data["soortDigitaalAdres"], "soortDigitaalAdres") | ||
self.assertEqual(data["adres"], "adres") | ||
self.assertEqual(data["soortDigitaalAdres"], SoortDigitaalAdres.email) | ||
self.assertEqual(data["adres"], "[email protected]") | ||
self.assertEqual(data["omschrijving"], "omschrijving") | ||
|
||
def test_update_digitaal_adres(self): | ||
|
@@ -95,8 +96,8 @@ def test_update_digitaal_adres(self): | |
digitaal_adres = DigitaalAdresFactory.create( | ||
betrokkene=betrokkene, | ||
partij=partij2, | ||
soort_digitaal_adres="soortDigitaalAdres", | ||
adres="adres", | ||
soort_digitaal_adres=SoortDigitaalAdres.email, | ||
adres="[email protected]", | ||
omschrijving="omschrijving", | ||
) | ||
detail_url = reverse( | ||
|
@@ -108,15 +109,15 @@ def test_update_digitaal_adres(self): | |
|
||
self.assertEqual(data["verstrektDoorBetrokkene"]["uuid"], str(betrokkene.uuid)) | ||
self.assertEqual(data["verstrektDoorPartij"]["uuid"], str(partij2.uuid)) | ||
self.assertEqual(data["soortDigitaalAdres"], "soortDigitaalAdres") | ||
self.assertEqual(data["adres"], "adres") | ||
self.assertEqual(data["soortDigitaalAdres"], SoortDigitaalAdres.email) | ||
self.assertEqual(data["adres"], "[email protected]") | ||
self.assertEqual(data["omschrijving"], "omschrijving") | ||
|
||
data = { | ||
"verstrektDoorBetrokkene": {"uuid": str(betrokkene2.uuid)}, | ||
"verstrektDoorPartij": {"uuid": str(partij.uuid)}, | ||
"soortDigitaalAdres": "changed", | ||
"adres": "changed", | ||
"soortDigitaalAdres": SoortDigitaalAdres.telefoonnummer, | ||
"adres": "0721434543", | ||
"omschrijving": "changed", | ||
} | ||
|
||
|
@@ -128,16 +129,16 @@ def test_update_digitaal_adres(self): | |
|
||
self.assertEqual(data["verstrektDoorBetrokkene"]["uuid"], str(betrokkene2.uuid)) | ||
self.assertEqual(data["verstrektDoorPartij"]["uuid"], str(partij.uuid)) | ||
self.assertEqual(data["soortDigitaalAdres"], "changed") | ||
self.assertEqual(data["adres"], "changed") | ||
self.assertEqual(data["soortDigitaalAdres"], SoortDigitaalAdres.telefoonnummer) | ||
self.assertEqual(data["adres"], "0721434543") | ||
self.assertEqual(data["omschrijving"], "changed") | ||
|
||
with self.subTest("update_betrokkene_partij_to_none"): | ||
data = { | ||
"verstrektDoorBetrokkene": None, | ||
"verstrektDoorPartij": None, | ||
"soortDigitaalAdres": "changed", | ||
"adres": "changed", | ||
"soortDigitaalAdres": SoortDigitaalAdres.telefoonnummer, | ||
"adres": "0721434543", | ||
"omschrijving": "changed", | ||
} | ||
|
||
|
@@ -149,8 +150,10 @@ def test_update_digitaal_adres(self): | |
|
||
self.assertIsNone(data["verstrektDoorBetrokkene"]) | ||
self.assertIsNone(data["verstrektDoorPartij"]) | ||
self.assertEqual(data["soortDigitaalAdres"], "changed") | ||
self.assertEqual(data["adres"], "changed") | ||
self.assertEqual( | ||
data["soortDigitaalAdres"], SoortDigitaalAdres.telefoonnummer | ||
) | ||
self.assertEqual(data["adres"], "0721434543") | ||
self.assertEqual(data["omschrijving"], "changed") | ||
|
||
def test_partial_update_digitaal_adres(self): | ||
|
@@ -159,8 +162,8 @@ def test_partial_update_digitaal_adres(self): | |
digitaal_adres = DigitaalAdresFactory.create( | ||
betrokkene=betrokkene, | ||
partij=partij, | ||
soort_digitaal_adres="soortDigitaalAdres", | ||
adres="adres", | ||
soort_digitaal_adres=SoortDigitaalAdres.email, | ||
adres="[email protected]", | ||
omschrijving="omschrijving", | ||
) | ||
detail_url = reverse( | ||
|
@@ -172,12 +175,13 @@ def test_partial_update_digitaal_adres(self): | |
|
||
self.assertEqual(data["verstrektDoorBetrokkene"]["uuid"], str(betrokkene.uuid)) | ||
self.assertEqual(data["verstrektDoorPartij"]["uuid"], str(partij.uuid)) | ||
self.assertEqual(data["soortDigitaalAdres"], "soortDigitaalAdres") | ||
self.assertEqual(data["adres"], "adres") | ||
self.assertEqual(data["soortDigitaalAdres"], SoortDigitaalAdres.email) | ||
self.assertEqual(data["adres"], "[email protected]") | ||
self.assertEqual(data["omschrijving"], "omschrijving") | ||
|
||
data = { | ||
"soortDigitaalAdres": "changed", | ||
"soortDigitaalAdres": SoortDigitaalAdres.telefoonnummer, | ||
"adres": "0721434543", | ||
} | ||
|
||
response = self.client.patch(detail_url, data) | ||
|
@@ -188,8 +192,8 @@ def test_partial_update_digitaal_adres(self): | |
|
||
self.assertEqual(data["verstrektDoorBetrokkene"]["uuid"], str(betrokkene.uuid)) | ||
self.assertEqual(data["verstrektDoorPartij"]["uuid"], str(partij.uuid)) | ||
self.assertEqual(data["soortDigitaalAdres"], "changed") | ||
self.assertEqual(data["adres"], "adres") | ||
self.assertEqual(data["soortDigitaalAdres"], SoortDigitaalAdres.telefoonnummer) | ||
self.assertEqual(data["adres"], "0721434543") | ||
self.assertEqual(data["omschrijving"], "omschrijving") | ||
|
||
def test_destroy_digitaal_adres(self): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.db.models import TextChoices | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class SoortDigitaalAdres(TextChoices): | ||
email = "email", _("Email") | ||
telefoonnummer = "telefoonnummer", _("Telefoonnummer") | ||
overig = "overig", _("Overig") |
27 changes: 27 additions & 0 deletions
27
...t/components/klantinteracties/migrations/0020_alter_digitaaladres_soort_digitaal_adres.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 4.2.15 on 2024-10-18 10:38 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("klantinteracties", "0019_alter_partij_indicatie_geheimhouding"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="digitaaladres", | ||
name="soort_digitaal_adres", | ||
field=models.CharField( | ||
choices=[ | ||
("email", "Man"), | ||
("telefoonnummer", "Telefoonnummer"), | ||
("overig", "Overig"), | ||
], | ||
help_text="Typering van het digitale adres die aangeeft via welk(e) kanaal of kanalen met dit adres contact kan worden opgenomen.", | ||
max_length=255, | ||
verbose_name="soort digitaal adres", | ||
), | ||
), | ||
] |
27 changes: 27 additions & 0 deletions
27
...t/components/klantinteracties/migrations/0021_alter_digitaaladres_soort_digitaal_adres.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 4.2.15 on 2024-10-18 10:58 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("klantinteracties", "0020_alter_digitaaladres_soort_digitaal_adres"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="digitaaladres", | ||
name="soort_digitaal_adres", | ||
field=models.CharField( | ||
choices=[ | ||
("email", "Email"), | ||
("telefoonnummer", "Telefoonnummer"), | ||
("overig", "Overig"), | ||
], | ||
help_text="Typering van het digitale adres die aangeeft via welk(e) kanaal of kanalen met dit adres contact kan worden opgenomen.", | ||
max_length=255, | ||
verbose_name="soort digitaal adres", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters