@@ -37,9 +37,6 @@ def inject_root_id(root_id, d):
37
37
return d
38
38
39
39
40
- # TODO Actually create appropriate schema
41
- SCHEMA = {}
42
-
43
40
UNICODE_TEST_STRING = 'éαГ😼𝒞人'
44
41
# ROOT_ID will be replace by the appropirate root_id name in the test (e.g. ocid)
45
42
@@ -141,52 +138,92 @@ def inject_root_id(root_id, d):
141
138
)
142
139
]
143
140
141
+ def create_schema (root_id ):
142
+ schema = {
143
+ 'properties' : {
144
+ 'id' : {
145
+ 'title' : 'Identifier' ,
146
+ 'type' : 'integer' ,
147
+ },
148
+ 'testA' : {
149
+ 'title' : 'A title' ,
150
+ 'type' : 'integer' ,
151
+ },
152
+ 'testB' : {
153
+ 'title' : 'B title' ,
154
+ 'type' : 'object' ,
155
+ 'properties' : {
156
+ 'testC' : {
157
+ 'title' : 'C title' ,
158
+ 'type' : 'integer' ,
159
+ },
160
+ 'testD' : {
161
+ 'title' : 'D title' ,
162
+ 'type' : 'integer' ,
163
+ }
164
+ }
165
+ },
166
+ 'testU' : {
167
+ 'title' : UNICODE_TEST_STRING ,
168
+ 'type' : 'string' ,
169
+ },
170
+ }
171
+ }
172
+ if root_id :
173
+ schema .update ({
174
+ root_id : {
175
+ 'title' : ROOT_ID_TITLES [root_id ],
176
+ 'type' : 'string'
177
+ }
178
+ })
179
+ return schema
180
+
144
181
testdata_titles = [
145
182
# Basic flat
146
- pytest . mark . xfail ( (
183
+ (
147
184
[{
148
- 'ROOT_ID ' : 1 ,
185
+ 'ROOT_ID_TITLE ' : 1 ,
149
186
'Identifier' : 2 ,
150
- 'testA ' : 3
187
+ 'A title ' : 3
151
188
}],
152
189
[{
153
- 'ROOT_ID' : 1 ,
154
- 'id' : 2 ,
155
- 'testA' : 3
190
+ 'ROOT_ID' : 1 ,
191
+ 'id' : 2 ,
192
+ 'testA' : 3
156
193
}]
157
- )) ,
194
+ ),
158
195
# Nested
159
196
pytest .mark .xfail ((
160
197
[{
161
- 'ROOT_ID ' : 1 ,
198
+ 'ROOT_ID_TITLE ' : 1 ,
162
199
'id' : 2 ,
163
- 'testA/testB ' : 3 ,
164
- 'testA/testC ' : 4 ,
200
+ 'B title:C title ' : 3 ,
201
+ 'B title:C title ' : 4 ,
165
202
}],
166
203
[{
167
204
'ROOT_ID' : 1 ,
168
205
'id' : 2 ,
169
- 'testA ' : {'testB ' : 3 , 'testC ' : 4 }
206
+ 'testB ' : {'testC ' : 3 , 'testD ' : 4 }
170
207
}]
171
208
)),
172
209
# Unicode
173
210
pytest .mark .xfail ((
174
211
[{
175
- 'ROOT_ID ' : UNICODE_TEST_STRING ,
176
- 'testA ' : UNICODE_TEST_STRING
212
+ 'ROOT_ID_TITLE ' : UNICODE_TEST_STRING ,
213
+ 'UNICODE_TEST_STRING ' : UNICODE_TEST_STRING
177
214
}],
178
215
[{
179
216
'ROOT_ID' : UNICODE_TEST_STRING ,
180
- 'testA ' : UNICODE_TEST_STRING
217
+ 'testU ' : UNICODE_TEST_STRING
181
218
}]
182
219
)),
183
220
# Rollup
184
221
pytest .mark .xfail ((
185
222
[{
186
- 'ROOT_ID ' : 1 ,
223
+ 'ROOT_ID_TITLE ' : 1 ,
187
224
'id' : 2 ,
188
- 'testA[]/id ' : 3 ,
189
- 'testA[]/testB ' : 4
225
+ 'A title:Identifier ' : 3 ,
226
+ 'A title:B title ' : 4
190
227
}],
191
228
[{
192
229
'ROOT_ID' : 1 , 'id' : 2 , 'testA' : [{
@@ -197,9 +234,9 @@ def inject_root_id(root_id, d):
197
234
# Rollup without an ID
198
235
pytest .mark .xfail ((
199
236
[{
200
- 'ROOT_ID ' : '1' ,
201
- 'testA[]/id ' : '2' ,
202
- 'testA[]/testB' : '3' ,
237
+ 'ROOT_ID_TITLE ' : '1' ,
238
+ 'A title:Identifier ' : 2 ,
239
+ 'A title:B title' : 3
203
240
}],
204
241
[{
205
242
'ROOT_ID' : '1' ,
@@ -223,7 +260,7 @@ def inject_root_id(root_id, d):
223
260
[]
224
261
),
225
262
# Empty except for root id
226
- pytest . mark . xfail ( (
263
+ (
227
264
[{
228
265
'ROOT_ID_TITLE' : 1 ,
229
266
'Identifier' : '' ,
@@ -236,7 +273,7 @@ def inject_root_id(root_id, d):
236
273
[{
237
274
'ROOT_ID' : 1
238
275
}]
239
- ))
276
+ )
240
277
]
241
278
242
279
ROOT_ID_PARAMS = [
@@ -267,7 +304,7 @@ def test_unflatten(convert_titles, use_schema, root_id, root_id_kwargs, input_li
267
304
spreadsheet_input .read_sheets ()
268
305
if convert_titles :
269
306
parser = SchemaParser (
270
- root_schema_dict = SCHEMA if use_schema else {},
307
+ root_schema_dict = create_schema ( root_id ) if use_schema else {},
271
308
use_titles = True
272
309
)
273
310
parser .parse ()
@@ -292,6 +329,10 @@ def test_unflatten_titles(root_id, root_id_kwargs, input_list, expected_output_l
292
329
use_schema are always true, as both of these are needed to convert titles
293
330
properly. (and runs with different test data).
294
331
"""
332
+ if root_id != '' :
333
+ # Skip all tests with a root ID for now, as this is broken
334
+ # https://github.com/OpenDataServices/flatten-tool/issues/84
335
+ pytest .skip ()
295
336
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 )
296
337
297
338
0 commit comments