You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/01/21 16:03:29 UTC
[allura] 07/12: [#7878] upload_files as binary
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/7878
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 2439e2647615ee96bfebbc719c0db25d2053f40d
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Thu Jan 16 22:43:18 2020 +0000
[#7878] upload_files as binary
---
Allura/allura/tests/functional/test_discuss.py | 12 ++++++------
ForgeBlog/forgeblog/tests/functional/test_root.py | 6 +++---
.../forgediscussion/tests/functional/test_forum.py | 8 ++++----
ForgeImporters/forgeimporters/tests/forge/test_tracker.py | 4 ++--
.../forgeimporters/trac/tests/functional/test_trac.py | 2 +-
ForgeImporters/forgeimporters/trac/tests/test_tickets.py | 6 +++---
ForgeTracker/forgetracker/tests/functional/test_root.py | 6 +++---
7 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index 4a87fd1..51f080e 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -433,7 +433,7 @@ class TestAttachment(TestDiscussBase):
def test_attach(self):
r = self.app.post(self.post_link + 'attach',
- upload_files=[('file_info', 'test.txt', 'HiThere!')])
+ upload_files=[('file_info', 'test.txt', b'HiThere!')])
r = self.app.get(self.thread_link)
assert '<div class="attachment_holder">' in r
alink = self.attach_link()
@@ -441,12 +441,12 @@ class TestAttachment(TestDiscussBase):
assert r.content_type == 'text/plain'
assert r.content_disposition == 'attachment;filename="test.txt"', 'Attachments should force download'
r = self.app.post(self.post_link + 'attach',
- upload_files=[('file_info', 'test.o12', 'HiThere!')])
+ upload_files=[('file_info', 'test.o12', b'HiThere!')])
r = self.app.post(alink, params=dict(delete='on'))
def test_attach_svg(self):
r = self.app.post(self.post_link + 'attach',
- upload_files=[('file_info', 'test.svg', '<svg onclick="prompt(document.domain)"></svg>')])
+ upload_files=[('file_info', 'test.svg', b'<svg onclick="prompt(document.domain)"></svg>')])
alink = self.attach_link()
r = self.app.get(alink)
assert r.content_type == 'image/svg+xml'
@@ -455,7 +455,7 @@ class TestAttachment(TestDiscussBase):
def test_attach_img(self):
r = self.app.post(self.post_link + 'attach',
upload_files=[('file_info', 'handtinyblack.gif',
- 'GIF89a\x01\x00\x01\x00\x00\xff\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x00;')])
+ b'GIF89a\x01\x00\x01\x00\x00\xff\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x00;')])
alink = self.attach_link()
r = self.app.get(alink)
assert r.content_type == 'image/gif'
@@ -475,8 +475,8 @@ class TestAttachment(TestDiscussBase):
params[post_form.find('textarea')['name']] = 'Reply'
r = self.app.post(self.post_link + 'reply',
params=params,
- upload_files=[('file_info', 'test.txt', 'HiThere!'),
- ('file_info', 'test2.txt', 'HiAgain!')])
+ upload_files=[('file_info', 'test.txt', b'HiThere!'),
+ ('file_info', 'test2.txt', b'HiAgain!')])
r = self.app.get(self.thread_link)
assert "test.txt" in r
diff --git a/ForgeBlog/forgeblog/tests/functional/test_root.py b/ForgeBlog/forgeblog/tests/functional/test_root.py
index 8c61cfa..87fcc53 100644
--- a/ForgeBlog/forgeblog/tests/functional/test_root.py
+++ b/ForgeBlog/forgeblog/tests/functional/test_root.py
@@ -188,8 +188,8 @@ class Test(TestController):
def test_post_attachments(self):
# create
- upload = ('attachment', 'nums.txt', '123412341234')
- upload2 = ('attachment', 'more_nums.txt', '56789')
+ upload = ('attachment', 'nums.txt', b'123412341234')
+ upload2 = ('attachment', 'more_nums.txt', b'56789')
self._post(extra_app_post_params=dict(upload_files=[upload, upload2]))
# check it is listed
@@ -199,7 +199,7 @@ class Test(TestController):
# edit
slug = '/%s/my-post' % d
- upload = ('attachment', 'letters.txt', 'abcdefghij')
+ upload = ('attachment', 'letters.txt', b'abcdefghij')
self._post(slug=slug,
extra_app_post_params=dict(upload_files=[upload]))
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index 13c1f07..eef13ab 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -263,13 +263,13 @@ class TestForumMessageHandling(TestController):
r = self.app.get(thd_url + reply.slug + '/')
# Check attachments
r = self.app.post(url + 'attach',
- upload_files=[('file_info', 'test.txt', 'This is a textfile')])
+ upload_files=[('file_info', 'test.txt', b'This is a textfile')])
r = self.app.post(url + 'attach',
upload_files=[('file_info', 'test.asdfasdtxt',
- 'This is a textfile')])
+ b'This is a textfile')])
r = self.app.post(url + 'attach',
- upload_files=[('file_info', 'test1.txt', 'This is a textfile'),
- ('file_info', 'test2.txt', 'This is a textfile')])
+ upload_files=[('file_info', 'test1.txt', b'This is a textfile'),
+ ('file_info', 'test2.txt', b'This is a textfile')])
r = self.app.get(url)
assert "test1.txt" in r
assert "test2.txt" in r
diff --git a/ForgeImporters/forgeimporters/tests/forge/test_tracker.py b/ForgeImporters/forgeimporters/tests/forge/test_tracker.py
index 99a098c..e56c5e4 100644
--- a/ForgeImporters/forgeimporters/tests/forge/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/forge/test_tracker.py
@@ -357,7 +357,7 @@ class TestForgeTrackerImportController(TestController, TestCase):
def test_create(self, import_tool, sui):
project = M.Project.query.get(shortname='test')
params = {
- 'tickets_json': webtest.Upload('tickets.json', '{"key": "val"}'),
+ 'tickets_json': webtest.Upload('tickets.json', b'{"key": "val"}'),
'mount_label': 'mylabel',
'mount_point': 'mymount',
}
@@ -378,7 +378,7 @@ class TestForgeTrackerImportController(TestController, TestCase):
project.set_tool_data('ForgeTrackerImporter', pending=1)
ThreadLocalORMSession.flush_all()
params = {
- 'tickets_json': webtest.Upload('tickets.json', '{"key": "val"}'),
+ 'tickets_json': webtest.Upload('tickets.json', b'{"key": "val"}'),
'mount_label': 'mylabel',
'mount_point': 'mymount',
}
diff --git a/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py b/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py
index e9ce596..babe127 100644
--- a/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py
+++ b/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py
@@ -37,7 +37,7 @@ class TestTracImportController(TestController):
form['trac_url'] = 'http://example.com/trac'
form['project_name'] = 'My Project'
form['project_shortname'] = 'my-project'
- form['user_map'] = '', ''
+ form['user_map'] = ('', b'')
with patch('forgeimporters.trac.requests.head') as mock_head:
mock_head.return_value.status_code = 200 # so our 'trac_url' above is deemed as an okay URL
diff --git a/ForgeImporters/forgeimporters/trac/tests/test_tickets.py b/ForgeImporters/forgeimporters/trac/tests/test_tickets.py
index 005f9f2..210e2fe 100644
--- a/ForgeImporters/forgeimporters/trac/tests/test_tickets.py
+++ b/ForgeImporters/forgeimporters/trac/tests/test_tickets.py
@@ -136,7 +136,7 @@ class TestTracTicketImportController(TestController, TestCase):
)
r = self.app.post('/p/test/admin/bugs/_importer/create', params,
upload_files=[(
- 'user_map', 'myfile', '{"orig_user": "new_user"}'
+ 'user_map', 'myfile', b'{"orig_user": "new_user"}'
)],
status=302)
self.assertEqual(r.location, 'http://localhost/p/test/admin/')
@@ -163,7 +163,7 @@ class TestTracTicketImportController(TestController, TestCase):
)
r = self.app.post('/p/test/admin/bugs/_importer/create', params,
upload_files=[(
- 'user_map', 'myfile', '{"orig_user": "new_user"}'
+ 'user_map', 'myfile', b'{"orig_user": "new_user"}'
)],
status=302).follow()
self.assertIn('Please wait and try again', r)
@@ -180,7 +180,7 @@ class TestTracTicketImportController(TestController, TestCase):
)
r = self.app.post('/p/test/admin/bugs/_importer/create', params,
upload_files=[(
- 'user_map', 'myfile', '{"orig_user": "new_user"}'
+ 'user_map', 'myfile', b'{"orig_user": "new_user"}'
)])
self.assertEqual(import_tool.post.call_count, 0)
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 75256f2..8e39790 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -928,7 +928,7 @@ class TestFunctionalController(TrackerTestController):
r = self.app.get('/bugs/1/', dict(page=1))
post_link = str(r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
self.app.post(post_link + 'attach',
- upload_files=[('file_info', 'test.txt', 'HiThere!')])
+ upload_files=[('file_info', 'test.txt', b'HiThere!')])
r = self.app.get('/bugs/1/', dict(page=1))
assert '<i class="fa fa-trash-o" aria-hidden="true"></i>' in r
r.forms[5].submit()
@@ -2370,7 +2370,7 @@ class TestFunctionalController(TrackerTestController):
r = self.app.get('/p/test/bugs/1/')
post_link = str(r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
r = self.app.post(post_link + 'attach',
- upload_files=[('file_info', 'test.txt', 'test')])
+ upload_files=[('file_info', 'test.txt', b'test')])
# move ticket
p = M.Project.query.get(shortname='test2')
bugs2 = p.app_instance('bugs2')
@@ -2444,7 +2444,7 @@ class TestFunctionalController(TrackerTestController):
r = self.app.get('/bugs/1/', dict(page=1))
post_link = str(r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
self.app.post(post_link + 'attach',
- upload_files=[('file_info', 'test.txt', 'test attach')])
+ upload_files=[('file_info', 'test.txt', b'test attach')])
r = self.app.get('/p/test/bugs/1/')
discussion_url = r.html.findAll('form')[-1]['action'][:-4]
r = self.app.get('/rest/p/test/bugs/1/')