Commit 67d64e37 authored by Rafael Monnerat's avatar Rafael Monnerat

Only decode into getMessageList() and keep the mail message text intact...

Only decode into getMessageList() and keep the mail message text intact because some tests expect it. Optionally, the original messages can be get by getMessageList(decode=False) instead access _message_list.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30479 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 34f003f9
...@@ -61,16 +61,21 @@ class DummyMailHost(MailHost): ...@@ -61,16 +61,21 @@ class DummyMailHost(MailHost):
_message_list = [] _message_list = []
def _send( self, mfrom, mto, messageText ): def _send( self, mfrom, mto, messageText ):
"""Record message in _last_message.""" """Record message in _last_message."""
self._previous_message = self._last_message
self._last_message = (mfrom, mto, messageText)
self._message_list.append(self._last_message)
def _decodeMessage(self, messageText):
""" Decode message"""
message_text = messageText message_text = messageText
for part in message_from_string(messageText).walk(): for part in message_from_string(messageText).walk():
if part.get_content_type() in ['text/plain', 'text/html' ] \ if part.get_content_type() in ['text/plain', 'text/html' ] \
and not part.is_multipart(): and not part.is_multipart():
message_text = part.get_payload(decode=1) message_text = part.get_payload(decode=1)
self._previous_message = self._last_message return message_text
self._last_message = (mfrom, mto, message_text) def getMessageList(self, decode=True):
self._message_list.append(self._last_message)
def getMessageList(self):
""" Return message list""" """ Return message list"""
if decode:
return [ (m[0], m[1], self._decodeMessage(m[2])) for m in self._message_list]
return self._message_list return self._message_list
class DummyTranslationService: class DummyTranslationService:
......
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