From e89e758dac13b63cff6ef5a62e84df70598dd900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Tue, 23 Sep 2008 14:36:15 +0000 Subject: [PATCH] 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 --- product/ERP5/tests/testInvoice.py | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/product/ERP5/tests/testInvoice.py b/product/ERP5/tests/testInvoice.py index 794ae3f12d..2726627baf 100644 --- a/product/ERP5/tests/testInvoice.py +++ b/product/ERP5/tests/testInvoice.py @@ -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 -- 2.30.9