Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Restore cc/bcc only support and add test from Chris:

  • Loading branch information...
commit fb2a0136ab7ab7e5d505faed117a5f67f7caa51a 1 parent 3586e74
@rpatterson rpatterson authored
Showing with 21 additions and 8 deletions.
  1. +0 −4 pyramid_mailer/message.py
  2. +21 −4 pyramid_mailer/tests.py
View
4 pyramid_mailer/message.py
@@ -139,10 +139,6 @@ def validate(self):
if not (self.recipients or self.cc or self.bcc):
raise InvalidMessage("No recipients have been added")
- if (self.cc or self.bcc) and not self.recipients:
- raise InvalidMessage("Must have at least one direct recipient "
- "even if cc or bcc set")
-
if not self.body and not self.html:
raise InvalidMessage("No body has been set")
View
25 pyramid_mailer/tests.py
@@ -168,8 +168,22 @@ def test_cc_without_recipients(self):
body="testing",
cc=["tosomeoneelse@example.com"])
mailer = Mailer()
- from pyramid_mailer.exceptions import InvalidMessage
- self.assertRaises(InvalidMessage, mailer.send, msg)
+ msgid = mailer.send(msg)
+ response = msg.get_response()
+
+ self.assertTrue("Cc: tosomeoneelse@example.com" in str(response))
+ self.assertTrue(msgid)
+
+ def test_cc_without_recipients_2(self):
+
+ from pyramid_mailer.message import Message
+
+ msg = Message(subject="testing",
+ sender="sender@example.com",
+ body="testing",
+ cc=["tosomeoneelse@example.com"])
+ response = msg.get_response()
+ self.assertTrue("Cc: tosomeoneelse@example.com" in str(response))
def test_bcc_without_recipients(self):
@@ -181,8 +195,11 @@ def test_bcc_without_recipients(self):
body="testing",
bcc=["tosomeoneelse@example.com"])
mailer = Mailer()
- from pyramid_mailer.exceptions import InvalidMessage
- self.assertRaises(InvalidMessage, mailer.send, msg)
+ msgid = mailer.send(msg)
+ response = msg.get_response()
+
+ self.assertFalse("Bcc: tosomeoneelse@example.com" in str(response))
+ self.assertTrue(msgid)
def test_attach(self):
Please sign in to comment.
Something went wrong with that request. Please try again.