@@ -1048,38 +1048,166 @@ def test_update_partij(self):
1048
1048
},
1049
1049
)
1050
1050
1051
- def test_update_partij_partijidentificator_empty_list(self):
1052
- partij = PartijFactory.create(
1053
- nummer="1298329191",
1054
- interne_notitie="interneNotitie",
1055
- voorkeurs_digitaal_adres=None,
1056
- voorkeurs_rekeningnummer=None,
1057
- soort_partij="persoon",
1058
- indicatie_geheimhouding=True,
1059
- voorkeurstaal="ndl",
1060
- indicatie_actief=True,
1061
- bezoekadres_nummeraanduiding_id="095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
1062
- bezoekadres_adresregel1="adres1",
1063
- bezoekadres_adresregel2="adres2",
1064
- bezoekadres_adresregel3="adres3",
1065
- bezoekadres_land="6030",
1066
- correspondentieadres_nummeraanduiding_id="095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
1067
- correspondentieadres_adresregel1="adres1",
1068
- correspondentieadres_adresregel2="adres2",
1069
- correspondentieadres_adresregel3="adres3",
1070
- correspondentieadres_land="6030",
1051
+ def test_update_partij_partijidentificator(self):
1052
+ partij = PartijFactory.create()
1053
+ digitaal_adres2 = DigitaalAdresFactory.create()
1054
+ partij_identificator = PartijIdentificatorFactory.create(
1055
+ partij_identificator_code_objecttype="natuurlijk_persoon",
1056
+ partij_identificator_code_soort_object_id="bsn",
1057
+ partij_identificator_object_id="296648875",
1058
+ partij_identificator_code_register="brp",
1071
1059
)
1072
- PersoonFactory.create(
1073
- partij=partij,
1074
- contactnaam_voorletters="P",
1075
- contactnaam_voornaam="Phil",
1076
- contactnaam_voorvoegsel_achternaam="",
1077
- contactnaam_achternaam="Bozeman",
1060
+ detail_url = reverse(
1061
+ "klantinteracties:partij-detail", kwargs={"uuid": str(partij.uuid)}
1078
1062
)
1063
+ response = self.client.get(detail_url)
1064
+ data = response.json()
1065
+ self.assertEqual(partij.partijidentificator_set.all().count(), 0)
1079
1066
1067
+ data = {
1068
+ "digitaleAdressen": [{"uuid": str(digitaal_adres2.uuid)}],
1069
+ "voorkeursDigitaalAdres": {"uuid": str(digitaal_adres2.uuid)},
1070
+ "rekeningnummers": [],
1071
+ "voorkeursRekeningnummer": None,
1072
+ "soortPartij": "persoon",
1073
+ "indicatieActief": True,
1074
+ "partijIdentificatoren": [
1075
+ {
1076
+ "uuid": str(partij_identificator.uuid),
1077
+ },
1078
+ ],
1079
+ }
1080
+
1081
+ response = self.client.put(detail_url, data)
1082
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
1083
+
1084
+ data = response.json()
1085
+ self.assertEqual(len(data["partijIdentificatoren"]), 1)
1086
+ self.assertEqual(partij.partijidentificator_set.all().count(), 1)
1087
+
1088
+ self.assertEqual(
1089
+ data["partijIdentificatoren"][0]["partijIdentificator"],
1090
+ {
1091
+ "codeObjecttype": partij_identificator.partij_identificator_code_objecttype,
1092
+ "codeSoortObjectId": partij_identificator.partij_identificator_code_soort_object_id,
1093
+ "objectId": partij_identificator.partij_identificator_object_id,
1094
+ "codeRegister": partij_identificator.partij_identificator_code_register,
1095
+ },
1096
+ )
1097
+
1098
+ def test_update_replace_partij_partijidentificator(self):
1099
+ partij = PartijFactory.create()
1080
1100
digitaal_adres2 = DigitaalAdresFactory.create()
1081
- rekeningnummer2 = RekeningnummerFactory.create()
1101
+ partij_identificator_1 = PartijIdentificatorFactory.create(
1102
+ partij=partij,
1103
+ partij_identificator_code_objecttype="natuurlijk_persoon",
1104
+ partij_identificator_code_soort_object_id="bsn",
1105
+ partij_identificator_object_id="296648875",
1106
+ partij_identificator_code_register="brp",
1107
+ )
1108
+ partij_identificator_2 = PartijIdentificatorFactory.create(
1109
+ partij_identificator_code_objecttype="niet_natuurlijk_persoon",
1110
+ partij_identificator_code_soort_object_id="rsin",
1111
+ partij_identificator_object_id="296648875",
1112
+ partij_identificator_code_register="hr",
1113
+ )
1114
+ detail_url = reverse(
1115
+ "klantinteracties:partij-detail", kwargs={"uuid": str(partij.uuid)}
1116
+ )
1117
+ response = self.client.get(detail_url)
1118
+ data = response.json()
1119
+ self.assertEqual(len(data["partijIdentificatoren"]), 1)
1120
+ self.assertEqual(partij.partijidentificator_set.all().count(), 1)
1121
+
1122
+ # Check simple GET
1123
+ self.assertEqual(
1124
+ data["partijIdentificatoren"][0]["partijIdentificator"],
1125
+ {
1126
+ "codeObjecttype": partij_identificator_1.partij_identificator_code_objecttype,
1127
+ "codeSoortObjectId": partij_identificator_1.partij_identificator_code_soort_object_id,
1128
+ "objectId": partij_identificator_1.partij_identificator_object_id,
1129
+ "codeRegister": partij_identificator_1.partij_identificator_code_register,
1130
+ },
1131
+ )
1132
+ # Update with specific partij_identificator (UUID)
1133
+ data = {
1134
+ "digitaleAdressen": [{"uuid": str(digitaal_adres2.uuid)}],
1135
+ "voorkeursDigitaalAdres": {"uuid": str(digitaal_adres2.uuid)},
1136
+ "rekeningnummers": [],
1137
+ "voorkeursRekeningnummer": None,
1138
+ "soortPartij": "persoon",
1139
+ "indicatieActief": True,
1140
+ "partijIdentificatoren": [
1141
+ {
1142
+ "uuid": str(partij_identificator_2.uuid),
1143
+ },
1144
+ ],
1145
+ }
1146
+
1147
+ response = self.client.put(detail_url, data)
1148
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
1149
+
1150
+ data = response.json()
1151
+ self.assertEqual(len(data["partijIdentificatoren"]), 1)
1152
+ self.assertEqual(partij.partijidentificator_set.all().count(), 1)
1153
+
1154
+ # Check new values
1155
+ self.assertEqual(
1156
+ data["partijIdentificatoren"][0]["partijIdentificator"],
1157
+ {
1158
+ "codeObjecttype": partij_identificator_2.partij_identificator_code_objecttype,
1159
+ "codeSoortObjectId": partij_identificator_2.partij_identificator_code_soort_object_id,
1160
+ "objectId": partij_identificator_2.partij_identificator_object_id,
1161
+ "codeRegister": partij_identificator_2.partij_identificator_code_register,
1162
+ },
1163
+ )
1164
+ partij_identificator_3 = PartijIdentificatorFactory.create(
1165
+ partij_identificator_code_objecttype="niet_natuurlijk_persoon",
1166
+ partij_identificator_code_soort_object_id="rsin",
1167
+ partij_identificator_object_id="296648875",
1168
+ partij_identificator_code_register="hr",
1169
+ )
1082
1170
1171
+ # Update with new partij_identificator and specific partij_identificator (UUID)
1172
+ data = {
1173
+ "digitaleAdressen": [{"uuid": str(digitaal_adres2.uuid)}],
1174
+ "voorkeursDigitaalAdres": {"uuid": str(digitaal_adres2.uuid)},
1175
+ "rekeningnummers": [],
1176
+ "voorkeursRekeningnummer": None,
1177
+ "soortPartij": "persoon",
1178
+ "indicatieActief": True,
1179
+ "partijIdentificatoren": [
1180
+ {
1181
+ "anderePartijIdentificator": "string",
1182
+ "partijIdentificator": {
1183
+ "codeObjecttype": "natuurlijk_persoon",
1184
+ "codeSoortObjectId": "bsn",
1185
+ "objectId": "296648875",
1186
+ "codeRegister": "brp",
1187
+ },
1188
+ },
1189
+ {
1190
+ "uuid": str(partij_identificator_3.uuid),
1191
+ },
1192
+ ],
1193
+ }
1194
+
1195
+ response = self.client.put(detail_url, data)
1196
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
1197
+
1198
+ data = response.json()
1199
+ self.assertEqual(len(data["partijIdentificatoren"]), 2)
1200
+ self.assertEqual(partij.partijidentificator_set.all().count(), 2)
1201
+ self.assertTrue(
1202
+ str(partij_identificator_3.uuid)
1203
+ in [
1204
+ identificator["uuid"] for identificator in data["partijIdentificatoren"]
1205
+ ]
1206
+ )
1207
+
1208
+ def test_update_partij_partijidentificator_empty_list(self):
1209
+ partij = PartijFactory.create()
1210
+ digitaal_adres2 = DigitaalAdresFactory.create()
1083
1211
partij_identificator = PartijIdentificatorFactory.create(
1084
1212
partij=partij,
1085
1213
partij_identificator_code_objecttype="natuurlijk_persoon",
@@ -1091,6 +1219,7 @@ def test_update_partij_partijidentificator_empty_list(self):
1091
1219
detail_url = reverse(
1092
1220
"klantinteracties:partij-detail", kwargs={"uuid": str(partij.uuid)}
1093
1221
)
1222
+
1094
1223
response = self.client.get(detail_url)
1095
1224
data = response.json()
1096
1225
self.assertEqual(partij.partijidentificator_set.all().count(), 1)
@@ -1105,45 +1234,19 @@ def test_update_partij_partijidentificator_empty_list(self):
1105
1234
)
1106
1235
1107
1236
data = {
1108
- "nummer": "6427834668",
1109
- "interneNotitie": "changed",
1110
1237
"digitaleAdressen": [{"uuid": str(digitaal_adres2.uuid)}],
1111
1238
"voorkeursDigitaalAdres": {"uuid": str(digitaal_adres2.uuid)},
1112
- "rekeningnummers": [{"uuid": str(rekeningnummer2.uuid)} ],
1113
- "voorkeursRekeningnummer": {"uuid": str(rekeningnummer2.uuid)} ,
1239
+ "rekeningnummers": [],
1240
+ "voorkeursRekeningnummer": None ,
1114
1241
"soortPartij": "persoon",
1115
- "indicatieGeheimhouding": None,
1116
- "voorkeurstaal": "ger",
1117
- "indicatieActief": False,
1118
- "bezoekadres": {
1119
- "nummeraanduidingId": "f78sd8f-uh45-34km-2o3n-aasdasdasc9g",
1120
- "adresregel1": "changed",
1121
- "adresregel2": "changed",
1122
- "adresregel3": "changed",
1123
- "land": "3060",
1124
- },
1125
- "correspondentieadres": {
1126
- "nummeraanduidingId": "sd76f7sd-j4nr-a9s8-83ec-sad89f79a7sd",
1127
- "adresregel1": "changed",
1128
- "adresregel2": "changed",
1129
- "adresregel3": "changed",
1130
- "land": "3060",
1131
- },
1132
- "partijIdentificatie": {
1133
- "contactnaam": {
1134
- "voorletters": "V",
1135
- "voornaam": "Vincent",
1136
- "voorvoegselAchternaam": "",
1137
- "achternaam": "Bennette",
1138
- }
1139
- },
1242
+ "indicatieActief": True,
1140
1243
"partijIdentificatoren": [],
1141
1244
}
1142
1245
1143
1246
response = self.client.put(detail_url, data)
1144
1247
self.assertEqual(response.status_code, status.HTTP_200_OK)
1145
- data = response.json()
1146
1248
1249
+ data = response.json()
1147
1250
self.assertEqual(len(data["partijIdentificatoren"]), 0)
1148
1251
self.assertEqual(partij.partijidentificator_set.all().count(), 0)
1149
1252
0 commit comments