Commit 9eab4dc7 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

tests: fix usage of ERP5Type.tests.utils.FileUpload.

parent 62238d4b
......@@ -78,7 +78,7 @@ class TestERP5Base(ERP5TypeTestCase):
def makeImageFileUpload(self, filename):
return FileUpload(
os.path.join(os.path.dirname(__file__),
'test_data', 'images', filename), 'rb')
'test_data', 'images', filename))
def login(self):
"""Create a new manager user and login.
......
......@@ -873,7 +873,7 @@ class TestCommerce(ERP5TypeTestCase):
"""
product = self.getDefaultProduct()
file_upload = FileUpload(os.path.join(os.path.dirname(__file__),
'test_data', 'images', 'erp5_logo_small.png'), 'rb')
'test_data', 'images', 'erp5_logo_small.png'))
product.edit(default_image_file=file_upload)
self.tic()
......
......@@ -1704,7 +1704,7 @@ class TestInvoice(TestInvoiceMixin):
self.resource_portal_type).newContent(
portal_type=self.resource_portal_type,
title='Resource',)
file_data = FileUpload(__file__, 'rb')
file_data = FileUpload(__file__)
client = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Client')
client_logo = client.newContent(portal_type='Embedded File',
......
......@@ -2776,7 +2776,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
portal_type=self.resource_portal_type,
title='Resource',)
image = FileUpload(os.path.join(os.path.dirname(__file__),
'test_data', 'images', 'erp5_logo.png'), 'rb')
'test_data', 'images', 'erp5_logo.png'))
client = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Client',
default_image_file=image)
......@@ -2813,7 +2813,7 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
portal_type=self.resource_portal_type,
title='Resource',)
image = FileUpload(os.path.join(os.path.dirname(__file__),
'test_data', 'images', 'erp5_logo.bmp'), 'rb')
'test_data', 'images', 'erp5_logo.bmp'))
client = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Client',
default_image_file=image)
......
......@@ -57,7 +57,7 @@ class TestScribusUtils(ERP5TypeTestCase):
def makeFileUpload(self, filename):
return FileUpload(
os.path.join(os.path.dirname(__file__),
'data', filename), 'rb')
'data', filename))
def test_01_SimpleModuleCreation(self):
'''Just create a module using scribus file and pdf file with minimal
......
......@@ -304,7 +304,7 @@ class TestFormPrintoutAsODG(TestFormPrintoutMixin):
current_dir = os.path.dirname(__file__)
parent_dir = os.path.dirname(current_dir)
image_path = os.path.join(parent_dir, 'www', 'form_printout_icon.png')
file_data = FileUpload(image_path, 'rb')
file_data = FileUpload(image_path)
image = person1.newContent(portal_type='Embedded File')
image.edit(file=file_data)
......
......@@ -1108,7 +1108,7 @@ return []
image_path = os.path.join(parent_dir,
'www',
'form_printout_icon.png')
file_data = FileUpload(image_path, 'rb')
file_data = FileUpload(image_path)
image = self.portal.newContent(portal_type='Image', id='test_image')
image.edit(file=file_data)
......
......@@ -216,7 +216,7 @@ return getattr(context, "%s_%s" % (parameter, current_language))
filename = 'cmyk_sample.jpg'
file_path = os.path.join(os.path.dirname(__file__), 'test_document',
filename)
upload_file = FileUpload(file_path, filename)
upload_file = FileUpload(file_path)
document = self.portal.portal_contributions.newContent(file=upload_file)
addOOoTemplate = self.getPortal().manage_addProduct['ERP5OOo'].addOOoTemplate
addOOoTemplate(id='Base_viewIncludeImageAsOdt', title='')
......
......@@ -51,7 +51,9 @@ class FileUpload(file):
"""Act as an uploaded file.
"""
__allow_access_to_unprotected_subobjects__ = 1
def __init__(self, path, name):
def __init__(self, path, name=None):
if name is None:
name = os.path.basename(path)
self.filename = name
file.__init__(self, path)
self.headers = {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment