@@ -35,6 +35,11 @@ def inject_root_id(root_id, d):
35
35
testdata = [
36
36
# Flat
37
37
(
38
+ [{
39
+ 'ROOT_ID' : 1 ,
40
+ 'Identifier' : 2 ,
41
+ 'testA' : 3
42
+ }],
38
43
[{
39
44
'ROOT_ID' : 1 ,
40
45
'id' : 2 ,
@@ -44,46 +49,90 @@ def inject_root_id(root_id, d):
44
49
),
45
50
# Nested
46
51
(
52
+ [{
53
+ 'ROOT_ID' : 1 ,
54
+ 'Identifier' : 2 ,
55
+ 'testA/testB' : 3 ,
56
+ 'testA/testC' : 4 ,
57
+ }],
47
58
[{
48
59
'ROOT_ID' : 1 ,
49
60
'id' : 2 ,
50
61
'testA/testB' : 3 ,
51
62
'testA/testC' : 4 ,
52
63
}],
53
- [{'ROOT_ID' : 1 , 'id' : 2 , 'testA' : {'testB' : 3 , 'testC' : 4 }}]
64
+ [{
65
+ 'ROOT_ID' : 1 ,
66
+ 'id' : 2 ,
67
+ 'testA' : {'testB' : 3 , 'testC' : 4 }
68
+ }]
54
69
),
55
70
# Unicode
56
71
(
72
+ [{
73
+ 'ROOT_ID' : UNICODE_TEST_STRING ,
74
+ 'A title' : UNICODE_TEST_STRING
75
+ }],
57
76
[{
58
77
'ROOT_ID' : UNICODE_TEST_STRING ,
59
78
'testA' : UNICODE_TEST_STRING
60
79
}],
61
- [{'ROOT_ID' : UNICODE_TEST_STRING , 'testA' : UNICODE_TEST_STRING }]
80
+ [{
81
+ 'ROOT_ID' : UNICODE_TEST_STRING ,
82
+ 'testA' : UNICODE_TEST_STRING
83
+ }]
62
84
),
63
85
# Rollup
64
86
(
87
+ [{
88
+ 'ROOT_ID' : 1 ,
89
+ 'Identifier' : 2 ,
90
+ 'testA[]/id' : 3 ,
91
+ 'testA[]/testB' : 4
92
+ }],
65
93
[{
66
94
'ROOT_ID' : 1 ,
67
95
'id' : 2 ,
68
96
'testA[]/id' : 3 ,
69
97
'testA[]/testB' : 4
70
98
}],
71
- [{'ROOT_ID' : 1 , 'id' : 2 , 'testA' : [{'id' : 3 , 'testB' : 4 }]}]
99
+ [{
100
+ 'ROOT_ID' : 1 , 'id' : 2 , 'testA' : [{
101
+ 'id' : 3 , 'testB' : 4
102
+ }]
103
+ }]
72
104
),
73
105
# Rollup without an ID
74
106
(
107
+ [{
108
+ 'ROOT_ID' : '1' ,
109
+ 'Identifier' : '2' ,
110
+ 'testA[]/testB' : '3' ,
111
+ }],
75
112
[{
76
113
'ROOT_ID' : '1' ,
77
114
'testA[]/id' : '2' ,
78
115
'testA[]/testB' : '3' ,
79
116
}],
80
117
[{
81
118
'ROOT_ID' : '1' ,
82
- 'testA' : [{'id' : '2' , 'testB' : '3' }]
119
+ 'testA' : [{
120
+ 'id' : '2' ,
121
+ 'testB' : '3'
122
+ }]
83
123
}]
84
124
),
85
125
# Empty
86
126
(
127
+ [{
128
+ 'ROOT_ID' : '' ,
129
+ 'Identifier' : '' ,
130
+ 'testA:number' : '' ,
131
+ 'testB:boolean' : '' ,
132
+ 'testC:array' : '' ,
133
+ 'testD:string' : '' ,
134
+ 'testE' : '' ,
135
+ }],
87
136
[{
88
137
'ROOT_ID' : '' ,
89
138
'id:integer' : '' ,
@@ -97,6 +146,15 @@ def inject_root_id(root_id, d):
97
146
),
98
147
# Empty except for root id
99
148
(
149
+ [{
150
+ 'ROOT_ID' : 1 ,
151
+ 'Identifier' : '' ,
152
+ 'testA:number' : '' ,
153
+ 'testB:boolean' : '' ,
154
+ 'testC:array' : '' ,
155
+ 'testD:string' : '' ,
156
+ 'testE' : '' ,
157
+ }],
100
158
[{
101
159
'ROOT_ID' : 1 ,
102
160
'id:integer' : '' ,
@@ -106,21 +164,31 @@ def inject_root_id(root_id, d):
106
164
'testD:string' : '' ,
107
165
'testE' : '' ,
108
166
}],
109
- [{'ROOT_ID' : 1 }]
167
+ [{
168
+ 'ROOT_ID' : 1
169
+ }]
110
170
)
111
171
]
112
172
113
173
# Convert titles modes: with appropirate schema, without, off
114
- @pytest .mark .parametrize ('convert_titles,use_schema' , [(False , False ), (True , False ), (True , True )])
174
+ @pytest .mark .parametrize ('convert_titles,use_schema,use_input_titles' , [
175
+ (False , False , False ), # Test without titles support at all
176
+ (True , False , False ), # Test that non-titles convert properly with convert_titles on
177
+ (True , True , False ), # Test that non-titles convert properly with
178
+ # convert_titles on, and an appropriate schema
179
+ pytest .mark .xfail ((True , True , True )), # Test that actual titles convert
180
+ ])
115
181
@pytest .mark .parametrize ('root_id,root_id_kwargs' ,
116
182
[
117
183
('ocid' , {}), # If not root_id kwarg is passed, then a root_id of ocid is assumed
118
184
('ocid' , {'root_id' : 'ocid' }),
119
185
('custom' , {'root_id' : 'custom' }),
120
186
('' , {'root_id' : '' })
121
187
])
122
- @pytest .mark .parametrize ('input_list,expected_output_list' , testdata )
123
- def test_unflatten (convert_titles , use_schema , root_id , root_id_kwargs , input_list , expected_output_list , recwarn ):
188
+ @pytest .mark .parametrize ('input_list_titles,input_list,,expected_output_list' , testdata )
189
+ def test_unflatten (convert_titles , use_schema , use_input_titles , root_id , root_id_kwargs , input_list , input_list_titles , expected_output_list , recwarn ):
190
+ if use_input_titles :
191
+ input_list = input_list_titles
124
192
extra_kwargs = {'convert_titles' : convert_titles }
125
193
extra_kwargs .update (root_id_kwargs )
126
194
spreadsheet_input = ListInput (
0 commit comments