@@ -22,20 +22,40 @@ def test_basic_sub_sheet(self):
22
22
{
23
23
'ocid' : 1 ,
24
24
'id' : 2 ,
25
+ },
26
+ {
27
+ 'ocid' : 1 ,
28
+ 'id' : 3 ,
25
29
}
26
30
],
27
31
'sub' : [
28
32
{
29
33
'ocid' : 1 ,
30
34
'id' : 2 ,
31
35
'subField/0/testA' : 3 ,
36
+ },
37
+ {
38
+ 'ocid' : 1 ,
39
+ 'id' : 2 ,
40
+ 'subField/0/testA' : 4 ,
32
41
}
33
42
]
34
43
},
35
44
main_sheet_name = 'custom_main' )
36
45
spreadsheet_input .read_sheets ()
37
46
assert list (spreadsheet_input .unflatten ()) == [
38
- {'ocid' : 1 , 'id' : 2 , 'subField' : [{'testA' : 3 }]}
47
+ {
48
+ 'ocid' : 1 ,
49
+ 'id' : 2 ,
50
+ 'subField' : [
51
+ {'testA' : 3 },
52
+ {'testA' : 4 },
53
+ ]
54
+ },
55
+ {
56
+ 'ocid' : 1 ,
57
+ 'id' : 3
58
+ }
39
59
]
40
60
41
61
@pytest .mark .parametrize ('nested_id_in_subsheet' , [True , False ])
@@ -82,6 +102,10 @@ def test_basic_two_sub_sheets(self):
82
102
OrderedDict ([
83
103
('ocid' , 1 ),
84
104
('id' , 2 ),
105
+ ]),
106
+ OrderedDict ([
107
+ ('ocid' , 1 ),
108
+ ('id' , 6 ),
85
109
])
86
110
],
87
111
'sub1' : [
@@ -104,7 +128,7 @@ def test_basic_two_sub_sheets(self):
104
128
main_sheet_name = 'custom_main' )
105
129
spreadsheet_input .read_sheets ()
106
130
unflattened = list (spreadsheet_input .unflatten ())
107
- assert len (unflattened ) == 1
131
+ assert len (unflattened ) == 2
108
132
assert set (unflattened [0 ]) == set (['ocid' , 'id' , 'sub1Field' ]) # FIXME should be ordered
109
133
assert unflattened [0 ]['ocid' ] == 1
110
134
assert unflattened [0 ]['id' ] == 2
@@ -119,6 +143,7 @@ def test_basic_two_sub_sheets(self):
119
143
]
120
144
}
121
145
]
146
+ assert unflattened [1 ] == {'ocid' :1 , 'id' :6 }
122
147
123
148
def test_nested_id (self ):
124
149
spreadsheet_input = ListInput (
@@ -190,16 +215,28 @@ def test_same_rollup(self, recwarn):
190
215
{
191
216
'ocid' : 1 ,
192
217
'id' : 2 ,
193
- 'testA/0/id' : 3 ,
194
- 'testA/0/testB' : 4
218
+ 'testC' : 3 ,
219
+ 'testA/0/id' : 4 ,
220
+ 'testA/0/testB' : 5 ,
221
+ },
222
+ {
223
+ 'ocid' : 6 ,
224
+ 'id' : 7 ,
225
+ 'testC' : 8 ,
226
+ 'testA/0/testB' : 9 ,
195
227
}
196
228
],
197
229
'testA' : [
198
230
{
199
231
'ocid' : 1 ,
200
232
'id' : 2 ,
201
- 'testA/0/id' : 3 ,
202
- 'testA/0/testB' : 4 ,
233
+ 'testA/0/id' : 4 ,
234
+ 'testA/0/testB' : 5 ,
235
+ },
236
+ {
237
+ 'ocid' : 6 ,
238
+ 'id' : 7 ,
239
+ 'testA/0/testB' : 9 ,
203
240
}
204
241
]
205
242
},
@@ -208,7 +245,8 @@ def test_same_rollup(self, recwarn):
208
245
spreadsheet_input .read_sheets ()
209
246
unflattened = list (spreadsheet_input .unflatten ())
210
247
assert unflattened == [
211
- {'ocid' : 1 , 'id' : 2 , 'testA' : [{'id' : 3 , 'testB' : 4 }]}
248
+ {'ocid' : 1 , 'id' : 2 , 'testC' :3 , 'testA' : [{'id' : 4 , 'testB' : 5 }]},
249
+ {'ocid' : 6 , 'id' : 7 , 'testC' :8 , 'testA' : [{'testB' : 9 }, {'testB' : 9 }]}, # FIXME rollup with ID causes duplicates
212
250
]
213
251
# We expect no warnings
214
252
assert recwarn .list == []
0 commit comments