You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2020/01/24 18:59:02 UTC
[allura] 09/13: [#7878] tests need to treat responses as unicode
text
This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 37ffa2518bc43324d85d778c6e85cc5c03a38847
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Thu Jan 16 23:17:49 2020 +0000
[#7878] tests need to treat responses as unicode text
---
Allura/allura/tests/functional/test_admin.py | 12 ++++----
Allura/allura/tests/functional/test_auth.py | 2 +-
Allura/allura/tests/functional/test_discuss.py | 11 +++-----
Allura/allura/tests/functional/test_root.py | 4 +--
.../forgediscussion/tests/functional/test_forum.py | 9 +++---
.../forgetracker/tests/functional/test_root.py | 32 +++++++++++-----------
6 files changed, 33 insertions(+), 37 deletions(-)
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 6a50b1b..d01eca0 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -63,7 +63,7 @@ class TestProjectAdmin(TestController):
'utf-8') * 45,
labels='aaa,bbb'))
r = self.app.get('/admin/overview')
- assert 'A Test Project ?\xc2\xbf A' in r
+ assert b'A Test Project ?\xc2\xbf A' in r.body
assert 'Test Subproject' not in r
assert 'Milkshakes are for crazy monkeys' in r
sidebar = r.html.find(id='sidebar')
@@ -707,8 +707,8 @@ class TestProjectAdmin(TestController):
'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
mem_holder = r.html.find(
'table', {'id': 'usergroup_admin'}).findAll('tr')[3]
- assert 'All users in Admin group' in str(dev_holder)
- assert 'All users in Developer group' in str(mem_holder)
+ assert 'All users in Admin group' in dev_holder.text
+ assert 'All users in Developer group' in mem_holder.text
r = self.app.get('/admin/groups/')
@@ -806,7 +806,7 @@ class TestProjectAdmin(TestController):
params={'name': 'RoleNew1'})
r = self.app.get('/admin/groups/')
role_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[4]
- assert 'RoleNew1' in str(role_holder)
+ assert 'RoleNew1' in role_holder.text
role_id = role_holder['data-group']
# add test-user to role
@@ -821,7 +821,7 @@ class TestProjectAdmin(TestController):
'group_name': 'RoleNew1'})
assert 'deleted' in self.webflash(r)
r = self.app.get('/admin/groups/', status=200)
- roles = [str(t) for t in r.html.findAll('td', {'class': 'group'})]
+ roles = [t.text for t in r.html.findAll('td', {'class': 'group'})]
assert 'RoleNew1' not in roles
# make sure can still access homepage after one of user's roles were
@@ -1047,7 +1047,7 @@ class TestExport(TestController):
session.return_value = {'result': [{"total_size": 10000}]}
export_tasks.bulk_export.post(['wiki'])
r = self.app.get('/admin/export')
- assert_in('<h2>Busy</h2>', r.body)
+ assert_in('<h2>Busy</h2>', r.text)
@td.with_user_project('test-user')
def test_bulk_export_path_for_user_project(self):
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 4f326db..64ba3e7 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -1150,7 +1150,7 @@ class TestPreferences(TestController):
# Check if setting a wrong date everything works correctly
r = self.app.post('/auth/user_info/change_personal_data',
params=dict(birthdate='30/02/1998', _session_id=self.app.cookies['_session_id']))
- assert 'Please enter a valid date' in str(r)
+ assert 'Please enter a valid date' in r.text
user = M.User.query.get(username='test-admin')
sex = user.sex
assert sex == setsex
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index 51f080e..64791da 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -369,10 +369,8 @@ class TestDiscuss(TestDiscussBase):
reply_form = r.html.find(
'div', {'class': 'edit_post_form reply'}).find('form')
post_link = str(reply_form['action'])
- assert 'This is a post' in str(
- r.html.find('div', {'class': 'display_post'}))
- assert 'Last edit:' not in str(
- r.html.find('div', {'class': 'display_post'}))
+ assert 'This is a post' in r.html.find('div', {'class': 'display_post'}).text
+ assert 'Last edit:' not in r.html.find('div', {'class': 'display_post'}).text
params = dict()
inputs = reply_form.findAll('input')
for field in inputs:
@@ -383,9 +381,8 @@ class TestDiscuss(TestDiscussBase):
assert create_activity.call_count == 1, create_activity.call_count
assert create_activity.call_args[0][1] == 'modified'
r = self.app.get(thread_url)
- assert 'zzz' in str(r.html.find('div', {'class': 'display_post'}))
- assert 'Last edit: Test Admin ' in str(
- r.html.find('div', {'class': 'display_post'}))
+ assert 'zzz' in r.html.find('div', {'class': 'display_post'}).text
+ assert 'Last edit: Test Admin ' in r.html.find('div', {'class': 'display_post'}).text
def test_deleted_post(self):
r = self._make_post('This is a post')
diff --git a/Allura/allura/tests/functional/test_root.py b/Allura/allura/tests/functional/test_root.py
index b91a97e..e9c630c 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -88,8 +88,8 @@ class TestRootController(TestController):
response = self.app.get('/neighborhood')
# inject it into the sidebar data
- content = str(response.html.find('div', {'id': 'content_base'}))
- assert '<script>' not in content
+ content = response.html.find('div', {'id': 'content_base'}).prettify()
+ assert '<script>' not in content, content
assert '<script>' in content
def test_strange_accept_headers(self):
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index eef13ab..3d9752b 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -674,9 +674,8 @@ class TestForum(TestController):
params[reply_form.find('textarea')['name']] = 'zzz'
self.app.post(post_link, params)
r = self.app.get(thread_url)
- assert 'zzz' in str(r.html.find('div', {'class': 'display_post'}))
- assert 'Last edit: Test Admin ' in str(
- r.html.find('div', {'class': 'display_post'}))
+ assert 'zzz' in r.html.find('div', {'class': 'display_post'}).text
+ assert 'Last edit: Test Admin ' in r.html.find('div', {'class': 'display_post'}).text
def test_subscription_controls(self):
r = self.app.get('/discussion/create_topic/')
@@ -824,8 +823,8 @@ class TestForum(TestController):
r = self.app.get('/discussion/testforum/')
rows = self.get_table_rows(r, 'forum_threads')
assert_equal(len(rows), 2)
- assert 'topic1' in str(rows[0])
- assert 'topic2' in str(rows[1])
+ assert 'topic1' in rows[0].text
+ assert 'topic2' in rows[1].text
# Reset Sticky flag
r = self.app.post(url1 + 'moderate', params=dict(
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 8e39790..8d624af 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1606,16 +1606,16 @@ class TestFunctionalController(TrackerTestController):
ThreadLocalORMSession.flush_all()
response = self.app.get('/p/test/bugs/?sort=summary+asc')
ticket_rows = response.html.find('table', {'class': 'ticket-list'}).find('tbody')
- assert_in('test first ticket', str(ticket_rows))
- assert_in('test second ticket', str(ticket_rows))
+ assert_in('test first ticket', ticket_rows.text)
+ assert_in('test second ticket', ticket_rows.text)
edit_link = response.html.find('a', {'title': 'Bulk Edit'})
expected_link = "/p/test/bugs/edit/?q=%21status%3Awont-fix+%26%26+%21status%3Aclosed"\
"&sort=snippet_s+asc&limit=25&filter=&page=0"
assert_equal(expected_link, edit_link['href'])
response = self.app.get(edit_link['href'])
ticket_rows = response.html.find('tbody', {'class': 'ticket-list'})
- assert_in('test first ticket', str(ticket_rows))
- assert_in('test second ticket', str(ticket_rows))
+ assert_in('test first ticket', ticket_rows.text)
+ assert_in('test second ticket', ticket_rows.text)
def test_bulk_edit_milestone(self):
self.new_ticket(summary='test first ticket',
@@ -1629,17 +1629,17 @@ class TestFunctionalController(TrackerTestController):
ThreadLocalORMSession.flush_all()
response = self.app.get('/p/test/bugs/milestone/1.0/?sort=ticket_num+asc')
ticket_rows = response.html.find('table', {'class': 'ticket-list'}).find('tbody')
- assert_in('test first ticket', str(ticket_rows))
- assert_in('test second ticket', str(ticket_rows))
- assert_in('test third ticket', str(ticket_rows))
+ assert_in('test first ticket', ticket_rows.text)
+ assert_in('test second ticket', ticket_rows.text)
+ assert_in('test third ticket', ticket_rows.text)
edit_link = response.html.find('a', {'title': 'Bulk Edit'})
expected_link = "/p/test/bugs/edit/?q=_milestone%3A1.0&sort=ticket_num_i+asc&limit=25&filter=&page=0"
assert_equal(expected_link, edit_link['href'])
response = self.app.get(edit_link['href'])
ticket_rows = response.html.find('tbody', {'class': 'ticket-list'})
- assert_in('test first ticket', str(ticket_rows))
- assert_in('test second ticket', str(ticket_rows))
- assert_in('test third ticket', str(ticket_rows))
+ assert_in('test first ticket', ticket_rows.text)
+ assert_in('test second ticket', ticket_rows.text)
+ assert_in('test third ticket', ticket_rows.text)
def test_bulk_edit_search(self):
self.new_ticket(summary='test first ticket', status='open')
@@ -1650,17 +1650,17 @@ class TestFunctionalController(TrackerTestController):
ThreadLocalORMSession.flush_all()
response = self.app.get('/p/test/bugs/search/?q=status%3Aopen')
ticket_rows = response.html.find('table', {'class': 'ticket-list'}).find('tbody')
- assert_in('test first ticket', str(ticket_rows))
- assert_in('test second ticket', str(ticket_rows))
- assert_false('test third ticket' in str(ticket_rows))
+ assert_in('test first ticket', ticket_rows.text)
+ assert_in('test second ticket', ticket_rows.text)
+ assert_false('test third ticket' in ticket_rows.text)
edit_link = response.html.find('a', {'title': 'Bulk Edit'})
expected_link = "/p/test/bugs/edit/?q=status%3Aopen&limit=25&filter=%7B%7D&page=0"
assert_equal(expected_link, edit_link['href'])
response = self.app.get(edit_link['href'])
ticket_rows = response.html.find('tbody', {'class': 'ticket-list'})
- assert_in('test first ticket', str(ticket_rows))
- assert_in('test second ticket', str(ticket_rows))
- assert_false('test third ticket' in str(ticket_rows))
+ assert_in('test first ticket', ticket_rows.text)
+ assert_in('test second ticket', ticket_rows.text)
+ assert_false('test third ticket' in ticket_rows.text)
def test_new_ticket_notification_contains_attachments(self):
file_name = 'tést_root.py'.encode('utf-8')