summaryrefslogtreecommitdiffstats
path: root/askbot/tests
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-11-06 23:02:23 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-11-06 23:02:23 -0300
commitc6105f36c41b39012a2c9edae193de24b0a9a176 (patch)
treeb0fb670ca71ae0f2e46b35bb70d59a1059c5f094 /askbot/tests
parentfc26b08ad98dd427ab882f8ec332dfdfea2ca9b2 (diff)
downloadaskbot-c6105f36c41b39012a2c9edae193de24b0a9a176.tar.gz
askbot-c6105f36c41b39012a2c9edae193de24b0a9a176.tar.bz2
askbot-c6105f36c41b39012a2c9edae193de24b0a9a176.zip
code for stripping email client quote separator and the corresponding test cases for some most common email clients
Diffstat (limited to 'askbot/tests')
-rw-r--r--askbot/tests/email_parsing_tests.py48
-rw-r--r--askbot/tests/reply_by_email_tests.py4
2 files changed, 31 insertions, 21 deletions
diff --git a/askbot/tests/email_parsing_tests.py b/askbot/tests/email_parsing_tests.py
index c1cea215..c8f3a057 100644
--- a/askbot/tests/email_parsing_tests.py
+++ b/askbot/tests/email_parsing_tests.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from django.conf import settings as django_settings
from askbot.skins.loaders import get_template
from django.template import Context
@@ -5,7 +6,7 @@ from askbot import mail
from askbot import models
from askbot.tests import utils
-class EmailParseTests(utils.AskbotTestCase):
+class EmailParsingTests(utils.AskbotTestCase):
def setUp(self):
self.template_name = 'email/welcome_lamson_on.html'
@@ -22,29 +23,38 @@ class EmailParseTests(utils.AskbotTestCase):
print '=================================================='
print cleaned_body
print "CLEANED BODY"
- self.assertEquals(cleaned_body, self.expected_output)
+ self.assertEqual(cleaned_body, self.expected_output)
def test_gmail_rich_text_response_stripped(self):
text = u'\n\nthis is my reply!\n\nOn Wed, Oct 31, 2012 at 1:45 AM, <kp@kp-dev.askbot.com> wrote:\n\n> **\n> '
- self.assertEqual(mail.extract_body(text), 'this is my reply!')
+ self.assertEqual(mail.extract_reply(text), 'this is my reply!')
- def test_gmail_plain_text_response_stripped(text):
+ def test_gmail_plain_text_response_stripped(self):
text = u'\n\nthis is my another reply!\n\nOn Wed, Oct 31, 2012 at 1:45 AM, <kp@kp-dev.askbot.com> wrote:\n>\n> '
- self.assertEqual(mail.extract_body(text), 'this is my another reply!')
+ self.assertEqual(mail.extract_reply(text), 'this is my another reply!')
def test_yahoo_mail_response_stripped(self):
text = u'\n\nthis is my reply!\n\n\n\n________________________________\n From: "kp@kp-dev.askbot.com" <kp@kp-dev.askbot.com>\nTo: fadeev@rocketmail.com \nSent: Wednesday, October 31, 2012 2:41 AM\nSubject: "This is my test question"\n \n\n \n \n \n'
- self.assertEqual(mail.extract_body(text), 'this is my reply!')
-
- def test_kmail_plain_text_response_stripped(text):
- text = u'On Monday 01 October 2012 21:22:44 you wrote: \n\nSecond try, no HTML kmail does weird things.'
- self.assertEqual(mail.extract_body(text), 'this is my reply!')
-
-
-u'outlook.com (new hotmail) with RTF on \n\nSubject: "Posting a question by email." \nFrom: kp@kp-dev.askbot.com \nTo: aj_fitoria@hotmail.com \nDate: Thu, 1 Nov 2012 16:30:27 +0000'
-
-u'reply from hotmail without RTF \n________________________________ \n> Subject: "test with recovered signature" \n> From: kp@kp-dev.askbot.com \n> To: aj_fitoria@hotmail.com \n> Date: Thu, 1 Nov 2012 16:44:35 +0000'
-
-u'Reply from squirremail \n'
-
-"""
+ self.assertEqual(mail.extract_reply(text), 'this is my reply!')
+
+ def test_kmail_plain_text_response_stripped(self):
+ text = u'On Monday 01 October 2012 21:22:44 you wrote: \n\nthis is my reply!'
+ self.assertEqual(mail.extract_reply(text), 'this is my reply!')
+
+ def test_outlook_com_with_rtf_response_stripped(self):
+ text = u'outlook.com (new hotmail) with RTF on \n\nSubject: "Posting a question by email." \nFrom: kp@kp-dev.askbot.com \nTo: aj_fitoria@hotmail.com \nDate: Thu, 1 Nov 2012 16:30:27 +0000'
+ self.assertEqual(
+ mail.extract_reply(text),
+ 'outlook.com (new hotmail) with RTF on'
+ )
+ self.assertEqual(
+ mail.extract_reply(text),
+ 'outlook.com (new hotmail) with RTF on'
+ )
+
+ def test_outlook_com_plain_text_response_stripped(self):
+ text = u'reply from hotmail without RTF \n________________________________ \n> Subject: "test with recovered signature" \n> From: kp@kp-dev.askbot.com \n> To: aj_fitoria@hotmail.com \n> Date: Thu, 1 Nov 2012 16:44:35 +0000'
+ self.assertEqual(
+ mail.extract_reply(text),
+ u'reply from hotmail without RTF'
+ )
diff --git a/askbot/tests/reply_by_email_tests.py b/askbot/tests/reply_by_email_tests.py
index 30cb48be..5353586c 100644
--- a/askbot/tests/reply_by_email_tests.py
+++ b/askbot/tests/reply_by_email_tests.py
@@ -84,8 +84,8 @@ class ReplyAddressModelTests(AskbotTestCase):
'instruction': 'reply above this line'
}
msg = MockMessage(
- "This is a test reply \n\nOn such and such someone"
- "wrote something \n\n%s\nlorem ipsum " % (reply_separator),
+ "This is a test reply \n\nOn such and such someone "
+ "wrote: \n\n%s\nlorem ipsum " % (reply_separator),
"user1@domain.com"
)
msg['Subject'] = 'test subject'