287 |
287 |
fields.EmailField(id='8', label='Email'),
|
288 |
288 |
fields.TextField(id='9', label='Long'),
|
289 |
289 |
fields.ItemField(id='10', label='List2', data_source=data_source),
|
|
290 |
fields.ItemsField(id='11', label='Items', data_source=data_source, required=False),
|
290 |
291 |
]
|
291 |
292 |
carddef.workflow_roles = {'_editor': user.roles[0]}
|
292 |
293 |
carddef.store()
|
... | ... | |
315 |
316 |
sample_resp = resp.click('Download sample file for this card')
|
316 |
317 |
today = datetime.date.today()
|
317 |
318 |
assert sample_resp.text == (
|
318 |
|
"Table,Map,Test,Boolean,List,Date,File,Email,Long,List2\r\n"
|
|
319 |
"Table,Map,Test,Boolean,List,Date,File,Email,Long,List2,Items\r\n"
|
319 |
320 |
"will be ignored - type Table not supported,"
|
320 |
321 |
"%s,"
|
321 |
322 |
"value,"
|
... | ... | |
325 |
326 |
"will be ignored - type File Upload not supported,"
|
326 |
327 |
"foo@example.com,"
|
327 |
328 |
"value,"
|
328 |
|
"value\r\n" % (pub.get_default_position(), today))
|
|
329 |
"value,"
|
|
330 |
"id1|id2|...\r\n" % (pub.get_default_position(), today))
|
329 |
331 |
|
330 |
332 |
# missing file
|
331 |
333 |
resp = resp.forms[0].submit()
|
... | ... | |
345 |
347 |
resp = resp.forms[0].submit()
|
346 |
348 |
assert 'CSV file contains less columns than card fields.' in resp.text
|
347 |
349 |
|
348 |
|
data = [b'Table,Map,Test,Boolean,List,Date,File,Email,Long,List2']
|
|
350 |
data = [b'Table,Map,Test,Boolean,List,Date,File,Email,Long,List2,Items']
|
349 |
351 |
for i in range(1, 150):
|
350 |
|
data.append(b'table,48.81;2.37,data%d ,%s,item%d,2020-01-%02d,filename-%d,test@localhost,"plop\nplop",1' % (
|
|
352 |
data.append(b'table,48.81;2.37,data%d ,%s,item%d,2020-01-%02d,filename-%d,test@localhost,"plop\nplop",1,1|2' % (
|
351 |
353 |
i, str(bool(i % 2)).encode('utf-8'), i, i % 31 + 1, i))
|
352 |
354 |
|
353 |
355 |
resp.forms[0]['file'] = Upload('test.csv', b'\n'.join(data),
|
... | ... | |
365 |
367 |
assert card1.data['10'] == '1'
|
366 |
368 |
assert card1.data['10_display'] == 'un'
|
367 |
369 |
assert card1.data['10_structured'] == {'id': '1', 'text': 'un', 'more': 'foo'}
|
|
370 |
assert card1.data['11'] == ['1', '2']
|
|
371 |
assert card1.data['11_display'] == 'un, deux'
|
|
372 |
assert card1.data['11_structured'] == [
|
|
373 |
{'id': '1', 'text': 'un', 'more': 'foo'},
|
|
374 |
{'id': '2', 'text': 'deux', 'more': 'bar'}]
|
368 |
375 |
assert card2.data['2'] == 'data2'
|
369 |
376 |
assert card2.data['3'] is False
|
370 |
377 |
assert card2.data['5'].tm_mday == 3
|