python3: handle http responses' payload as str in test_user_manager
This commit is contained in:
parent
872a33d8a1
commit
ec3ada75e6
|
@ -174,7 +174,7 @@ def test_export_csv_disabled_attribute(settings, app, superuser):
|
|||
response = response.click('CSV')
|
||||
|
||||
user_count = User.objects.count()
|
||||
table = list(csv.reader(response.content.splitlines()))
|
||||
table = list(csv.reader(response.text.splitlines()))
|
||||
assert len(table) == (user_count + 1)
|
||||
num_col = 15 + 1 # 1 is the number active attributes,
|
||||
# disabled attribute should not show up
|
||||
|
@ -370,7 +370,7 @@ def import_csv(csv_content, app):
|
|||
time.sleep(.1)
|
||||
|
||||
# report
|
||||
urls = re.findall('<a href="(/manage/users/import/[^/]+/[^/]+/)">', response.content)
|
||||
urls = re.findall('<a href="(/manage/users/import/[^/]+/[^/]+/)">', response.text)
|
||||
response = app.get(urls[0])
|
||||
return response
|
||||
|
||||
|
@ -393,13 +393,13 @@ def test_user_import_attributes(transactional_db, app, admin, media):
|
|||
u"elliot@universalpictures.com,Elliott,Thomas,petit,Mr,True,2019-7-20,1972-05-26,75014,1234",
|
||||
u"et@universalpictures.com,ET,the Extra-Terrestrial,long,??,False,1/2/3/4,0002-2-22,42,home"]
|
||||
response = import_csv('\n'.join(csv_lines), app)
|
||||
urls = re.findall('<a href="(/manage/users/import/[^/]+/[^/]+/)">', response.content)
|
||||
urls = re.findall('<a href="(/manage/users/import/[^/]+/[^/]+/)">', response.text)
|
||||
response = app.get(urls[0])
|
||||
assert 'Select a valid choice. ?? is not one of the available choices.' in response.content
|
||||
assert 'Enter a valid date.' in response.content
|
||||
assert 'birthdate must be in the past and greater or equal than 1900-01-01.' in response.content
|
||||
assert 'The value must be a valid french postcode' in response.content
|
||||
assert 'Phone number can start with a + an must contain only digits' in response.content
|
||||
assert 'Select a valid choice. ?? is not one of the available choices.' in response.text
|
||||
assert 'Enter a valid date.' in response.text
|
||||
assert 'birthdate must be in the past and greater or equal than 1900-01-01.' in response.text
|
||||
assert 'The value must be a valid french postcode' in response.text
|
||||
assert 'Phone number can start with a + an must contain only digits' in response.text
|
||||
|
||||
assert User.objects.count() == user_count + 1
|
||||
elliot = User.objects.filter(email='elliot@universalpictures.com')[0]
|
||||
|
@ -414,7 +414,7 @@ def test_user_import_attributes(transactional_db, app, admin, media):
|
|||
csv_lines[2] = \
|
||||
u"et@universalpictures.com,ET,the Extra-Terrestrial,,,,,,42000,+888 5678"
|
||||
response = import_csv('\n'.join(csv_lines), app)
|
||||
assert '0 rows have errors' in response.content
|
||||
assert '0 rows have errors' in response.text
|
||||
|
||||
assert User.objects.count() == user_count + 2
|
||||
et = User.objects.filter(email='et@universalpictures.com')[0]
|
||||
|
|
Loading…
Reference in New Issue