@@ -41,8 +41,8 @@ def inject_root_id(root_id, d):
41
41
# ROOT_ID will be replace by the appropirate root_id name in the test (e.g. ocid)
42
42
43
43
testdata = [
44
- # Basic flat
45
44
(
45
+ 'Basic flat' ,
46
46
[{
47
47
'ROOT_ID' : '1' ,
48
48
'id' : 2 ,
@@ -54,8 +54,8 @@ def inject_root_id(root_id, d):
54
54
'testA' : 3
55
55
}]
56
56
),
57
- # Nested
58
57
(
58
+ 'Nested' ,
59
59
[{
60
60
'ROOT_ID' : '1' ,
61
61
'id' : 2 ,
@@ -68,8 +68,8 @@ def inject_root_id(root_id, d):
68
68
'testO' : {'testB' : 3 , 'testC' : 4 }
69
69
}]
70
70
),
71
- # Unicode
72
71
(
72
+ 'Unicode' ,
73
73
[{
74
74
'ROOT_ID' : UNICODE_TEST_STRING ,
75
75
'testU' : UNICODE_TEST_STRING
@@ -79,8 +79,8 @@ def inject_root_id(root_id, d):
79
79
'testU' : UNICODE_TEST_STRING
80
80
}]
81
81
),
82
- # Single item array
83
82
(
83
+ 'Single item array' ,
84
84
[{
85
85
'ROOT_ID' : '1' ,
86
86
'id' : 2 ,
@@ -93,8 +93,8 @@ def inject_root_id(root_id, d):
93
93
}]
94
94
}]
95
95
),
96
- # Single item array withou parent ID
97
96
(
97
+ 'Single item array without parent ID' ,
98
98
[{
99
99
'ROOT_ID' : '1' ,
100
100
'testL/0/id' : '2' ,
@@ -108,8 +108,8 @@ def inject_root_id(root_id, d):
108
108
}]
109
109
}]
110
110
),
111
- # Empty
112
111
(
112
+ 'Empty' ,
113
113
[{
114
114
'ROOT_ID' : '' ,
115
115
'id' : '' ,
@@ -121,8 +121,8 @@ def inject_root_id(root_id, d):
121
121
}],
122
122
[]
123
123
),
124
- # Empty except for root id
125
124
(
125
+ 'Empty except for root id' ,
126
126
[{
127
127
'ROOT_ID' : 1 ,
128
128
'id' : '' ,
@@ -139,8 +139,8 @@ def inject_root_id(root_id, d):
139
139
]
140
140
141
141
testdata_pointer = [
142
- # Single item array without json numbering
143
142
(
143
+ 'Single item array without json numbering' ,
144
144
[{
145
145
'ROOT_ID' : '1' ,
146
146
'testR/id' : '2' ,
@@ -156,8 +156,8 @@ def inject_root_id(root_id, d):
156
156
}]
157
157
}]
158
158
),
159
- # Multi item array one with varied numbering
160
159
(
160
+ 'Multi item array one with varied numbering ' ,
161
161
[{
162
162
'ROOT_ID' : '1' ,
163
163
'testR/id' : '-1' ,
@@ -265,8 +265,8 @@ def create_schema(root_id):
265
265
return schema
266
266
267
267
testdata_titles = [
268
- # Basic flat
269
268
(
269
+ 'Basic flat' ,
270
270
[{
271
271
'ROOT_ID_TITLE' : 1 ,
272
272
'Identifier' : 2 ,
@@ -278,8 +278,8 @@ def create_schema(root_id):
278
278
'testA' : 3
279
279
}]
280
280
),
281
- # Nested
282
281
(
282
+ 'Nested' ,
283
283
[{
284
284
'ROOT_ID_TITLE' : 1 ,
285
285
'Identifier' : 2 ,
@@ -292,8 +292,8 @@ def create_schema(root_id):
292
292
'testB' : {'testC' : 3 , 'testD' : 4 }
293
293
}]
294
294
),
295
- # Nested titles should be converted individually
296
295
(
296
+ 'Nested titles should be converted individually' ,
297
297
[{
298
298
'ROOT_ID_TITLE' : 1 ,
299
299
'Identifier' : 2 ,
@@ -306,8 +306,8 @@ def create_schema(root_id):
306
306
'testB' : {'testC' : 3 , 'Not in schema' : 4 }
307
307
}]
308
308
),
309
- # Should be space and case invariant
310
309
(
310
+ 'Should be space and case invariant' ,
311
311
[{
312
312
'ROOT_ID_TITLE' : 1 ,
313
313
'Identifier' : 2 ,
@@ -320,8 +320,8 @@ def create_schema(root_id):
320
320
'testB' : {'testC' : 3 , 'Not in schema' : 4 }
321
321
}]
322
322
),
323
- # Unicode
324
323
(
324
+ 'Unicode' ,
325
325
[{
326
326
'ROOT_ID_TITLE' : UNICODE_TEST_STRING ,
327
327
UNICODE_TEST_STRING : UNICODE_TEST_STRING
@@ -331,8 +331,8 @@ def create_schema(root_id):
331
331
'testU' : UNICODE_TEST_STRING
332
332
}]
333
333
),
334
- # Single item array
335
334
(
335
+ 'Single item array' ,
336
336
[{
337
337
'ROOT_ID_TITLE' : 1 ,
338
338
'Identifier' : 2 ,
@@ -347,8 +347,8 @@ def create_schema(root_id):
347
347
}]
348
348
}]
349
349
),
350
- # Single item array without parent ID
351
350
(
351
+ 'Single item array without parent ID' ,
352
352
[{
353
353
'ROOT_ID_TITLE' : '1' ,
354
354
'R title:Identifier' : '2' ,
@@ -362,9 +362,11 @@ def create_schema(root_id):
362
362
}]
363
363
}]
364
364
),
365
- # Properties of a single item array shouldn't need to be in rollUp list
366
- # for their titles to be converted
367
365
(
366
+ '''
367
+ Properties of a single item array shouldn't need to be in rollUp list
368
+ for their titles to be converted
369
+ ''' ,
368
370
[{
369
371
'ROOT_ID_TITLE' : 1 ,
370
372
'Identifier' : 2 ,
@@ -380,8 +382,8 @@ def create_schema(root_id):
380
382
}]
381
383
}]
382
384
),
383
- # Single item array, titles should be converted individually
384
385
(
386
+ 'Single item array, titles should be converted individually' ,
385
387
[{
386
388
'ROOT_ID_TITLE' : 1 ,
387
389
'Identifier' : 2 ,
@@ -397,8 +399,8 @@ def create_schema(root_id):
397
399
}]
398
400
}]
399
401
),
400
- # Multi item array, allow numbering
401
402
pytest .mark .xfail ((
403
+ 'Multi item array, allow numbering' ,
402
404
[{
403
405
'ROOT_ID_TITLE' : 1 ,
404
406
'Identifier' : 2 ,
@@ -427,8 +429,8 @@ def create_schema(root_id):
427
429
]
428
430
}]
429
431
)),
430
- # Empty
431
432
(
433
+ 'Empty' ,
432
434
[{
433
435
'ROOT_ID_TITLE' : '' ,
434
436
'Identifier' : '' ,
@@ -440,8 +442,8 @@ def create_schema(root_id):
440
442
}],
441
443
[]
442
444
),
443
- # Empty except for root id
444
445
(
446
+ 'Empty except for root id' ,
445
447
[{
446
448
'ROOT_ID_TITLE' : 1 ,
447
449
'Identifier' : '' ,
@@ -455,8 +457,8 @@ def create_schema(root_id):
455
457
'ROOT_ID' : 1
456
458
}]
457
459
),
458
- # Test arrays of strings
459
460
(
461
+ 'Test arrays of strings (1 item)' ,
460
462
[{
461
463
'ROOT_ID_TITLE' : 1 ,
462
464
'Identifier' : 2 ,
@@ -469,6 +471,7 @@ def create_schema(root_id):
469
471
}]
470
472
),
471
473
(
474
+ 'Test arrays of strings (2 items)' ,
472
475
[{
473
476
'ROOT_ID_TITLE' : 1 ,
474
477
'Identifier' : 2 ,
@@ -495,8 +498,8 @@ def create_schema(root_id):
495
498
@pytest .mark .parametrize ('convert_titles' , [True , False ])
496
499
@pytest .mark .parametrize ('use_schema' , [True , False ])
497
500
@pytest .mark .parametrize ('root_id,root_id_kwargs' , ROOT_ID_PARAMS )
498
- @pytest .mark .parametrize ('input_list,expected_output_list' , testdata )
499
- def test_unflatten (convert_titles , use_schema , root_id , root_id_kwargs , input_list , expected_output_list , recwarn ):
501
+ @pytest .mark .parametrize ('comment, input_list,expected_output_list' , testdata )
502
+ def test_unflatten (convert_titles , use_schema , root_id , root_id_kwargs , input_list , expected_output_list , recwarn , comment ):
500
503
extra_kwargs = {'convert_titles' : convert_titles }
501
504
extra_kwargs .update (root_id_kwargs )
502
505
spreadsheet_input = ListInput (
@@ -532,14 +535,14 @@ def test_unflatten(convert_titles, use_schema, root_id, root_id_kwargs, input_li
532
535
533
536
@pytest .mark .parametrize ('convert_titles' , [True , False ])
534
537
@pytest .mark .parametrize ('root_id,root_id_kwargs' , ROOT_ID_PARAMS )
535
- @pytest .mark .parametrize ('input_list,expected_output_list' , testdata_pointer )
536
- def test_unflatten_pointer (convert_titles , root_id , root_id_kwargs , input_list , expected_output_list , recwarn ):
537
- 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 )
538
+ @pytest .mark .parametrize ('comment, input_list,expected_output_list' , testdata_pointer )
539
+ def test_unflatten_pointer (convert_titles , root_id , root_id_kwargs , input_list , expected_output_list , recwarn , comment ):
540
+ 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 , comment = comment )
538
541
539
542
540
- @pytest .mark .parametrize ('input_list,expected_output_list' , testdata_titles )
543
+ @pytest .mark .parametrize ('comment, input_list,expected_output_list' , testdata_titles )
541
544
@pytest .mark .parametrize ('root_id,root_id_kwargs' , ROOT_ID_PARAMS )
542
- def test_unflatten_titles (root_id , root_id_kwargs , input_list , expected_output_list , recwarn ):
545
+ def test_unflatten_titles (root_id , root_id_kwargs , input_list , expected_output_list , recwarn , comment ):
543
546
"""
544
547
Essentially the same as test unflatten, except that convert_titles and
545
548
use_schema are always true, as both of these are needed to convert titles
@@ -549,6 +552,6 @@ def test_unflatten_titles(root_id, root_id_kwargs, input_list, expected_output_l
549
552
# Skip all tests with a root ID for now, as this is broken
550
553
# https://github.com/OpenDataServices/flatten-tool/issues/84
551
554
pytest .skip ()
552
- return test_unflatten (convert_titles = True , 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 )
555
+ return test_unflatten (convert_titles = True , 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 , comment = comment )
553
556
554
557
0 commit comments