changeset d44bb0b91dde in trytond:4.6
details: https://hg.tryton.org/trytond?cmd=changeset;node=d44bb0b91dde
description:
Use MagicMock for message when testing sendmail
Since issue8596, sendmail test message contains Date header so message
must
implement the magic method.
(grafted from 464864aedc0460dd6717d6197eb736bfa2433169)
diffstat:
trytond/tests/test_sendmail.py | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diffs (51 lines):
diff -r 8584fb74574b -r d44bb0b91dde trytond/tests/test_sendmail.py
--- a/trytond/tests/test_sendmail.py Fri Aug 30 09:08:32 2019 +0200
+++ b/trytond/tests/test_sendmail.py Fri Aug 30 11:32:32 2019 +0200
@@ -4,7 +4,7 @@
import smtplib
import sys
from email.message import Message
-from mock import Mock, patch, call
+from mock import Mock, MagicMock, patch, call
from trytond.sendmail import (
sendmail_transactional, sendmail, SMTPDataManager, get_smtp_server)
@@ -22,7 +22,7 @@
@with_transaction()
def test_sendmail_transactional(self):
'Test sendmail_transactional'
- message = Mock()
+ message = MagicMock()
datamanager = Mock()
sendmail_transactional(
'[email protected]', '[email protected]', message,
@@ -33,7 +33,7 @@
def test_sendmail(self):
'Test sendmail'
- message = Mock()
+ message = MagicMock()
server = Mock()
sendmail(
'[email protected]', '[email protected]', message, server=server)
@@ -91,8 +91,8 @@
# multiple join must return the same
self.assertEqual(transaction.join(SMTPDataManager()), datamanager)
- msg1 = Mock(Message)
- msg2 = Mock(Message)
+ msg1 = MagicMock(Message)
+ msg2 = MagicMock(Message)
datamanager.put('[email protected]', '[email protected]', msg1)
datamanager.put('[email protected]', '[email protected]', msg2)
@@ -107,7 +107,8 @@
server.reset_mock()
- datamanager.put('[email protected]', '[email protected]', Mock(Message))
+ datamanager.put(
+ '[email protected]', '[email protected]', MagicMock(Message))
transaction.rollback()
server.sendmail.assert_not_called()