@@ -2144,31 +2144,28 @@ def test_invalid_validation_partij_identificator_object_id(self):
2144
2144
"Deze waarde is ongeldig, reden: Waarde moet 9 tekens lang zijn" ,
2145
2145
)
2146
2146
2147
-
2148
- class PartijIdentificatorUniquenessTests (APITestCase ):
2149
- def setUp (self ):
2150
- self .list_url = reverse ("klantinteracties:partijidentificator-list" )
2151
- self .partij = PartijFactory .create ()
2152
- super ().setUp ()
2153
-
2154
2147
def test_invalid_create_empty (self ):
2155
2148
# all partij_identificator fields required
2149
+ partij = PartijFactory .create ()
2150
+ list_url = reverse ("klantinteracties:partijidentificator-list" )
2156
2151
data = {
2157
- "identificeerdePartij" : {"uuid" : str (self . partij .uuid )},
2152
+ "identificeerdePartij" : {"uuid" : str (partij .uuid )},
2158
2153
"anderePartijIdentificator" : "anderePartijIdentificator" ,
2159
2154
"partijIdentificator" : {},
2160
2155
}
2161
2156
2162
- response = self .client .post (self . list_url , data )
2157
+ response = self .client .post (list_url , data )
2163
2158
self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
2164
2159
self .assertEqual (response .data ["code" ], "invalid" )
2165
2160
self .assertEqual (response .data ["title" ], "Invalid input." )
2166
2161
self .assertEqual (len (response .data ["invalid_params" ]), 4 )
2167
2162
2168
2163
def test_invalid_create_partial (self ):
2169
2164
# all partij_identificator fields required
2165
+ partij = PartijFactory .create ()
2166
+ list_url = reverse ("klantinteracties:partijidentificator-list" )
2170
2167
data = {
2171
- "identificeerdePartij" : {"uuid" : str (self . partij .uuid )},
2168
+ "identificeerdePartij" : {"uuid" : str (partij .uuid )},
2172
2169
"anderePartijIdentificator" : "anderePartijIdentificator" ,
2173
2170
"partijIdentificator" : {
2174
2171
"codeObjecttype" : "natuurlijk_persoon" ,
@@ -2177,7 +2174,7 @@ def test_invalid_create_partial(self):
2177
2174
},
2178
2175
}
2179
2176
2180
- response = self .client .post (self . list_url , data )
2177
+ response = self .client .post (list_url , data )
2181
2178
self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
2182
2179
self .assertEqual (response .data ["code" ], "invalid" )
2183
2180
self .assertEqual (response .data ["title" ], "Invalid input." )
@@ -2192,8 +2189,10 @@ def test_invalid_create_partial(self):
2192
2189
2193
2190
def test_invalid_update_partial (self ):
2194
2191
# all partij_identificator fields required
2192
+ partij = PartijFactory .create ()
2193
+ list_url = reverse ("klantinteracties:partijidentificator-list" )
2195
2194
partij_identificator = PartijIdentificatorFactory .create (
2196
- partij = self . partij ,
2195
+ partij = partij ,
2197
2196
andere_partij_identificator = "anderePartijIdentificator" ,
2198
2197
partij_identificator_code_objecttype = "natuurlijk_persoon" ,
2199
2198
partij_identificator_code_soort_object_id = "bsn" ,
@@ -2216,7 +2215,7 @@ def test_invalid_update_partial(self):
2216
2215
2217
2216
response = self .client .patch (detail_url , data )
2218
2217
2219
- response = self .client .post (self . list_url , data )
2218
+ response = self .client .post (list_url , data )
2220
2219
self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
2221
2220
self .assertEqual (response .data ["code" ], "invalid" )
2222
2221
self .assertEqual (response .data ["title" ], "Invalid input." )
@@ -2229,6 +2228,13 @@ def test_invalid_update_partial(self):
2229
2228
)
2230
2229
self .assertEqual (PartijIdentificator .objects .all ().count (), 1 )
2231
2230
2231
+
2232
+ class PartijIdentificatorUniquenessTests (APITestCase ):
2233
+ def setUp (self ):
2234
+ self .list_url = reverse ("klantinteracties:partijidentificator-list" )
2235
+ self .partij = PartijFactory .create ()
2236
+ super ().setUp ()
2237
+
2232
2238
def test_bsn_valid_create (self ):
2233
2239
data = {
2234
2240
"identificeerdePartij" : {"uuid" : str (self .partij .uuid )},
@@ -2245,49 +2251,30 @@ def test_bsn_valid_create(self):
2245
2251
self .assertEqual (response .status_code , status .HTTP_201_CREATED )
2246
2252
self .assertEqual (PartijIdentificator .objects .all ().count (), 1 )
2247
2253
2248
- def test_bsn_invalid_create_for_same_partij_unique (self ):
2254
+ def test_bsn_valid_create_sub_identificator_van (self ):
2255
+ # sub_identificator_van not allowed for partij_identificator_code_soort_object_id = 'bsn'
2256
+ partij_identificator = PartijIdentificatorFactory .create (
2257
+ partij = self .partij ,
2258
+ andere_partij_identificator = "anderePartijIdentificator" ,
2259
+ partij_identificator_code_objecttype = "natuurlijk_persoon" ,
2260
+ partij_identificator_code_soort_object_id = "bsn" ,
2261
+ partij_identificator_object_id = "123456782" ,
2262
+ partij_identificator_code_register = "brp" ,
2263
+ )
2264
+
2249
2265
data = {
2250
2266
"identificeerdePartij" : {"uuid" : str (self .partij .uuid )},
2251
- "anderePartijIdentificator" : "anderePartijIdentificator" ,
2252
2267
"partijIdentificator" : {
2253
2268
"codeObjecttype" : "natuurlijk_persoon" ,
2254
2269
"codeSoortObjectId" : "bsn" ,
2255
2270
"objectId" : "296648875" ,
2256
2271
"codeRegister" : "brp" ,
2257
2272
},
2258
2273
}
2259
-
2274
+ data [ "sub_identificator_van" ] = { "uuid" : str ( partij_identificator . uuid )}
2260
2275
response = self .client .post (self .list_url , data )
2261
2276
self .assertEqual (response .status_code , status .HTTP_201_CREATED )
2262
- self .assertEqual (PartijIdentificator .objects .all ().count (), 1 )
2263
-
2264
- with self .subTest ("failed_subtest_same_partij_1" ):
2265
- # same partij, same data_values
2266
- response = self .client .post (self .list_url , data )
2267
- self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
2268
- self .assertEqual (response .data ["code" ], "invalid" )
2269
- self .assertEqual (response .data ["title" ], "Invalid input." )
2270
- self .assertEqual (
2271
- response .data ["invalid_params" ][0 ]["reason" ],
2272
- "`PartijIdentificator` moet uniek zijn, er bestaat er al een met deze gegevenscombinatie." ,
2273
- )
2274
-
2275
- with self .subTest ("failed_subtest_same_partij_2" ):
2276
- # same partij, new data_values
2277
- data = {
2278
- "identificeerdePartij" : {"uuid" : str (self .partij .uuid )},
2279
- "anderePartijIdentificator" : "anderePartijIdentificator" ,
2280
- "partijIdentificator" : {
2281
- "codeObjecttype" : "natuurlijk_persoon" ,
2282
- "codeSoortObjectId" : "bsn" ,
2283
- "objectId" : "123456782" ,
2284
- "codeRegister" : "brp" ,
2285
- },
2286
- }
2287
-
2288
- response = self .client .post (self .list_url , data )
2289
- self .assertEqual (response .status_code , status .HTTP_201_CREATED )
2290
- self .assertEqual (PartijIdentificator .objects .all ().count (), 2 )
2277
+ self .assertEqual (PartijIdentificator .objects .all ().count (), 2 )
2291
2278
2292
2279
def test_bsn_invalid_create_global_unique (self ):
2293
2280
PartijIdentificatorFactory .create (
@@ -2332,28 +2319,6 @@ def test_bsn_invalid_create_global_unique(self):
2332
2319
"`PartijIdentificator` moet uniek zijn, er bestaat er al een met deze gegevenscombinatie." ,
2333
2320
)
2334
2321
2335
- def test_bsn_invalid_create_sub_identificator_van (self ):
2336
- # sub_identificator_van not allowed for partij_identificator_code_soort_object_id = 'bsn'
2337
- partij_identificator = PartijIdentificatorFactory .create ()
2338
- data = {
2339
- "identificeerdePartij" : {"uuid" : str (self .partij .uuid )},
2340
- "partijIdentificator" : {
2341
- "codeObjecttype" : "natuurlijk_persoon" ,
2342
- "codeSoortObjectId" : "bsn" ,
2343
- "objectId" : "296648875" ,
2344
- "codeRegister" : "brp" ,
2345
- },
2346
- }
2347
- data ["sub_identificator_van" ] = {"uuid" : str (partij_identificator .uuid )}
2348
- response = self .client .post (self .list_url , data )
2349
- self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
2350
- self .assertEqual (response .data ["code" ], "invalid" )
2351
- self .assertEqual (response .data ["title" ], "Invalid input." )
2352
- self .assertEqual (
2353
- response .data ["invalid_params" ][0 ]["reason" ],
2354
- "Alleen een identifier met code_soort_object_id kan een `sub_identificator_van' hebben." ,
2355
- )
2356
-
2357
2322
def test_bsn_valid_partial_update_unique (self ):
2358
2323
partij_identificator = PartijIdentificatorFactory .create (
2359
2324
partij = self .partij ,
@@ -2571,54 +2536,6 @@ def test_vestigingsnummer_invalid_create_invalid_sub_identificator_van(self):
2571
2536
"Het is alleen mogelijk om sub_identifier_vans te selecteren die CodeSoortObjectId = `kvk_nummer` hebben." ,
2572
2537
)
2573
2538
2574
- def test_vestigingsnummer_valid_create (self ):
2575
- sub_identificator_van = PartijIdentificatorFactory .create (
2576
- partij = self .partij ,
2577
- partij_identificator_code_objecttype = "niet_natuurlijk_persoon" ,
2578
- partij_identificator_code_soort_object_id = "kvk_nummer" ,
2579
- partij_identificator_object_id = "12345678" ,
2580
- partij_identificator_code_register = "hr" ,
2581
- )
2582
-
2583
- data = {
2584
- "identificeerdePartij" : {"uuid" : str (self .partij .uuid )},
2585
- "sub_identificator_van" : {"uuid" : str (sub_identificator_van .uuid )},
2586
- "partijIdentificator" : {
2587
- "codeObjecttype" : "vestiging" ,
2588
- "codeSoortObjectId" : "vestigingsnummer" ,
2589
- "objectId" : "296648875154" ,
2590
- "codeRegister" : "hr" ,
2591
- },
2592
- }
2593
-
2594
- response = self .client .post (self .list_url , data )
2595
- self .assertEqual (response .status_code , status .HTTP_201_CREATED )
2596
- partij_identificatoren = PartijIdentificator .objects .all ()
2597
- self .assertEqual (partij_identificatoren .count (), 2 )
2598
-
2599
- with self .subTest ("subtest_global_1" ):
2600
- # create new with objectId changed
2601
- data ["partijIdentificator" ]["objectId" ] = "123412341234"
2602
- response = self .client .post (self .list_url , data )
2603
- self .assertEqual (response .status_code , status .HTTP_201_CREATED )
2604
- partij_identificatoren = PartijIdentificator .objects .all ()
2605
- self .assertEqual (partij_identificatoren .count (), 3 )
2606
-
2607
- with self .subTest ("subtest_global_2" ):
2608
- # create new with sub_identificator_van changed
2609
- sub_identificator_van = PartijIdentificatorFactory .create (
2610
- partij = self .partij ,
2611
- partij_identificator_code_objecttype = "niet_natuurlijk_persoon" ,
2612
- partij_identificator_code_soort_object_id = "kvk_nummer" ,
2613
- partij_identificator_object_id = "87654321" ,
2614
- partij_identificator_code_register = "hr" ,
2615
- )
2616
- data ["sub_identificator_van" ] = {"uuid" : str (sub_identificator_van .uuid )}
2617
- response = self .client .post (self .list_url , data )
2618
- self .assertEqual (response .status_code , status .HTTP_201_CREATED )
2619
- partij_identificatoren = PartijIdentificator .objects .all ()
2620
- self .assertEqual (partij_identificatoren .count (), 5 )
2621
-
2622
2539
def test_vestigingsnummer_invalid_create (self ):
2623
2540
sub_identificator_van = PartijIdentificatorFactory .create (
2624
2541
partij = self .partij ,
@@ -2733,6 +2650,43 @@ def test_vestigingsnummer_invalid_update_set_sub_identificator_van_null(self):
2733
2650
in response .data ["invalid_params" ][0 ]["reason" ]
2734
2651
)
2735
2652
2653
+ def test_invalid_vestigingsnummer_and_kvk_nummer_combination_unique (self ):
2654
+ sub_identificator_van = PartijIdentificatorFactory .create (
2655
+ partij = self .partij ,
2656
+ partij_identificator_code_objecttype = "niet_natuurlijk_persoon" ,
2657
+ partij_identificator_code_soort_object_id = "kvk_nummer" ,
2658
+ partij_identificator_object_id = "12345678" ,
2659
+ partij_identificator_code_register = "hr" ,
2660
+ )
2661
+ PartijIdentificatorFactory .create (
2662
+ partij = self .partij ,
2663
+ sub_identificator_van = sub_identificator_van ,
2664
+ partij_identificator_code_objecttype = "vestiging" ,
2665
+ partij_identificator_code_soort_object_id = "vestigingsnummer" ,
2666
+ partij_identificator_object_id = "296648875154" ,
2667
+ partij_identificator_code_register = "hr" ,
2668
+ )
2669
+ # Same sub_identificator_van and same data_values
2670
+ data = {
2671
+ "identificeerdePartij" : {"uuid" : str (self .partij .uuid )},
2672
+ "sub_identificator_van" : {"uuid" : str (sub_identificator_van .uuid )},
2673
+ "partijIdentificator" : {
2674
+ "codeObjecttype" : "vestiging" ,
2675
+ "codeSoortObjectId" : "vestigingsnummer" ,
2676
+ "objectId" : "296648875154" ,
2677
+ "codeRegister" : "hr" ,
2678
+ },
2679
+ }
2680
+
2681
+ response = self .client .post (self .list_url , data )
2682
+ self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
2683
+ self .assertEqual (response .data ["code" ], "invalid" )
2684
+ self .assertEqual (response .data ["title" ], "Invalid input." )
2685
+ self .assertEqual (
2686
+ response .data ["invalid_params" ][0 ]["reason" ],
2687
+ "`PartijIdentificator` moet uniek zijn, er bestaat er al een met deze gegevenscombinatie." ,
2688
+ )
2689
+
2736
2690
def test_vestigingsnummer_invalid_update_unique (self ):
2737
2691
sub_identificator_van_a = PartijIdentificatorFactory .create (
2738
2692
partij = self .partij ,
@@ -2756,7 +2710,7 @@ def test_vestigingsnummer_invalid_update_unique(self):
2756
2710
partij_identificator_object_id = "12345678" ,
2757
2711
partij_identificator_code_register = "hr" ,
2758
2712
)
2759
- partij_identificator_b = PartijIdentificatorFactory .create (
2713
+ PartijIdentificatorFactory .create (
2760
2714
partij = self .partij ,
2761
2715
sub_identificator_van = sub_identificator_van_b ,
2762
2716
partij_identificator_code_objecttype = "vestiging" ,
0 commit comments