Commit e89e758d authored by Jérome Perrin's avatar Jérome Perrin

test Invoice print when organisation logos are not valid images

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23765 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e22005fb
No related merge requests found
......@@ -36,6 +36,7 @@ TODO:
"""
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5OOo.OOoUtils import OOoParser
from AccessControl.SecurityManagement import newSecurityManager
......@@ -709,6 +710,57 @@ class TestInvoice(TestInvoiceMixin):
style_xml = parser.oo_files['styles.xml']
self.assert_('<draw:image' not in style_xml)
def test_Invoice_viewAsODT_invalid_image(self):
resource = self.portal.getDefaultModule(
self.resource_portal_type).newContent(
portal_type=self.resource_portal_type,
title='Resource',)
file_data = FileUpload(__file__, 'rb')
client = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Client')
client_logo = client.newContent(portal_type='Image',
id='default_image',
file=file_data)
vendor = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Vendor')
vendor_logo = vendor.newContent(portal_type='Image',
id='default_image',
file=file_data)
# width and height of an invalid image are -1 according to
# OFS.Image.getImageInfo maybe this is not what we want here ?
self.assertEquals(-1, vendor.getDefaultImageWidth())
self.assertEquals(-1, vendor.getDefaultImageHeight())
invoice = self.portal.getDefaultModule(self.invoice_portal_type).newContent(
portal_type=self.invoice_portal_type,
start_date=DateTime(2008, 12, 31),
title='Invoice',
source_value=vendor,
source_section_value=vendor,
destination_value=client,
destination_section_value=client)
line = invoice.newContent(portal_type=self.invoice_line_portal_type,
resource_value=resource,
quantity=10,
price=3)
invoice.confirm()
get_transaction().commit()
self.tic()
odt = invoice.Invoice_viewAsODT()
from Products.ERP5OOo.tests.utils import Validator
odf_validator = Validator()
err_list = odf_validator.validate(odt)
if err_list:
self.fail(''.join(err_list))
# the <draw:image> should not be present, because there's no logo
parser = OOoParser()
parser.openFromString(odt)
style_xml = parser.oo_files['styles.xml']
self.assert_('<draw:image' not in style_xml)
def test_invoice_building_with_cells(self):
# if the order has cells, the invoice built from that order must have
# cells too
......
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