1206 |
1206 |
resp = resp.click('Import Events')
|
1207 |
1207 |
sample_csv_resp = resp.click('Download sample file')
|
1208 |
1208 |
assert sample_csv_resp.content_type == 'text/csv'
|
1209 |
|
assert sample_csv_resp.text.startswith('date,time,')
|
|
1209 |
assert sample_csv_resp.text.startswith('date,time')
|
1210 |
1210 |
|
1211 |
1211 |
resp.form['events_csv_file'] = Upload('t.csv', sample_csv_resp.content, 'text/csv')
|
1212 |
1212 |
resp = resp.form.submit(status=302)
|
... | ... | |
1344 |
1344 |
resp.form['events_csv_file'] = Upload('t.csv', b'2016-09-16,18:00,10,5,label,slug', 'text/csv')
|
1345 |
1345 |
resp = resp.form.submit(status=200)
|
1346 |
1346 |
assert 'Event with this Agenda and Identifier already exists.' in resp.text
|
1347 |
|
assert not '__all__' in resp.text
|
|
1347 |
assert '__all__' not in resp.text
|
1348 |
1348 |
|
1349 |
1349 |
# additional optional attributes
|
1350 |
1350 |
Event.objects.all().delete()
|
1351 |
1351 |
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
|
|
1352 |
resp.form['events_csv_file'] = Upload('t.csv', b'2016-09-16,18:00,10,5,label,slug,,,,', 'text/csv')
|
|
1353 |
resp = resp.form.submit(status=302)
|
|
1354 |
assert Event.objects.count() == 1
|
|
1355 |
event = Event.objects.get()
|
|
1356 |
assert event.description == ''
|
|
1357 |
assert event.pricing == ''
|
|
1358 |
assert event.url == ''
|
|
1359 |
assert event.publication_date is None
|
|
1360 |
Event.objects.all().delete()
|
|
1361 |
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
|
1352 |
1362 |
resp.form['events_csv_file'] = Upload(
|
1353 |
|
't.csv', b'2016-09-16,18:00,10,5,label,slug,description,pricing,url', 'text/csv'
|
|
1363 |
't.csv', b'2016-09-16,18:00,10,5,label,slug,description,pricing,url,2016-10-16', 'text/csv'
|
1354 |
1364 |
)
|
1355 |
1365 |
resp = resp.form.submit(status=302)
|
1356 |
1366 |
assert Event.objects.count() == 1
|
1357 |
|
assert Event.objects.all()[0].description == 'description'
|
1358 |
|
assert Event.objects.all()[0].pricing == 'pricing'
|
1359 |
|
assert Event.objects.all()[0].url == 'url'
|
|
1367 |
event = Event.objects.get()
|
|
1368 |
assert event.description == 'description'
|
|
1369 |
assert event.pricing == 'pricing'
|
|
1370 |
assert event.url == 'url'
|
|
1371 |
assert event.publication_date == datetime.date(2016, 10, 16)
|
|
1372 |
|
|
1373 |
# publication date bad format
|
|
1374 |
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
|
|
1375 |
resp.form['events_csv_file'] = Upload(
|
|
1376 |
't.csv', b'2016-09-16,18:00,10,5,label,slug,description,pricing,url,foobar', 'text/csv'
|
|
1377 |
)
|
|
1378 |
resp = resp.form.submit(status=200)
|
|
1379 |
assert 'Invalid file format. (date format' in resp.text
|
1360 |
1380 |
|
1361 |
1381 |
# import events with empty slugs
|
1362 |
1382 |
Event.objects.all().delete()
|
1363 |
|
-
|