Skip to content

Commit 0dc9807

Browse files
committed
[#77] Complete title equivalents of current unflatten tests
(for current behaviour)
1 parent 9f911c8 commit 0dc9807

File tree

1 file changed

+45
-19
lines changed

1 file changed

+45
-19
lines changed

flattentool/tests/test_input_SpreadsheetInput_unflatten.py

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,27 @@ def create_schema(root_id):
163163
}
164164
}
165165
},
166+
'testR': {
167+
'title': 'R title',
168+
'type': 'array',
169+
'rollUp': ['id', 'testB'],
170+
'items': {
171+
'type': 'object',
172+
'properties': {
173+
'id': {
174+
'title': 'Identifier',
175+
'type': 'string',
176+
# 'type': 'integer',
177+
# integer does not work, as testB:integer is not
178+
# in the rollUp
179+
},
180+
'testB': {
181+
'title': 'B title',
182+
'type': 'string',
183+
},
184+
}
185+
}
186+
},
166187
'testU': {
167188
'title': UNICODE_TEST_STRING,
168189
'type': 'string',
@@ -193,59 +214,61 @@ def create_schema(root_id):
193214
}]
194215
),
195216
# Nested
196-
pytest.mark.xfail((
217+
(
197218
[{
198219
'ROOT_ID_TITLE': 1,
199-
'id': 2,
220+
'Identifier': 2,
200221
'B title:C title': 3,
201-
'B title:C title': 4,
222+
'B title:D title': 4,
202223
}],
203224
[{
204225
'ROOT_ID': 1,
205226
'id': 2,
206227
'testB': {'testC': 3, 'testD': 4}
207228
}]
208-
)),
229+
),
209230
# Unicode
210-
pytest.mark.xfail((
231+
(
211232
[{
212233
'ROOT_ID_TITLE': UNICODE_TEST_STRING,
213-
'UNICODE_TEST_STRING': UNICODE_TEST_STRING
234+
UNICODE_TEST_STRING: UNICODE_TEST_STRING
214235
}],
215236
[{
216237
'ROOT_ID': UNICODE_TEST_STRING,
217238
'testU': UNICODE_TEST_STRING
218239
}]
219-
)),
240+
),
220241
# Rollup
221-
pytest.mark.xfail((
242+
(
222243
[{
223244
'ROOT_ID_TITLE': 1,
224-
'id': 2,
225-
'A title:Identifier': 3,
226-
'A title:B title': 4
245+
'Identifier': 2,
246+
'R title:Identifier': 3,
247+
'R title:B title': 4
227248
}],
228249
[{
229-
'ROOT_ID': 1, 'id': 2, 'testA': [{
250+
'ROOT_ID': 1,
251+
'id': 2,
252+
'testR': [{
230253
'id': 3, 'testB': 4
231254
}]
232255
}]
233-
)),
256+
),
234257
# Rollup without an ID
235-
pytest.mark.xfail((
258+
(
236259
[{
237260
'ROOT_ID_TITLE': '1',
238-
'A title:Identifier': 2,
239-
'A title:B title': 3
261+
'R title:Identifier': '2',
262+
'R title:B title': '3'
240263
}],
241264
[{
242265
'ROOT_ID': '1',
243-
'testA': [{
266+
'testR': [{
244267
'id': '2',
245268
'testB': '3'
246269
}]
247270
}]
248-
)),
271+
),
249272
# Empty
250273
(
251274
[{
@@ -305,6 +328,9 @@ def test_unflatten(convert_titles, use_schema, root_id, root_id_kwargs, input_li
305328
if convert_titles:
306329
parser = SchemaParser(
307330
root_schema_dict=create_schema(root_id) if use_schema else {},
331+
main_sheet_name='custom_main',
332+
root_id=root_id,
333+
rollup=True,
308334
use_titles=True
309335
)
310336
parser.parse()
@@ -321,8 +347,8 @@ def test_unflatten(convert_titles, use_schema, root_id, root_id_kwargs, input_li
321347
assert recwarn.list == []
322348

323349

324-
@pytest.mark.parametrize('root_id,root_id_kwargs', ROOT_ID_PARAMS)
325350
@pytest.mark.parametrize('input_list,expected_output_list', testdata_titles)
351+
@pytest.mark.parametrize('root_id,root_id_kwargs', ROOT_ID_PARAMS)
326352
def test_unflatten_titles(root_id, root_id_kwargs, input_list, expected_output_list, recwarn):
327353
"""
328354
Essentially the same as test unflatten, except that convert_titles and

0 commit comments

Comments
 (0)