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

Test deferred style with converting to a format

parent ce9e92bf
...@@ -39,6 +39,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -39,6 +39,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
skin = content_type = None skin = content_type = None
recipient_email_address = 'invalid@example.com' recipient_email_address = 'invalid@example.com'
attachment_file_extension = '' attachment_file_extension = ''
format = ''
username = 'bob' username = 'bob'
password = 'bobpwd' password = 'bobpwd'
# the weird '<' char is to force quoting of the first name on the e-mail # the weird '<' char is to force quoting of the first name on the e-mail
...@@ -83,8 +84,8 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -83,8 +84,8 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self.loginAsUser('bob') self.loginAsUser('bob')
self.portal.changeSkin('Deferred') self.portal.changeSkin('Deferred')
response = self.publish( response = self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s' '/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s&format=%s'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password)) % (self.portal.getId(), self.skin, self.format), '%s:%s' % (self.username, self.password))
self.tic() self.tic()
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
...@@ -102,9 +103,12 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -102,9 +103,12 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEquals('attachment; filename="%s"' % expected_file_name, self.assertEquals('attachment; filename="%s"' % expected_file_name,
part.get('Content-Disposition')) part.get('Content-Disposition'))
data = part.get_payload(decode=True) data = part.get_payload(decode=True)
if self.format == '':
error_list = Validator().validate(data) error_list = Validator().validate(data)
if error_list: if error_list:
self.fail(''.join(error_list)) self.fail(''.join(error_list))
elif self.format == 'pdf':
self.assertTrue(data.startswith('%PDF'))
break break
else: else:
self.fail('Attachment not found in email\n%s' % message_text) self.fail('Attachment not found in email\n%s' % message_text)
...@@ -116,8 +120,9 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -116,8 +120,9 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
response = self.publish( response = self.publish(
'/%s/person_module/pers/Base_callDialogMethod?deferred_portal_skin=%s&' '/%s/person_module/pers/Base_callDialogMethod?deferred_portal_skin=%s&'
'dialog_method=Person_view&dialog_id=Person_view&' 'dialog_method=Person_view&dialog_id=Person_view&'
'deferred_style:int=1&junk=%s' % (self.portal.getId(), 'deferred_style:int=1&format=%s&junk=%s' % (self.portal.getId(),
self.skin, self.skin,
self.format,
'X' * 2000), 'X' * 2000),
'%s:%s' % (self.username, self.password)) '%s:%s' % (self.username, self.password))
self.tic() self.tic()
...@@ -136,9 +141,12 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -136,9 +141,12 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEquals('attachment; filename="%s"' % expected_file_name, self.assertEquals('attachment; filename="%s"' % expected_file_name,
part.get('Content-Disposition')) part.get('Content-Disposition'))
data = part.get_payload(decode=True) data = part.get_payload(decode=True)
if self.format == '':
error_list = Validator().validate(data) error_list = Validator().validate(data)
if error_list: if error_list:
self.fail(''.join(error_list)) self.fail(''.join(error_list))
elif self.format == 'pdf':
self.assertTrue(data.startswith('%PDF'))
break break
else: else:
self.fail('Attachment not found in email\n%s' % message_text) self.fail('Attachment not found in email\n%s' % message_text)
...@@ -149,16 +157,42 @@ class TestODSDeferredStyle(TestDeferredStyle): ...@@ -149,16 +157,42 @@ class TestODSDeferredStyle(TestDeferredStyle):
content_type = 'application/vnd.oasis.opendocument.spreadsheet' content_type = 'application/vnd.oasis.opendocument.spreadsheet'
attachment_file_extension = '.ods' attachment_file_extension = '.ods'
class TestODSDeferredStyleFormatXLSX(TestDeferredStyle):
skin = 'ODS'
content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
attachment_file_extension = '.xlsx'
format = 'xlsx'
class TestODSDeferredStyleFormatPDF(TestDeferredStyle):
skin = 'ODS'
content_type = 'application/pdf'
attachment_file_extension = '.pdf'
format = 'pdf'
class TestODTDeferredStyle(TestDeferredStyle): class TestODTDeferredStyle(TestDeferredStyle):
skin = 'ODT' skin = 'ODT'
content_type = 'application/vnd.oasis.opendocument.text' content_type = 'application/vnd.oasis.opendocument.text'
attachment_file_extension = '.odt' attachment_file_extension = '.odt'
class TestODTDeferredStyleFormatDOCX(TestDeferredStyle):
skin = 'ODT'
content_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
attachment_file_extension = '.docx'
format = 'docx'
class TestODTDeferredStyleFormatPDF(TestDeferredStyle):
skin = 'ODT'
content_type = 'application/pdf'
attachment_file_extension = '.pdf'
format = 'pdf'
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestODSDeferredStyle)) suite.addTest(unittest.makeSuite(TestODSDeferredStyle))
suite.addTest(unittest.makeSuite(TestODSDeferredStyleFormatXLSX))
suite.addTest(unittest.makeSuite(TestODSDeferredStyleFormatPDF))
suite.addTest(unittest.makeSuite(TestODTDeferredStyle)) suite.addTest(unittest.makeSuite(TestODTDeferredStyle))
suite.addTest(unittest.makeSuite(TestODTDeferredStyleFormatDOCX))
suite.addTest(unittest.makeSuite(TestODTDeferredStyleFormatPDF))
return suite return suite
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