python3: pass bytes to Upload content (#40911)

This commit is contained in:
Nicolas Roche 2020-03-24 11:35:02 +01:00
parent f39cbee9d2
commit 02f660ca5b
1 changed files with 2 additions and 3 deletions

View File

@ -2,6 +2,7 @@
import csv
from django.utils.encoding import force_bytes
from django.utils.six import StringIO
from webtest import Upload
@ -24,15 +25,13 @@ def test_synchronize_federations(settings, app, nanterre_classic_family, admin):
response = response.click(u'Synchroniser les fédérations')
response = response.click(u'Nouvel import')
response.form.set('app_id', 'technocarte')
content = '\n'.join(map(str, [f['kevin'].id + 1000, f['marie'].id + 1000, '99999']))
content = force_bytes('\n'.join(map(str, [f['kevin'].id + 1000, f['marie'].id + 1000, '99999'])))
response.form.set('csv_uploaded', Upload('federations.csv', content, 'application/octet-stream'))
response = response.form.submit().follow()
assert len(response.pyquery('table#result-list tbody tr')) == 1
response = response.click('Rapport')
def check_csv_response(csv_response):
reader = csv.DictReader(StringIO(csv_response.content))
reader.fieldnames = reader.reader.next()
rows = list(reader)
def rows_by_action(action):