Skip to content

Commit 8e4ff34

Browse files
committed
Create some xfailing titles tests to implement
The schema nedes writing, and the tests can be improved to have more titles.
1 parent 5d4c1bc commit 8e4ff34

File tree

1 file changed

+76
-8
lines changed

1 file changed

+76
-8
lines changed

flattentool/tests/test_input_SpreadsheetInput_unflatten.py

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def inject_root_id(root_id, d):
3535
testdata = [
3636
# Flat
3737
(
38+
[{
39+
'ROOT_ID': 1,
40+
'Identifier': 2,
41+
'testA': 3
42+
}],
3843
[{
3944
'ROOT_ID': 1,
4045
'id': 2,
@@ -44,46 +49,90 @@ def inject_root_id(root_id, d):
4449
),
4550
# Nested
4651
(
52+
[{
53+
'ROOT_ID': 1,
54+
'Identifier': 2,
55+
'testA/testB': 3,
56+
'testA/testC': 4,
57+
}],
4758
[{
4859
'ROOT_ID': 1,
4960
'id': 2,
5061
'testA/testB': 3,
5162
'testA/testC': 4,
5263
}],
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+
}]
5469
),
5570
# Unicode
5671
(
72+
[{
73+
'ROOT_ID': UNICODE_TEST_STRING,
74+
'A title': UNICODE_TEST_STRING
75+
}],
5776
[{
5877
'ROOT_ID': UNICODE_TEST_STRING,
5978
'testA': UNICODE_TEST_STRING
6079
}],
61-
[{'ROOT_ID': UNICODE_TEST_STRING, 'testA': UNICODE_TEST_STRING}]
80+
[{
81+
'ROOT_ID': UNICODE_TEST_STRING,
82+
'testA': UNICODE_TEST_STRING
83+
}]
6284
),
6385
# Rollup
6486
(
87+
[{
88+
'ROOT_ID': 1,
89+
'Identifier': 2,
90+
'testA[]/id': 3,
91+
'testA[]/testB': 4
92+
}],
6593
[{
6694
'ROOT_ID': 1,
6795
'id': 2,
6896
'testA[]/id': 3,
6997
'testA[]/testB': 4
7098
}],
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+
}]
72104
),
73105
# Rollup without an ID
74106
(
107+
[{
108+
'ROOT_ID': '1',
109+
'Identifier': '2',
110+
'testA[]/testB': '3',
111+
}],
75112
[{
76113
'ROOT_ID': '1',
77114
'testA[]/id': '2',
78115
'testA[]/testB': '3',
79116
}],
80117
[{
81118
'ROOT_ID': '1',
82-
'testA': [{'id': '2', 'testB': '3'}]
119+
'testA': [{
120+
'id': '2',
121+
'testB': '3'
122+
}]
83123
}]
84124
),
85125
# Empty
86126
(
127+
[{
128+
'ROOT_ID': '',
129+
'Identifier': '',
130+
'testA:number': '',
131+
'testB:boolean': '',
132+
'testC:array': '',
133+
'testD:string': '',
134+
'testE': '',
135+
}],
87136
[{
88137
'ROOT_ID': '',
89138
'id:integer': '',
@@ -97,6 +146,15 @@ def inject_root_id(root_id, d):
97146
),
98147
# Empty except for root id
99148
(
149+
[{
150+
'ROOT_ID': 1,
151+
'Identifier': '',
152+
'testA:number': '',
153+
'testB:boolean': '',
154+
'testC:array': '',
155+
'testD:string': '',
156+
'testE': '',
157+
}],
100158
[{
101159
'ROOT_ID': 1,
102160
'id:integer': '',
@@ -106,21 +164,31 @@ def inject_root_id(root_id, d):
106164
'testD:string': '',
107165
'testE': '',
108166
}],
109-
[{'ROOT_ID': 1}]
167+
[{
168+
'ROOT_ID': 1
169+
}]
110170
)
111171
]
112172

113173
# 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+
])
115181
@pytest.mark.parametrize('root_id,root_id_kwargs',
116182
[
117183
('ocid', {}), # If not root_id kwarg is passed, then a root_id of ocid is assumed
118184
('ocid', {'root_id': 'ocid'}),
119185
('custom', {'root_id': 'custom'}),
120186
('', {'root_id': ''})
121187
])
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
124192
extra_kwargs = {'convert_titles': convert_titles}
125193
extra_kwargs.update(root_id_kwargs)
126194
spreadsheet_input = ListInput(

0 commit comments

Comments
 (0)