@@ -138,6 +138,60 @@ def inject_root_id(root_id, d):
138
138
)
139
139
]
140
140
141
+ testdata_pointer = [
142
+ # Single item array without json numbering
143
+ (
144
+ [{
145
+ 'ROOT_ID' : '1' ,
146
+ 'testR/id' : '2' ,
147
+ 'testR/testB' : '3' ,
148
+ 'testR/testX' : '3' ,
149
+ }],
150
+ [{
151
+ 'ROOT_ID' : '1' ,
152
+ 'testR' : [{
153
+ 'id' : '2' ,
154
+ 'testB' : '3' ,
155
+ 'testX' : '3'
156
+ }]
157
+ }]
158
+ ),
159
+ # Multi item array one with varied numbering
160
+ (
161
+ [{
162
+ 'ROOT_ID' : '1' ,
163
+ 'testR/id' : '-1' ,
164
+ 'testR/testB' : '-1' ,
165
+ 'testR/testX' : '-2' ,
166
+ 'testR/0/id' : '0' ,
167
+ 'testR/0/testB' : '1' ,
168
+ 'testR/0/testX' : '1' ,
169
+ 'testR/5/id' : '5' ,
170
+ 'testR/5/testB' : '5' ,
171
+ 'testR/5/testX' : '6' ,
172
+ }],
173
+ [{
174
+ 'ROOT_ID' : '1' ,
175
+ 'testR' : [{
176
+ 'id' : '-1' ,
177
+ 'testB' : '-1' ,
178
+ 'testX' : '-2'
179
+ },
180
+ {
181
+ 'id' : '0' ,
182
+ 'testB' : '1' ,
183
+ 'testX' : '1'
184
+ },
185
+ {
186
+ 'id' : '5' ,
187
+ 'testB' : '5' ,
188
+ 'testX' : '6'
189
+ }
190
+ ]
191
+ }]
192
+ ),
193
+ ]
194
+
141
195
def create_schema (root_id ):
142
196
schema = {
143
197
'properties' : {
@@ -336,6 +390,36 @@ def create_schema(root_id):
336
390
}]
337
391
}]
338
392
),
393
+ # Multi item array, allow numbering
394
+ (
395
+ [{
396
+ 'ROOT_ID_TITLE' : 1 ,
397
+ 'Identifier' : 2 ,
398
+ 'R title:C title' : 3 ,
399
+ 'R title:Not in schema' : 4 ,
400
+ 'R title:0:C title' : 5 ,
401
+ 'R title:0:Not in schema' : 6 ,
402
+ 'R title:5:C title' : 7 ,
403
+ 'R title:5:Not in schema' : 8 ,
404
+ }],
405
+ [{
406
+ 'ROOT_ID' : 1 ,
407
+ 'id' : 2 ,
408
+ 'testR' : [{
409
+ 'testC' : '3' ,
410
+ 'Not in schema' : 4
411
+ },
412
+ {
413
+ 'testC' : '5' ,
414
+ 'Not in schema' : 6
415
+ },
416
+ {
417
+ 'testC' : '7' ,
418
+ 'Not in schema' : 8
419
+ }
420
+ ]
421
+ }]
422
+ ),
339
423
# Empty
340
424
(
341
425
[{
@@ -414,6 +498,13 @@ def test_unflatten(convert_titles, use_schema, root_id, root_id_kwargs, input_li
414
498
assert recwarn .list == []
415
499
416
500
501
+ @pytest .mark .parametrize ('convert_titles' , [True , False ])
502
+ @pytest .mark .parametrize ('root_id,root_id_kwargs' , ROOT_ID_PARAMS )
503
+ @pytest .mark .parametrize ('input_list,expected_output_list' , testdata_pointer )
504
+ def test_unflatten_pointer (convert_titles , root_id , root_id_kwargs , input_list , expected_output_list , recwarn ):
505
+ return test_unflatten (convert_titles = convert_titles , use_schema = True , root_id = root_id , root_id_kwargs = root_id_kwargs , input_list = input_list , expected_output_list = expected_output_list , recwarn = recwarn )
506
+
507
+
417
508
@pytest .mark .parametrize ('input_list,expected_output_list' , testdata_titles )
418
509
@pytest .mark .parametrize ('root_id,root_id_kwargs' , ROOT_ID_PARAMS )
419
510
def test_unflatten_titles (root_id , root_id_kwargs , input_list , expected_output_list , recwarn ):
0 commit comments