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

CRM: py3 WIP

parent 4e91e2e9
......@@ -693,7 +693,8 @@ class TestCRMMailIngestion(BaseTestCRM):
def _readTestData(self, filename):
"""read test data from data directory."""
return open(makeFilePath(filename)).read()
with open(makeFilePath(filename), 'rb') as f:
return f.read()
def _ingestMail(self, filename=None, data=None):
"""ingest an email from the mail in data dir named `filename`"""
......@@ -832,7 +833,7 @@ class TestCRMMailIngestion(BaseTestCRM):
Subject: mail subject
content
''').splitlines()[1:]))
''').splitlines()[1:].encode()))
property_dict = event.getPropertyDictFromContent()
# destination is set on the event. In this case it is kept as is.
......@@ -1287,7 +1288,7 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_content_type()=='text/plain':
part = i
self.assertEqual(part.get_payload(decode=True), event.getTextContent())
self.assertEqual(part.get_payload(decode=True).decode(), event.getTextContent())
# Check attachment
# pdf
......@@ -1297,7 +1298,7 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_filename()==filename:
part = i
self.assertEqual(part.get_payload(decode=True), str(document.getData()))
self.assertEqual(part.get_payload(decode=True), bytes(document.getData()))
def test_MailAttachmentText(self):
"""
......@@ -1334,7 +1335,7 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_content_type()=='text/plain':
part = i
self.assertEqual(part.get_payload(decode=True), event.getTextContent())
self.assertEqual(part.get_payload(decode=True).decode(), event.getTextContent())
# Check attachment
# odt
......@@ -1379,7 +1380,7 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_content_type()=='text/plain':
part = i
self.assertEqual(part.get_payload(decode=True), event.getTextContent())
self.assertEqual(part.get_payload(decode=True).decode(), event.getTextContent())
# Check attachment
# zip
......@@ -1426,7 +1427,7 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_content_type()=='text/plain':
part = i
self.assertEqual(part.get_payload(decode=True), event.getTextContent())
self.assertEqual(part.get_payload(decode=True).decode(), event.getTextContent())
# Check attachment
# gif
......@@ -1436,7 +1437,7 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_filename() == filename:
part = i
self.assertEqual(part.get_payload(decode=True), str(document.getData()))
self.assertEqual(part.get_payload(decode=True), bytes(document.getData()))
def test_MailAttachmentWebPage(self):
"""
......@@ -1445,7 +1446,7 @@ class TestCRMMailSend(BaseTestCRM):
# Add a document which will be attached.
filename = 'sample_attachment.html'
document = self.portal.portal_contributions.newContent(
data='<html><body>Hello world!</body></html>',
data=b'<html><body>Hello world!</body></html>',
filename=filename)
self.tic()
......@@ -1473,7 +1474,7 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_content_type()=='text/plain':
part = i
self.assertEqual(part.get_payload(decode=True), event.getTextContent())
self.assertEqual(part.get_payload(decode=True).decode(), event.getTextContent())
# Check attachment
# html
......@@ -1484,7 +1485,7 @@ class TestCRMMailSend(BaseTestCRM):
if i.get_filename() == filename:
part = i
self.assertEqual(part.get_payload(decode=True),
str(document.getTextContent()))
document.getTextContent())
self.assertEqual(part.get_content_type(), 'text/html')
def test_AttachPdfToMailUsingNewEventDialog(self):
......@@ -1524,7 +1525,7 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_content_type()=='text/plain':
part = i
self.assertEqual(part.get_payload(decode=True), event.getTextContent())
self.assertEqual(part.get_payload(decode=True).decode(), event.getTextContent())
# Check attachment
# pdf
......@@ -1534,7 +1535,7 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_filename()==filename:
part = i
self.assertEqual(part.get_payload(decode=True), str(document.getData()))
self.assertEqual(part.get_payload(decode=True), bytes(document.getData()))
def test_AttachFileToMailUsingNewEventDialog(self):
"""
......@@ -1572,7 +1573,7 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_content_type()=='text/plain':
part = i
self.assertEqual(part.get_payload(decode=True), event.getTextContent())
self.assertEqual(part.get_payload(decode=True).decode(), event.getTextContent())
# Check attachment
# zip
......@@ -1586,7 +1587,7 @@ class TestCRMMailSend(BaseTestCRM):
def test_testValidatorForAttachmentField(self):
"""
If an Event Type doesn't allow Emebedded Files in its sub portal types,
If an Event Type doesn't allow Embedded Files in its sub portal types,
then the dialog should tell the user that attachment can't be uploaded
"""
# Add a document which will be attached.
......@@ -1704,7 +1705,7 @@ class TestCRMMailSend(BaseTestCRM):
if i.get_content_type()=='text/plain':
part = i
break
self.assertEqual(part.get_payload(decode=True), event.getTextContent())
self.assertEqual(part.get_payload(decode=True).decode(), event.getTextContent())
# Check attachment
# txt
......@@ -1761,7 +1762,7 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_content_type()=='text/plain':
part = i
self.assertEqual(part.get_payload(decode=True), event.getTextContent())
self.assertEqual(part.get_payload(decode=True).decode(), event.getTextContent())
# Check attachment
# gif
......@@ -1771,11 +1772,11 @@ class TestCRMMailSend(BaseTestCRM):
for i in message.get_payload():
if i.get_filename() == filename:
part = i
self.assertEqual(part.get_payload(decode=True), str(document_gif.getData()))
self.assertEqual(part.get_payload(decode=True), bytes(document_gif.getData()))
def test_cloneEvent(self):
"""
All events uses after script and interaciton
All events uses after script and interaction
workflow add a test for clone
"""
# XXX in the case of title, getTitle ignores the title attribute,
......@@ -1808,7 +1809,7 @@ class TestCRMMailSend(BaseTestCRM):
def test_cloneTicketAndEventList(self):
"""
All events uses after script and interaciton
All events uses after script and interaction
workflow add a test for clone
"""
portal = self.portal
......@@ -2034,7 +2035,7 @@ class TestCRMMailSend(BaseTestCRM):
attachment_list=[])
self.tic()
(from_url, to_url, last_message,), = self.portal.MailHost._message_list
self.assertIn("Body Simple Case", last_message)
self.assertIn(b"Body Simple Case", last_message)
self.assertEqual('FG ER <eee@eee.com>', from_url)
self.assertEqual(['Expert User <expert@in24.test>'], to_url)
......
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