예제 #1
0
 def test_multipartWithHtmlIsInjected(self):
   msg = MIMEMultipart('alternative')
   msg['From'] = '*****@*****.**'
   text = MIMEText("Test")    
   html = MIMEText("<html><body>Test</body></html>",'html')
   msg.attach(text)
   msg.attach(html)
   
   newMessage = SugarMessageProcessor(self.authUser).process(msg,"category")
   
   self.assertEquals(2, len(newMessage.get_payload()))
   self.assertTrue('</img>' in newMessage.get_payload()[1].get_payload())
예제 #2
0
 def test_AdvertisingFooterIsNotInjectedIntoPayingCustomer(self):
   msg = MIMEText("Test1") 
   msg['From'] = '*****@*****.**'
   
   profile = self.authUser.get_profile()
   profile.customer_level = CUSTOMER_LEVEL_FREE + 1
   profile.save()
   newMessage = SugarMessageProcessor(self.authUser).process(msg,"category")
   
   self.assertEquals(2, len(newMessage.get_payload()))
   last_payload = newMessage.get_payload()[1]
   
   self.assertFalse('<img alt=\"Mail Receipts\"' in last_payload.get_payload())
예제 #3
0
 def test_multipartWithTextIsInjected(self):
   msg = MIMEMultipart('alternative')
   msg['From'] = '*****@*****.**'
   text1 = MIMEText("Test1")    
   text2 = MIMEText("Test2")
   msg.attach(text1)
   msg.attach(text2)
   
   newMessage = SugarMessageProcessor(self.authUser).process(msg,"category")
   
   self.assertEquals(3, len(newMessage.get_payload()))
   last_payload = newMessage.get_payload()[2]
   
   self.assertTrue('</img>' in last_payload.get_payload())
   self.assertTrue('Test2' in last_payload.get_payload())
예제 #4
0
 def test_htmlMessagesAreInjected(self):
   msg = MIMEText("<html><body>Test</body></html>",'html')    
   msg['From'] = '*****@*****.**'
   newMessage = SugarMessageProcessor(self.authUser).process(msg,"category")
   
   self.assertEquals('text/html', newMessage.get_content_type())
   self.assertTrue("</img>" in newMessage.get_payload())
예제 #5
0
 def test_textMessagesConvertedToMultipart(self):
   msg = MIMEText("Test")    
   msg['From'] = '*****@*****.**'
   newMessage = SugarMessageProcessor(self.authUser).process(msg,"category")
   
   self.assertEquals('multipart/alternative', newMessage.get_content_type())
   self.assertEquals(2, len(newMessage.get_payload()))
예제 #6
0
 def test_textMessagesAreInjected(self):
   msg = MIMEText("Test")    
   msg['From'] = '*****@*****.**'
   newMessage = SugarMessageProcessor(self.authUser).process(msg,"category")
   
   self.assertEquals('multipart/alternative', newMessage.get_content_type())
   last_payload = newMessage.get_payload()[1]
   
   self.assertEquals('text/html', last_payload.get_content_type())
   self.assertTrue("</img>" in last_payload.get_payload())