1316 |
1316 |
# additional optional attributes
|
1317 |
1317 |
Event.objects.all().delete()
|
1318 |
1318 |
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
|
1319 |
|
resp.form['events_csv_file'] = Upload('t.csv', b'2016-09-16,18:00,10,5,label,slug,,,,', 'text/csv')
|
|
1319 |
resp.form['events_csv_file'] = Upload('t.csv', b'2016-09-16,18:00,10,5,label,slug,,,,,', 'text/csv')
|
1320 |
1320 |
resp = resp.form.submit(status=302)
|
1321 |
1321 |
assert Event.objects.count() == 1
|
1322 |
1322 |
event = Event.objects.get()
|
... | ... | |
1324 |
1324 |
assert event.pricing == ''
|
1325 |
1325 |
assert event.url == ''
|
1326 |
1326 |
assert event.publication_date is None
|
|
1327 |
assert event.duration is None
|
1327 |
1328 |
Event.objects.all().delete()
|
1328 |
1329 |
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
|
1329 |
1330 |
resp.form['events_csv_file'] = Upload(
|
1330 |
|
't.csv', b'2016-09-16,18:00,10,5,label,slug,description,pricing,url,2016-10-16', 'text/csv'
|
|
1331 |
't.csv', b'2016-09-16,18:00,10,5,label,slug,description,pricing,url,2016-10-16,90', 'text/csv'
|
1331 |
1332 |
)
|
1332 |
1333 |
resp = resp.form.submit(status=302)
|
1333 |
1334 |
assert Event.objects.count() == 1
|
... | ... | |
1336 |
1337 |
assert event.pricing == 'pricing'
|
1337 |
1338 |
assert event.url == 'url'
|
1338 |
1339 |
assert event.publication_date == datetime.date(2016, 10, 16)
|
|
1340 |
assert event.duration == 90
|
1339 |
1341 |
|
1340 |
1342 |
# publication date bad format
|
1341 |
1343 |
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
|
... | ... | |
1345 |
1347 |
resp = resp.form.submit(status=200)
|
1346 |
1348 |
assert 'Invalid file format. (date format' in resp.text
|
1347 |
1349 |
|
|
1350 |
# duration bad format
|
|
1351 |
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
|
|
1352 |
resp.form['events_csv_file'] = Upload(
|
|
1353 |
't.csv', b'2016-09-16,18:00,10,5,label,slug,description,pricing,url,2016-09-16,foobar', 'text/csv'
|
|
1354 |
)
|
|
1355 |
resp = resp.form.submit(status=200)
|
|
1356 |
assert 'Invalid file format. (duration' in resp.text
|
|
1357 |
|
1348 |
1358 |
# import events with empty slugs
|
1349 |
1359 |
Event.objects.all().delete()
|
1350 |
1360 |
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
|
1351 |
|
-
|