Skip to content

Commit a7bc705

Browse files
[#239] Updated factories
1 parent 21b73a9 commit a7bc705

File tree

2 files changed

+67
-119
lines changed

2 files changed

+67
-119
lines changed

src/openklant/components/klantinteracties/api/tests/test_partijen.py

+31-118
Original file line numberDiff line numberDiff line change
@@ -2148,12 +2148,9 @@ def _get_detail_url(partij: Partij) -> str:
21482148

21492149
def test_get_partij_and_partij_identificatoren(self):
21502150
partij = PartijFactory.create()
2151-
partij_identificator = PartijIdentificatorFactory.create(
2151+
partij_identificator = BsnPartijIdentificatorFactory.create(
21522152
partij=partij,
2153-
partij_identificator_code_objecttype="natuurlijk_persoon",
2154-
partij_identificator_code_soort_object_id="bsn",
21552153
partij_identificator_object_id="296648875",
2156-
partij_identificator_code_register="brp",
21572154
)
21582155
detail_url = reverse(
21592156
"klantinteracties:partij-detail", kwargs={"uuid": str(partij.uuid)}
@@ -2417,13 +2414,9 @@ def test_create_partij_identificator(self):
24172414

24182415
def test_update_partij_identificator(self):
24192416
partij, partij2 = PartijFactory.create_batch(2)
2420-
partij_identificator = PartijIdentificatorFactory.create(
2417+
partij_identificator = BsnPartijIdentificatorFactory.create(
24212418
partij=partij,
2422-
andere_partij_identificator="anderePartijIdentificator",
2423-
partij_identificator_code_objecttype="natuurlijk_persoon",
2424-
partij_identificator_code_soort_object_id="bsn",
24252419
partij_identificator_object_id="296648875",
2426-
partij_identificator_code_register="brp",
24272420
)
24282421

24292422
detail_url = reverse(
@@ -2474,13 +2467,10 @@ def test_update_partij_identificator(self):
24742467

24752468
def test_partial_update_partij_identificator(self):
24762469
partij = PartijFactory.create()
2477-
partij_identificator = PartijIdentificatorFactory.create(
2470+
partij_identificator = BsnPartijIdentificatorFactory.create(
24782471
partij=partij,
24792472
andere_partij_identificator="anderePartijIdentificator",
2480-
partij_identificator_code_objecttype="natuurlijk_persoon",
2481-
partij_identificator_code_soort_object_id="bsn",
24822473
partij_identificator_object_id="296648875",
2483-
partij_identificator_code_register="brp",
24842474
)
24852475

24862476
detail_url = reverse(
@@ -2676,13 +2666,10 @@ def test_invalid_update_partial(self):
26762666
# all partij_identificator fields required
26772667
partij = PartijFactory.create()
26782668
list_url = reverse("klantinteracties:partijidentificator-list")
2679-
partij_identificator = PartijIdentificatorFactory.create(
2669+
partij_identificator = BsnPartijIdentificatorFactory.create(
26802670
partij=partij,
26812671
andere_partij_identificator="anderePartijIdentificator",
2682-
partij_identificator_code_objecttype="natuurlijk_persoon",
2683-
partij_identificator_code_soort_object_id="bsn",
26842672
partij_identificator_object_id="123456782",
2685-
partij_identificator_code_register="brp",
26862673
)
26872674

26882675
data = {
@@ -2732,13 +2719,10 @@ def test_valid_create(self):
27322719
self.assertEqual(PartijIdentificator.objects.all().count(), 1)
27332720

27342721
def test_valid_create_with_sub_identificator_van(self):
2735-
partij_identificator = PartijIdentificatorFactory.create(
2722+
partij_identificator = KvkNummerPartijIdentificatorFactory.create(
27362723
partij=self.partij,
27372724
andere_partij_identificator="anderePartijIdentificator",
2738-
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
2739-
partij_identificator_code_soort_object_id="kvk_nummer",
27402725
partij_identificator_object_id="12345678",
2741-
partij_identificator_code_register="hr",
27422726
)
27432727
data = {
27442728
"identificeerdePartij": {"uuid": str(self.partij.uuid)},
@@ -2770,9 +2754,9 @@ def test_invalid_create_partij_required(self):
27702754
self.assertEqual(error["reason"], "Dit veld is vereist.")
27712755

27722756
def test_invalid_create_duplicate_code_soort_object_id_for_partij(self):
2773-
PartijIdentificatorFactory.create(
2757+
BsnPartijIdentificatorFactory.create(
27742758
partij=self.partij,
2775-
partij_identificator_code_soort_object_id="bsn",
2759+
partij_identificator_object_id="296648875",
27762760
)
27772761

27782762
data = {
@@ -2794,13 +2778,10 @@ def test_invalid_create_duplicate_code_soort_object_id_for_partij(self):
27942778
)
27952779

27962780
def test_valid_update_partij(self):
2797-
partij_identificator = PartijIdentificatorFactory.create(
2781+
partij_identificator = BsnPartijIdentificatorFactory.create(
27982782
partij=PartijFactory.create(),
27992783
andere_partij_identificator="anderePartijIdentificator",
2800-
partij_identificator_code_objecttype="natuurlijk_persoon",
2801-
partij_identificator_code_soort_object_id="bsn",
28022784
partij_identificator_object_id="123456782",
2803-
partij_identificator_code_register="brp",
28042785
)
28052786
data = {
28062787
"identificeerdePartij": {"uuid": str(self.partij.uuid)},
@@ -2819,22 +2800,15 @@ def test_valid_update_partij(self):
28192800

28202801
def test_invalid_update_partij(self):
28212802
new_partij = PartijFactory.create()
2822-
PartijIdentificatorFactory.create(
2803+
BsnPartijIdentificatorFactory.create(
28232804
partij=new_partij,
28242805
andere_partij_identificator="anderePartijIdentificator",
2825-
partij_identificator_code_objecttype="natuurlijk_persoon",
2826-
partij_identificator_code_soort_object_id="bsn",
28272806
partij_identificator_object_id="123456782",
2828-
partij_identificator_code_register="brp",
28292807
)
2830-
2831-
partij_identificator = PartijIdentificatorFactory.create(
2808+
partij_identificator = BsnPartijIdentificatorFactory.create(
28322809
partij=self.partij,
28332810
andere_partij_identificator="anderePartijIdentificator",
2834-
partij_identificator_code_objecttype="natuurlijk_persoon",
2835-
partij_identificator_code_soort_object_id="bsn",
28362811
partij_identificator_object_id="296648875",
2837-
partij_identificator_code_register="brp",
28382812
)
28392813
data = {
28402814
"identificeerdePartij": {"uuid": str(new_partij.uuid)},
@@ -2871,15 +2845,11 @@ def test_invalid_update_partij(self):
28712845
)
28722846

28732847
def test_valid_update_check_uniqueness_values(self):
2874-
partij_identificator = PartijIdentificatorFactory.create(
2848+
partij_identificator = BsnPartijIdentificatorFactory.create(
28752849
partij=self.partij,
28762850
andere_partij_identificator="anderePartijIdentificator",
2877-
partij_identificator_code_objecttype="natuurlijk_persoon",
2878-
partij_identificator_code_soort_object_id="bsn",
28792851
partij_identificator_object_id="123456782",
2880-
partij_identificator_code_register="brp",
28812852
)
2882-
28832853
data = {
28842854
"identificeerdePartij": {"uuid": str(self.partij.uuid)},
28852855
"anderePartijIdentificator": "changed",
@@ -2911,20 +2881,13 @@ def test_valid_update_check_uniqueness_values(self):
29112881
)
29122882

29132883
def test_invalid_update_check_uniqueness_exists(self):
2914-
partij_identificator_a = PartijIdentificatorFactory.create(
2884+
partij_identificator_a = BsnPartijIdentificatorFactory.create(
29152885
partij=self.partij,
2916-
partij_identificator_code_objecttype="natuurlijk_persoon",
2917-
partij_identificator_code_soort_object_id="bsn",
29182886
partij_identificator_object_id="123456782",
2919-
partij_identificator_code_register="brp",
29202887
)
2921-
2922-
partij_identificator_b = PartijIdentificatorFactory.create(
2888+
partij_identificator_b = BsnPartijIdentificatorFactory.create(
29232889
partij=PartijFactory.create(),
2924-
partij_identificator_code_objecttype="natuurlijk_persoon",
2925-
partij_identificator_code_soort_object_id="bsn",
29262890
partij_identificator_object_id="296648875",
2927-
partij_identificator_code_register="brp",
29282891
)
29292892
# update partij_identificator_a with partij_identificator_b data
29302893
detail_url = reverse(
@@ -2953,21 +2916,15 @@ def test_invalid_update_check_uniqueness_exists(self):
29532916
)
29542917

29552918
def test_valid_check_uniqueness_sub_identificator_van(self):
2956-
PartijIdentificatorFactory.create(
2919+
BsnPartijIdentificatorFactory.create(
29572920
partij=self.partij,
2958-
partij_identificator_code_objecttype="natuurlijk_persoon",
2959-
partij_identificator_code_soort_object_id="bsn",
29602921
partij_identificator_object_id="296648875",
2961-
partij_identificator_code_register="brp",
29622922
)
29632923
# Same values, but sub_identifier_van is set
29642924
partij = PartijFactory.create()
2965-
sub_identificator_van = PartijIdentificatorFactory.create(
2925+
sub_identificator_van = KvkNummerPartijIdentificatorFactory.create(
29662926
partij=partij,
2967-
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
2968-
partij_identificator_code_soort_object_id="kvk_nummer",
29692927
partij_identificator_object_id="12345678",
2970-
partij_identificator_code_register="hr",
29712928
)
29722929
self.assertEqual(PartijIdentificator.objects.all().count(), 2)
29732930
data = {
@@ -2985,20 +2942,14 @@ def test_valid_check_uniqueness_sub_identificator_van(self):
29852942
self.assertEqual(PartijIdentificator.objects.all().count(), 3)
29862943

29872944
def test_invalid_check_uniqueness_sub_identificator_van(self):
2988-
sub_identificator_van = PartijIdentificatorFactory.create(
2945+
sub_identificator_van = KvkNummerPartijIdentificatorFactory.create(
29892946
partij=self.partij,
2990-
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
2991-
partij_identificator_code_soort_object_id="kvk_nummer",
29922947
partij_identificator_object_id="12345678",
2993-
partij_identificator_code_register="hr",
29942948
)
2995-
PartijIdentificatorFactory.create(
2949+
BsnPartijIdentificatorFactory.create(
29962950
partij=self.partij,
29972951
sub_identificator_van=sub_identificator_van,
2998-
partij_identificator_code_objecttype="natuurlijk_persoon",
2999-
partij_identificator_code_soort_object_id="bsn",
30002952
partij_identificator_object_id="296648875",
3001-
partij_identificator_code_register="brp",
30022953
)
30032954
self.assertEqual(PartijIdentificator.objects.all().count(), 2)
30042955
# Same values and same sub_identificator_van
@@ -3023,12 +2974,9 @@ def test_invalid_check_uniqueness_sub_identificator_van(self):
30232974
self.assertEqual(PartijIdentificator.objects.all().count(), 2)
30242975

30252976
def test_vestigingsnummer_valid_create(self):
3026-
sub_identificator_van = PartijIdentificatorFactory.create(
2977+
sub_identificator_van = KvkNummerPartijIdentificatorFactory.create(
30272978
partij=self.partij,
3028-
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
3029-
partij_identificator_code_soort_object_id="kvk_nummer",
30302979
partij_identificator_object_id="12345678",
3031-
partij_identificator_code_register="hr",
30322980
)
30332981

30342982
data = {
@@ -3072,12 +3020,9 @@ def test_vestigingsnummer_invalid_create_without_sub_identificator_van(self):
30723020
)
30733021

30743022
def test_vestigingsnummer_invalid_create_without_partij(self):
3075-
sub_identificator_van = PartijIdentificatorFactory.create(
3023+
sub_identificator_van = KvkNummerPartijIdentificatorFactory.create(
30763024
partij=self.partij,
3077-
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
3078-
partij_identificator_code_soort_object_id="kvk_nummer",
30793025
partij_identificator_object_id="12345678",
3080-
partij_identificator_code_register="hr",
30813026
)
30823027

30833028
data = {
@@ -3098,12 +3043,9 @@ def test_vestigingsnummer_invalid_create_without_partij(self):
30983043

30993044
def test_vestigingsnummer_valid_create_external_partij(self):
31003045
partij = PartijFactory.create()
3101-
sub_identificator_van = PartijIdentificatorFactory.create(
3046+
sub_identificator_van = KvkNummerPartijIdentificatorFactory.create(
31023047
partij=partij,
3103-
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
3104-
partij_identificator_code_soort_object_id="kvk_nummer",
31053048
partij_identificator_object_id="12345678",
3106-
partij_identificator_code_register="hr",
31073049
)
31083050

31093051
# sub_identificator_van partij is different from vestigingsnummer partij
@@ -3122,13 +3064,11 @@ def test_vestigingsnummer_valid_create_external_partij(self):
31223064
self.assertEqual(PartijIdentificator.objects.all().count(), 2)
31233065

31243066
def test_vestigingsnummer_invalid_create_invalid_sub_identificator_van(self):
3125-
sub_identificator_van = PartijIdentificatorFactory.create(
3067+
sub_identificator_van = BsnPartijIdentificatorFactory.create(
31263068
partij=self.partij,
3127-
partij_identificator_code_objecttype="natuurlijk_persoon",
3128-
partij_identificator_code_soort_object_id="bsn",
31293069
partij_identificator_object_id="296648875",
3130-
partij_identificator_code_register="brp",
31313070
)
3071+
31323072
data = {
31333073
"identificeerdePartij": {"uuid": str(self.partij.uuid)},
31343074
"sub_identificator_van": {"uuid": str(sub_identificator_van.uuid)},
@@ -3150,20 +3090,14 @@ def test_vestigingsnummer_invalid_create_invalid_sub_identificator_van(self):
31503090
)
31513091

31523092
def test_vestigingsnummer_valid_update(self):
3153-
sub_identificator_van = PartijIdentificatorFactory.create(
3093+
sub_identificator_van = KvkNummerPartijIdentificatorFactory.create(
31543094
partij=self.partij,
3155-
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
3156-
partij_identificator_code_soort_object_id="kvk_nummer",
31573095
partij_identificator_object_id="12345678",
3158-
partij_identificator_code_register="hr",
31593096
)
3160-
partij_identificator = PartijIdentificatorFactory.create(
3097+
partij_identificator = VestigingsnummerPartijIdentificatorFactory.create(
31613098
partij=self.partij,
31623099
sub_identificator_van=sub_identificator_van,
3163-
partij_identificator_code_objecttype="vestiging",
3164-
partij_identificator_code_soort_object_id="vestigingsnummer",
31653100
partij_identificator_object_id="111122223333",
3166-
partij_identificator_code_register="hr",
31673101
)
31683102

31693103
self.assertEqual(PartijIdentificator.objects.count(), 2)
@@ -3192,20 +3126,14 @@ def test_vestigingsnummer_valid_update(self):
31923126
)
31933127

31943128
def test_vestigingsnummer_invalid_update_set_sub_identificator_van_null(self):
3195-
sub_identificator_van = PartijIdentificatorFactory.create(
3129+
sub_identificator_van = KvkNummerPartijIdentificatorFactory.create(
31963130
partij=self.partij,
3197-
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
3198-
partij_identificator_code_soort_object_id="kvk_nummer",
31993131
partij_identificator_object_id="12345678",
3200-
partij_identificator_code_register="hr",
32013132
)
3202-
partij_identificator = PartijIdentificatorFactory.create(
3133+
partij_identificator = VestigingsnummerPartijIdentificatorFactory.create(
32033134
partij=self.partij,
32043135
sub_identificator_van=sub_identificator_van,
3205-
partij_identificator_code_objecttype="vestiging",
3206-
partij_identificator_code_soort_object_id="vestigingsnummer",
32073136
partij_identificator_object_id="111122223333",
3208-
partij_identificator_code_register="hr",
32093137
)
32103138

32113139
self.assertEqual(PartijIdentificator.objects.count(), 2)
@@ -3231,20 +3159,14 @@ def test_vestigingsnummer_invalid_update_set_sub_identificator_van_null(self):
32313159
)
32323160

32333161
def test_invalid_vestigingsnummer_and_kvk_nummer_combination_unique(self):
3234-
sub_identificator_van = PartijIdentificatorFactory.create(
3162+
sub_identificator_van = KvkNummerPartijIdentificatorFactory.create(
32353163
partij=self.partij,
3236-
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
3237-
partij_identificator_code_soort_object_id="kvk_nummer",
32383164
partij_identificator_object_id="12345678",
3239-
partij_identificator_code_register="hr",
32403165
)
3241-
PartijIdentificatorFactory.create(
3166+
VestigingsnummerPartijIdentificatorFactory.create(
32423167
partij=self.partij,
32433168
sub_identificator_van=sub_identificator_van,
3244-
partij_identificator_code_objecttype="vestiging",
3245-
partij_identificator_code_soort_object_id="vestigingsnummer",
32463169
partij_identificator_object_id="296648875154",
3247-
partij_identificator_code_register="hr",
32483170
)
32493171
# Same sub_identificator_van and same data_values
32503172
data = {
@@ -3273,12 +3195,9 @@ def test_invalid_vestigingsnummer_and_kvk_nummer_combination_unique(self):
32733195
)
32743196

32753197
def test_valid_protect_delete(self):
3276-
partij_identificator = PartijIdentificatorFactory.create(
3198+
partij_identificator = KvkNummerPartijIdentificatorFactory.create(
32773199
partij=self.partij,
3278-
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
3279-
partij_identificator_code_soort_object_id="kvk_nummer",
32803200
partij_identificator_object_id="12345678",
3281-
partij_identificator_code_register="hr",
32823201
)
32833202
detail_url = reverse(
32843203
"klantinteracties:partijidentificator-detail",
@@ -3290,20 +3209,14 @@ def test_valid_protect_delete(self):
32903209
self.assertEqual(PartijIdentificator.objects.all().count(), 0)
32913210

32923211
def test_invalid_protect_delete(self):
3293-
sub_identificator_van = PartijIdentificatorFactory.create(
3212+
sub_identificator_van = KvkNummerPartijIdentificatorFactory.create(
32943213
partij=self.partij,
3295-
partij_identificator_code_objecttype="niet_natuurlijk_persoon",
3296-
partij_identificator_code_soort_object_id="kvk_nummer",
32973214
partij_identificator_object_id="12345678",
3298-
partij_identificator_code_register="hr",
32993215
)
3300-
PartijIdentificatorFactory.create(
3216+
VestigingsnummerPartijIdentificatorFactory.create(
33013217
partij=self.partij,
33023218
sub_identificator_van=sub_identificator_van,
3303-
partij_identificator_code_objecttype="vestiging",
3304-
partij_identificator_code_soort_object_id="vestigingsnummer",
33053219
partij_identificator_object_id="296648875154",
3306-
partij_identificator_code_register="hr",
33073220
)
33083221
detail_url = reverse(
33093222
"klantinteracties:partijidentificator-detail",

0 commit comments

Comments
 (0)