5
5
from django .core .files .storage .memory import InMemoryStorage
6
6
from django .test import TestCase
7
7
8
- from open_inwoner .openzaak .import_export import (
9
- CatalogusConfigExport ,
10
- CatalogusConfigImport ,
11
- )
8
+ from open_inwoner .openzaak .import_export import CatalogusConfigImport , ZGWConfigExport
12
9
from open_inwoner .openzaak .models import (
13
10
CatalogusConfig ,
14
11
ZaakTypeConfig ,
@@ -94,17 +91,17 @@ def test_export_only_accepts_queryset(self):
94
91
for arg in (list (), set (), tuple (), None , "" , CatalogusConfig .objects .first ()):
95
92
with self .subTest (f"Default factory should not accept { arg } " ):
96
93
with self .assertRaises (TypeError ):
97
- CatalogusConfigExport .from_catalogus_configs (arg )
94
+ ZGWConfigExport .from_catalogus_configs (arg )
98
95
99
96
def test_export_only_accepts_queryset_of_correct_type (self ):
100
97
with self .assertRaises (ValueError ):
101
- CatalogusConfigExport .from_catalogus_configs (ZaakTypeConfig .objects .all ())
98
+ ZGWConfigExport .from_catalogus_configs (ZaakTypeConfig .objects .all ())
102
99
103
100
def test_equality_operator (self ):
104
- export_a = CatalogusConfigExport .from_catalogus_configs (
101
+ export_a = ZGWConfigExport .from_catalogus_configs (
105
102
CatalogusConfig .objects .filter (pk = self .mocks [0 ].catalogus .pk )
106
103
)
107
- export_b = CatalogusConfigExport .from_catalogus_configs (
104
+ export_b = ZGWConfigExport .from_catalogus_configs (
108
105
CatalogusConfig .objects .filter (pk = self .mocks [1 ].catalogus .pk )
109
106
)
110
107
@@ -113,14 +110,14 @@ def test_equality_operator(self):
113
110
self .assertFalse (export_a == export_b )
114
111
115
112
def test_only_models_related_to_exported_catalogus_config_are_included (self ):
116
- export = CatalogusConfigExport .from_catalogus_configs (
113
+ export = ZGWConfigExport .from_catalogus_configs (
117
114
CatalogusConfig .objects .filter (pk = self .mocks [0 ].catalogus .pk )
118
115
)
119
116
120
117
for export_field , mock_field in zip (
121
118
(
122
119
"catalogus_configs" ,
123
- "zaak_type_configs " ,
120
+ "zaaktype_configs " ,
124
121
"zaak_status_type_configs" ,
125
122
"zaak_resultaat_type_configs" ,
126
123
"zaak_informatie_object_type_configs" ,
@@ -148,6 +145,79 @@ def test_only_models_related_to_exported_catalogus_config_are_included(self):
148
145
)
149
146
150
147
148
+ class ZaakTypeConfigExportTest (TestCase ):
149
+ def setUp (self ):
150
+ self .mocks = ZGWExportImportMockData (0 )
151
+
152
+ def test_export_zaaktype_configs (self ):
153
+ export = ZGWConfigExport .from_zaaktype_configs (
154
+ ZaakTypeConfig .objects .filter (pk = self .mocks .ztc .pk )
155
+ )
156
+ rows = export .as_dicts ()
157
+
158
+ expected = [
159
+ {
160
+ "model" : "openzaak.zaaktypeconfig" ,
161
+ "fields" : {
162
+ "urls" : '["https://foo.0.maykinmedia.nl"]' ,
163
+ "catalogus" : ["DM-0" , "123456789" ],
164
+ "identificatie" : "ztc-id-a-0" ,
165
+ "omschrijving" : "zaaktypeconfig" ,
166
+ "notify_status_changes" : False ,
167
+ "description" : "" ,
168
+ "external_document_upload_url" : "" ,
169
+ "document_upload_enabled" : False ,
170
+ "contact_form_enabled" : False ,
171
+ "contact_subject_code" : "" ,
172
+ "relevante_zaakperiode" : None ,
173
+ },
174
+ },
175
+ {
176
+ "model" : "openzaak.zaaktypeinformatieobjecttypeconfig" ,
177
+ "fields" : {
178
+ "zaaktype_config" : ["ztc-id-a-0" , "DM-0" , "123456789" ],
179
+ "informatieobjecttype_url" : "https://foo.0.maykinmedia.nl" ,
180
+ "omschrijving" : "informatieobject" ,
181
+ "zaaktype_uuids" : '["a1591906-3368-470a-a957-4b8634c275a1"]' ,
182
+ "document_upload_enabled" : False ,
183
+ "document_notification_enabled" : False ,
184
+ },
185
+ },
186
+ {
187
+ "model" : "openzaak.zaaktypestatustypeconfig" ,
188
+ "fields" : {
189
+ "zaaktype_config" : ["ztc-id-a-0" , "DM-0" , "123456789" ],
190
+ "statustype_url" : "https://foo.0.maykinmedia.nl" ,
191
+ "omschrijving" : "status omschrijving" ,
192
+ "statustekst" : "" ,
193
+ "zaaktype_uuids" : '["a1591906-3368-470a-a957-4b8634c275a1"]' ,
194
+ "status_indicator" : "" ,
195
+ "status_indicator_text" : "" ,
196
+ "document_upload_description" : "" ,
197
+ "description" : "status" ,
198
+ "notify_status_change" : True ,
199
+ "action_required" : False ,
200
+ "document_upload_enabled" : True ,
201
+ "call_to_action_url" : "" ,
202
+ "call_to_action_text" : "" ,
203
+ "case_link_text" : "" ,
204
+ },
205
+ },
206
+ {
207
+ "model" : "openzaak.zaaktyperesultaattypeconfig" ,
208
+ "fields" : {
209
+ "zaaktype_config" : ["ztc-id-a-0" , "DM-0" , "123456789" ],
210
+ "resultaattype_url" : "https://foo.0.maykinmedia.nl" ,
211
+ "omschrijving" : "resultaat" ,
212
+ "zaaktype_uuids" : '["a1591906-3368-470a-a957-4b8634c275a1"]' ,
213
+ "description" : "" ,
214
+ },
215
+ },
216
+ ]
217
+
218
+ self .assertEqual (rows , expected )
219
+
220
+
151
221
class TestCatalogusExport (TestCase ):
152
222
def setUp (self ):
153
223
self .mocks = [
@@ -156,7 +226,7 @@ def setUp(self):
156
226
]
157
227
158
228
def test_export_catalogus_configs (self ):
159
- export = CatalogusConfigExport .from_catalogus_configs (
229
+ export = ZGWConfigExport .from_catalogus_configs (
160
230
CatalogusConfig .objects .filter (pk = self .mocks [0 ].catalogus .pk )
161
231
)
162
232
rows = export .as_dicts ()
@@ -233,9 +303,7 @@ def test_export_catalogus_configs(self):
233
303
self .assertEqual (rows , expected )
234
304
235
305
def test_export_catalogus_configs_as_jsonl (self ):
236
- export = CatalogusConfigExport .from_catalogus_configs (
237
- CatalogusConfig .objects .all ()
238
- )
306
+ export = ZGWConfigExport .from_catalogus_configs (CatalogusConfig .objects .all ())
239
307
rows = list (export .as_jsonl_iter ())
240
308
241
309
expected = [
@@ -585,9 +653,7 @@ def setUp(self):
585
653
ZGWExportImportMockData ()
586
654
587
655
def test_exports_can_be_imported (self ):
588
- export = CatalogusConfigExport .from_catalogus_configs (
589
- CatalogusConfig .objects .all ()
590
- )
656
+ export = ZGWConfigExport .from_catalogus_configs (CatalogusConfig .objects .all ())
591
657
import_result = CatalogusConfigImport .from_jsonl_stream_or_string (
592
658
export .as_jsonl ()
593
659
)
0 commit comments