@@ -2235,7 +2235,7 @@ def setUp(self):
2235
2235
self .partij = PartijFactory .create ()
2236
2236
super ().setUp ()
2237
2237
2238
- def test_bsn_valid_create (self ):
2238
+ def test_valid_create (self ):
2239
2239
data = {
2240
2240
"identificeerdePartij" : {"uuid" : str (self .partij .uuid )},
2241
2241
"anderePartijIdentificator" : "anderePartijIdentificator" ,
@@ -2251,8 +2251,7 @@ def test_bsn_valid_create(self):
2251
2251
self .assertEqual (response .status_code , status .HTTP_201_CREATED )
2252
2252
self .assertEqual (PartijIdentificator .objects .all ().count (), 1 )
2253
2253
2254
- def test_bsn_valid_create_sub_identificator_van (self ):
2255
- # sub_identificator_van not allowed for partij_identificator_code_soort_object_id = 'bsn'
2254
+ def test_valid_create_sub_identificator_van (self ):
2256
2255
partij_identificator = PartijIdentificatorFactory .create (
2257
2256
partij = self .partij ,
2258
2257
andere_partij_identificator = "anderePartijIdentificator" ,
@@ -2264,19 +2263,19 @@ def test_bsn_valid_create_sub_identificator_van(self):
2264
2263
2265
2264
data = {
2266
2265
"identificeerdePartij" : {"uuid" : str (self .partij .uuid )},
2266
+ "sub_identificator_van" : {"uuid" : str (partij_identificator .uuid )},
2267
2267
"partijIdentificator" : {
2268
2268
"codeObjecttype" : "natuurlijk_persoon" ,
2269
2269
"codeSoortObjectId" : "bsn" ,
2270
2270
"objectId" : "296648875" ,
2271
2271
"codeRegister" : "brp" ,
2272
2272
},
2273
2273
}
2274
- data ["sub_identificator_van" ] = {"uuid" : str (partij_identificator .uuid )}
2275
2274
response = self .client .post (self .list_url , data )
2276
2275
self .assertEqual (response .status_code , status .HTTP_201_CREATED )
2277
2276
self .assertEqual (PartijIdentificator .objects .all ().count (), 2 )
2278
2277
2279
- def test_bsn_invalid_create_global_unique (self ):
2278
+ def test_invalid_create_global_unique (self ):
2280
2279
PartijIdentificatorFactory .create (
2281
2280
partij = self .partij ,
2282
2281
partij_identificator_code_objecttype = "natuurlijk_persoon" ,
@@ -2294,11 +2293,31 @@ def test_bsn_invalid_create_global_unique(self):
2294
2293
"codeRegister" : "brp" ,
2295
2294
},
2296
2295
}
2297
-
2296
+ sub_identificator_van = PartijIdentificatorFactory .create (
2297
+ partij = self .partij ,
2298
+ partij_identificator_code_objecttype = "niet_natuurlijk_persoon" ,
2299
+ partij_identificator_code_soort_object_id = "kvk_nummer" ,
2300
+ partij_identificator_object_id = "12345678" ,
2301
+ partij_identificator_code_register = "hr" ,
2302
+ )
2303
+ with self .subTest ("ok_subtest_global_1" ):
2304
+ # sub_identificator_van is set
2305
+ data ["sub_identificator_van" ] = {"uuid" : str (sub_identificator_van .uuid )}
2306
+ response = self .client .post (self .list_url , data )
2307
+ self .assertEqual (response .status_code , status .HTTP_201_CREATED )
2308
+ with self .subTest ("failed_subtest_global_1" ):
2309
+ # combination sub_identificator_van and partij_identificator arleady exists
2310
+ data ["sub_identificator_van" ] = {"uuid" : str (sub_identificator_van .uuid )}
2311
+ response = self .client .post (self .list_url , data )
2312
+ self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
2313
+ self .assertEqual (response .data ["code" ], "invalid" )
2314
+ self .assertEqual (response .data ["title" ], "Invalid input." )
2315
+ self .assertEqual (
2316
+ response .data ["invalid_params" ][0 ]["reason" ],
2317
+ "`PartijIdentificator` moet uniek zijn, er bestaat er al een met deze gegevenscombinatie." ,
2318
+ )
2298
2319
with self .subTest ("failed_subtest_global_2" ):
2299
- # new partij, same data_values
2300
- partij = PartijFactory .create ()
2301
- data ["identificeerdePartij" ] = {"uuid" : str (partij .uuid )}
2320
+ # same partij, same data_values
2302
2321
response = self .client .post (self .list_url , data )
2303
2322
self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
2304
2323
self .assertEqual (response .data ["code" ], "invalid" )
@@ -2319,7 +2338,7 @@ def test_bsn_invalid_create_global_unique(self):
2319
2338
"`PartijIdentificator` moet uniek zijn, er bestaat er al een met deze gegevenscombinatie." ,
2320
2339
)
2321
2340
2322
- def test_bsn_valid_partial_update_unique (self ):
2341
+ def test_valid_update_simple_field (self ):
2323
2342
partij_identificator = PartijIdentificatorFactory .create (
2324
2343
partij = self .partij ,
2325
2344
andere_partij_identificator = "anderePartijIdentificator" ,
@@ -2352,7 +2371,29 @@ def test_bsn_valid_partial_update_unique(self):
2352
2371
},
2353
2372
)
2354
2373
2355
- def test_bsn_valid_update_unique (self ):
2374
+ def test_valid_update_partij (self ):
2375
+ partij_identificator = PartijIdentificatorFactory .create (
2376
+ andere_partij_identificator = "anderePartijIdentificator" ,
2377
+ partij_identificator_code_objecttype = "natuurlijk_persoon" ,
2378
+ partij_identificator_code_soort_object_id = "bsn" ,
2379
+ partij_identificator_object_id = "123456782" ,
2380
+ partij_identificator_code_register = "brp" ,
2381
+ )
2382
+
2383
+ data = {
2384
+ "identificeerdePartij" : {"uuid" : str (self .partij .uuid )},
2385
+ }
2386
+ detail_url = reverse (
2387
+ "klantinteracties:partijidentificator-detail" ,
2388
+ kwargs = {"uuid" : str (partij_identificator .uuid )},
2389
+ )
2390
+
2391
+ response = self .client .patch (detail_url , data )
2392
+ self .assertEqual (response .status_code , status .HTTP_200_OK )
2393
+ data = response .json ()
2394
+ self .assertEqual (data ["identificeerdePartij" ]["uuid" ], str (self .partij .uuid ))
2395
+
2396
+ def test_valid_update_unique (self ):
2356
2397
partij_identificator = PartijIdentificatorFactory .create (
2357
2398
partij = self .partij ,
2358
2399
andere_partij_identificator = "anderePartijIdentificator" ,
@@ -2392,7 +2433,7 @@ def test_bsn_valid_update_unique(self):
2392
2433
},
2393
2434
)
2394
2435
2395
- def test_bsn_invalid_update_unique_already_exists (self ):
2436
+ def test_invalid_update_unique_already_exists (self ):
2396
2437
partij_identificator_a = PartijIdentificatorFactory .create (
2397
2438
partij = self .partij ,
2398
2439
partij_identificator_code_objecttype = "natuurlijk_persoon" ,
@@ -2434,7 +2475,7 @@ def test_bsn_invalid_update_unique_already_exists(self):
2434
2475
"`PartijIdentificator` moet uniek zijn, er bestaat er al een met deze gegevenscombinatie." ,
2435
2476
)
2436
2477
2437
- def test_bsn_invalid_update_unique_set_sub_identificator_van_self (self ):
2478
+ def test_invalid_update_unique_set_sub_identificator_van_self (self ):
2438
2479
partij_identificator_a = PartijIdentificatorFactory .create (
2439
2480
partij = self .partij ,
2440
2481
partij_identificator_code_objecttype = "natuurlijk_persoon" ,
@@ -2508,6 +2549,73 @@ def test_vestigingsnummer_invalid_create_without_sub_identificator_van(self):
2508
2549
in response .data ["invalid_params" ][0 ]["reason" ]
2509
2550
)
2510
2551
2552
+ def test_vestigingsnummer_invalid_create_without_partij (self ):
2553
+ sub_identificator_van = PartijIdentificatorFactory .create (
2554
+ partij = self .partij ,
2555
+ partij_identificator_code_objecttype = "niet_natuurlijk_persoon" ,
2556
+ partij_identificator_code_soort_object_id = "kvk_nummer" ,
2557
+ partij_identificator_object_id = "12345678" ,
2558
+ partij_identificator_code_register = "hr" ,
2559
+ )
2560
+
2561
+ data = {
2562
+ "identificeerdePartij" : None ,
2563
+ "sub_identificator_van" : {"uuid" : str (sub_identificator_van .uuid )},
2564
+ "partijIdentificator" : {
2565
+ "codeObjecttype" : "vestiging" ,
2566
+ "codeSoortObjectId" : "vestigingsnummer" ,
2567
+ "objectId" : "296648875154" ,
2568
+ "codeRegister" : "hr" ,
2569
+ },
2570
+ }
2571
+
2572
+ response = self .client .post (self .list_url , data )
2573
+ self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
2574
+ self .assertEqual (response .data ["code" ], "invalid" )
2575
+ self .assertEqual (response .data ["title" ], "Invalid input." )
2576
+ self .assertTrue (
2577
+ "Het is niet mogelijk om een partij_identificator te maken zonder de partijwaartoe"
2578
+ in response .data ["invalid_params" ][0 ]["reason" ]
2579
+ )
2580
+
2581
+ def test_vestigingsnummer_invalid_create_external_partij (self ):
2582
+ partij = PartijFactory .create ()
2583
+ sub_identificator_van = PartijIdentificatorFactory .create (
2584
+ partij = partij ,
2585
+ partij_identificator_code_objecttype = "niet_natuurlijk_persoon" ,
2586
+ partij_identificator_code_soort_object_id = "kvk_nummer" ,
2587
+ partij_identificator_object_id = "12345678" ,
2588
+ partij_identificator_code_register = "hr" ,
2589
+ )
2590
+
2591
+ # sub_identificator_van partij is different from vestigingsnummer
2592
+ data = {
2593
+ "identificeerdePartij" : {"uuid" : str (self .partij .uuid )},
2594
+ "sub_identificator_van" : {"uuid" : str (sub_identificator_van .uuid )},
2595
+ "partijIdentificator" : {
2596
+ "codeObjecttype" : "vestiging" ,
2597
+ "codeSoortObjectId" : "vestigingsnummer" ,
2598
+ "objectId" : "296648875154" ,
2599
+ "codeRegister" : "hr" ,
2600
+ },
2601
+ }
2602
+
2603
+ response = self .client .post (self .list_url , data )
2604
+ self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
2605
+ self .assertEqual (response .data ["code" ], "invalid" )
2606
+ self .assertEqual (response .data ["title" ], "Invalid input." )
2607
+ self .assertEqual (
2608
+ response .data ["invalid_params" ][0 ]["reason" ],
2609
+ "Je moet een `sub_identifier_van` selecteren die tot dezelfde partij behoort." ,
2610
+ )
2611
+
2612
+ # valida case sub_identificator_van partij equal vestigingsnummer partij
2613
+ sub_identificator_van .partij = self .partij
2614
+ sub_identificator_van .save ()
2615
+ response = self .client .post (self .list_url , data )
2616
+ self .assertEqual (response .status_code , status .HTTP_201_CREATED )
2617
+ self .assertEqual (PartijIdentificator .objects .all ().count (), 2 )
2618
+
2511
2619
def test_vestigingsnummer_invalid_create_invalid_sub_identificator_van (self ):
2512
2620
sub_identificator_van = PartijIdentificatorFactory .create (
2513
2621
partij = self .partij ,
0 commit comments