Example #1
0
    def test_create_message_html(self):
        """
    	Tests if an email is created in html with specified fields
        """
    	email_msg = shortcuts._create_message('test_subject', None, '<span>test_html</span>',
    	"*****@*****.**", ["*****@*****.**"], None)

	self.assertEqual(email_msg.body, '')
	self.assertEqual(email_msg.alternatives, [('<span>test_html</span>', 'text/html')])
Example #2
0
    def test_create_message_html_and_plain_text(self):

	"""
	Tests if an email is created in html and plaintext with specified fields
	"""
	email_msg = shortcuts._create_message('test_subject', 'test_plain', 'test_html',
	"*****@*****.**", ["*****@*****.**"], None)

	self.assertEqual(email_msg.body, 'test_plain')
	self.assertEqual(email_msg.alternatives, [('test_html', 'text/html')])
Example #3
0
    def test_create_message_plaintext(self):
    	"""
    	Tests if an email is created with plaintext only
    	"""

    	email_msg = shortcuts._create_message('test_subject', 'test_plain', None,
        	"*****@*****.**", ["*****@*****.**"], None)

    	self.assertEqual(email_msg.body, 'test_plain')
    	self.assertEqual(email_msg.attachments, [])
Example #4
0
 def test__create_message_plaintext(self):
     """
     Tests that messages created with only plaintext will have all of the 
     proper fields.
     """
     
     message = shortcuts._create_message("This is a subject", 
         "This is a plaintext message", None, "*****@*****.**", 
         ["*****@*****.**"], ["*****@*****.**"], 
         ["*****@*****.**"])
     self.assertEqual(message.subject, "This is a subject")
     self.assertEqual(message.body, "This is a plaintext message")
     self.assertEqual(message.from_email, "*****@*****.**")
     self.assertEqual(message.to, ["*****@*****.**"])
     self.assertEqual(message.cc, ["*****@*****.**"])
     self.assertEqual(message.bcc, ["*****@*****.**"])
     self.assertEqual(message.attachments, [])
Example #5
0
    def test__create_message_html(self):
        """
        Tests that messages created with html will have all of the proper fields
        and the body should be empty because _create_message is not responsible
        for creating a plaintext body from an html message. 
        """

        message = shortcuts._create_message("This is a subject", 
            None, u"<span>This is an html message</span>", "*****@*****.**",
            ["*****@*****.**"], ["*****@*****.**"],     
            ["*****@*****.**"])
        self.assertEqual(message.subject, "This is a subject")
        self.assertEqual(message.body, '')
        self.assertEqual(message.from_email, "*****@*****.**")
        self.assertEqual(message.to, ["*****@*****.**"])
        self.assertEqual(message.cc, ["*****@*****.**"])
        self.assertEqual(message.bcc, ["*****@*****.**"])
        self.assertEqual(message.attachments, [])
        self.assertEqual(message.alternatives[0], 
           (u"<span>This is an html message</span>", "text/html"))