summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
Diffstat (limited to 'service/test')
-rw-r--r--service/test/integration/test_leap_mailstore.py78
-rw-r--r--service/test/support/integration/model.py3
-rw-r--r--service/test/unit/adapter/mailstore/test_leap_mail.py102
-rw-r--r--service/test/unit/adapter/services/test_mail_sender.py6
-rw-r--r--service/test/unit/adapter/test_draft_service.py2
-rw-r--r--service/test/unit/adapter/test_mail.py16
-rw-r--r--service/test/unit/adapter/test_mail_service.py8
-rw-r--r--service/test/unit/support/test_replier.py42
8 files changed, 59 insertions, 198 deletions
diff --git a/service/test/integration/test_leap_mailstore.py b/service/test/integration/test_leap_mailstore.py
index e28fbe5d..885aa62b 100644
--- a/service/test/integration/test_leap_mailstore.py
+++ b/service/test/integration/test_leap_mailstore.py
@@ -32,7 +32,7 @@ class LeapMailStoreTest(SoledadTestBase):
self.maxDiff = None
mail = load_mail_from_file('mbox00000000')
mail_id = yield self._create_mail_in_soledad(mail)
- expected_mail_dict = {'body': u'Dignissimos ducimus veritatis. Est tenetur consequatur quia occaecati. Vel sit sit voluptas.\n\nEarum distinctio eos. Accusantium qui sint ut quia assumenda. Facere dignissimos inventore autem sit amet. Pariatur voluptatem sint est.\n\nUt recusandae praesentium aspernatur. Exercitationem amet placeat deserunt quae consequatur eum. Unde doloremque suscipit quia.\n\n', 'header': {u'date': u'Tue, 21 Apr 2015 08:43:27 +0000 (UTC)', u'to': [u'carmel@murazikortiz.name'], u'x-tw-pixelated-tags': u'nite, macro, trash', u'from': u'darby.senger@zemlak.biz', u'subject': u'Itaque consequatur repellendus provident sunt quia.'}, 'ident': mail_id, 'status': [], 'tags': set([]), 'replying': {'all': {'cc-field': [], 'to-field': [u'carmel@murazikortiz.name', u'darby.senger@zemlak.biz']}, 'single': u'darby.senger@zemlak.biz'}, 'textPlainBody': u'Dignissimos ducimus veritatis. Est tenetur consequatur quia occaecati. Vel sit sit voluptas.\n\nEarum distinctio eos. Accusantium qui sint ut quia assumenda. Facere dignissimos inventore autem sit amet. Pariatur voluptatem sint est.\n\nUt recusandae praesentium aspernatur. Exercitationem amet placeat deserunt quae consequatur eum. Unde doloremque suscipit quia.\n\n', 'mailbox': u'inbox', 'attachments': [], 'security_casing': {'imprints': [{'state': 'no_signature_information'}], 'locks': []}}
+ expected_mail_dict = {'body': u'Dignissimos ducimus veritatis. Est tenetur consequatur quia occaecati. Vel sit sit voluptas.\n\nEarum distinctio eos. Accusantium qui sint ut quia assumenda. Facere dignissimos inventore autem sit amet. Pariatur voluptatem sint est.\n\nUt recusandae praesentium aspernatur. Exercitationem amet placeat deserunt quae consequatur eum. Unde doloremque suscipit quia.\n\n', 'header': {u'date': u'Tue, 21 Apr 2015 08:43:27 +0000 (UTC)', u'to': [u'carmel@murazikortiz.name'], u'x-tw-pixelated-tags': u'nite, macro, trash', u'from': u'darby.senger@zemlak.biz', u'subject': u'Itaque consequatur repellendus provident sunt quia.'}, 'ident': mail_id, 'status': [], 'tags': set([]), 'textPlainBody': u'Dignissimos ducimus veritatis. Est tenetur consequatur quia occaecati. Vel sit sit voluptas.\n\nEarum distinctio eos. Accusantium qui sint ut quia assumenda. Facere dignissimos inventore autem sit amet. Pariatur voluptatem sint est.\n\nUt recusandae praesentium aspernatur. Exercitationem amet placeat deserunt quae consequatur eum. Unde doloremque suscipit quia.\n\n', 'mailbox': u'inbox', 'attachments': [], 'security_casing': {'imprints': [{'state': 'no_signature_information'}], 'locks': []}}
result = yield self.mail_store.get_mail(mail_id, include_body=True)
self.assertIsNotNone(result)
@@ -109,83 +109,7 @@ class LeapMailStoreTest(SoledadTestBase):
self.assertEqual(mail.mail_id, mails[0])
@defer.inlineCallbacks
- def test_get_replying_when_sender_is_not_me(self):
- InputMail.FROM_EMAIL_ADDRESS = 'me@pixelated.org'
- mail = load_mail_from_file('mbox00000000')
- del mail['From']
- del mail['To']
- del mail['Cc']
- mail['From'] = 'not-me@pixelated.org'
- mail['To'] = 'addr1@pixelated.org, addr2@pixelated.org'
-
- yield self.mail_store.add_mailbox('INBOX')
- mail = yield self.mail_store.add_mail('INBOX', mail.as_string())
-
- replying = mail.as_dict()['replying']
-
- self.assertEqual(replying['single'], 'not-me@pixelated.org')
- self.assertEqual(replying['all']['to-field'], [u'addr1@pixelated.org', u'addr2@pixelated.org', u'not-me@pixelated.org'])
- self.assertListEqual(replying['all']['cc-field'], [])
-
- @defer.inlineCallbacks
- def test_get_replying_when_sender_is_me(self):
- InputMail.FROM_EMAIL_ADDRESS = 'me@pixelated.org'
- mail = load_mail_from_file('mbox00000000')
- del mail['From']
- del mail['To']
- del mail['Cc']
- mail['From'] = 'me@pixelated.org'
- mail['To'] = 'addr1@pixelated.org, addr2@pixelated.org'
-
- yield self.mail_store.add_mailbox('INBOX')
- mail = yield self.mail_store.add_mail('INBOX', mail.as_string())
-
- replying = mail.as_dict()['replying']
-
- self.assertEqual(replying['single'], 'me@pixelated.org')
- self.assertEqual(replying['all']['to-field'], [u'addr1@pixelated.org', u'addr2@pixelated.org'])
- self.assertEqual(replying['all']['cc-field'], [])
-
- @defer.inlineCallbacks
- def test_get_replying_when_sender_is_me_to_me(self):
- InputMail.FROM_EMAIL_ADDRESS = 'me@pixelated.org'
- mail = load_mail_from_file('mbox00000000')
- del mail['From']
- del mail['To']
- del mail['Cc']
- mail['From'] = 'me@pixelated.org'
- mail['To'] = 'me@pixelated.org'
-
- yield self.mail_store.add_mailbox('INBOX')
- mail = yield self.mail_store.add_mail('INBOX', mail.as_string())
-
- replying = mail.as_dict()['replying']
-
- self.assertEqual(replying['single'], 'me@pixelated.org')
- self.assertEqual(replying['all']['to-field'], [u'me@pixelated.org'])
- self.assertEqual(replying['all']['cc-field'], [])
-
- @defer.inlineCallbacks
- def test_get_replying_when_sender_is_me_to_recipients_including_me(self):
- InputMail.FROM_EMAIL_ADDRESS = 'me@pixelated.org'
- mail = load_mail_from_file('mbox00000000')
- del mail['From']
- del mail['To']
- del mail['Cc']
- mail['From'] = 'me@pixelated.org'
- mail['To'] = 'addr1@pixelated.org, me@pixelated.org'
-
- yield self.mail_store.add_mailbox('INBOX')
- mail = yield self.mail_store.add_mail('INBOX', mail.as_string())
- replying = mail.as_dict()['replying']
-
- self.assertEqual(replying['single'], 'me@pixelated.org')
- self.assertEqual(replying['all']['to-field'], [u'addr1@pixelated.org'])
- self.assertEqual(replying['all']['cc-field'], [])
-
- @defer.inlineCallbacks
def test_deleting_a_deleted_mail_doesnt_raise_errors(self):
- InputMail.FROM_EMAIL_ADDRESS = 'me@pixelated.org'
mail = load_mail_from_file('mbox00000000')
yield self.mail_store.add_mailbox('INBOX')
mail = yield self.mail_store.add_mail('INBOX', mail.as_string())
diff --git a/service/test/support/integration/model.py b/service/test/support/integration/model.py
index c6f6a754..87a18af6 100644
--- a/service/test/support/integration/model.py
+++ b/service/test/support/integration/model.py
@@ -33,7 +33,6 @@ class MailBuilder:
'body': "Hello,\nThis is the body of this message\n\nRegards,\n\n--\nPixelated.\n",
'status': []
}
- InputMail.FROM_EMAIL_ADDRESS = 'Formatted Sender <sender@from.com>'
def with_body(self, body):
self.mail['body'] = body
@@ -80,7 +79,7 @@ class MailBuilder:
return json.dumps(self.mail)
def build_input_mail(self):
- return InputMail.from_dict(self.mail)
+ return InputMail.from_dict(self.mail, from_address='Formatted Sender <sender@from.com>')
def build_leap_mail(self):
return LeapMail.from_dict(self.mail)
diff --git a/service/test/unit/adapter/mailstore/test_leap_mail.py b/service/test/unit/adapter/mailstore/test_leap_mail.py
index 91e960e1..cd8852ad 100644
--- a/service/test/unit/adapter/mailstore/test_leap_mail.py
+++ b/service/test/unit/adapter/mailstore/test_leap_mail.py
@@ -68,11 +68,6 @@ class TestLeapMail(TestCase):
'imprints': [{'state': 'no_signature_information'}],
'locks': []
},
- 'replying': {'all': {'cc-field': [],
- 'to-field': ['receiver@example.test',
- 'test@example.test',
- 'receiver2@other.test']},
- 'single': 'test@example.test'},
'attachments': []
}
@@ -105,103 +100,6 @@ class TestLeapMail(TestCase):
self.assertEqual([expected_address], mail.as_dict()['header']['cc'])
self.assertEqual(expected_subject, mail.as_dict()['header']['subject'])
- def test_as_dict_replying_with_special_chars(self):
- expected_address = u'"\xc4lbert \xdcbr\xf6" <\xe4\xfc\xf6@example.mail>'
- mail = LeapMail('', 'INBOX',
- {'From': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
- 'To': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
- 'Cc': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
- 'Subject': '=?iso-8859-1?q?H=E4ll=F6_W=F6rld?='})
- self.assertEqual([expected_address], mail.as_dict()['replying']['all']['to-field'])
- self.assertEqual([expected_address], mail.as_dict()['replying']['all']['cc-field'])
- self.assertEqual(expected_address, mail.as_dict()['replying']['single'])
-
- def test_reply_all_result_does_not_contain_own_address_in_to_with_spaces(self):
- my_address = 'myaddress@example.test'
-
- with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
- mail = LeapMail('', 'INBOX',
- {'From': 'test@example.test',
- 'To': 'receiver@example.test, %s ' % my_address})
- expected_recipients = ['receiver@example.test', 'test@example.test']
- actual_recipients = mail.as_dict()['replying']['all']['to-field']
- expected_recipients.sort()
- actual_recipients.sort()
-
- self.assertEqual(expected_recipients, actual_recipients)
-
- def test_reply_all_result_does_not_contain_own_address_in_to_with_name(self):
- my_address = 'myaddress@example.test'
-
- with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
- mail = LeapMail('', 'INBOX',
- {'From': 'test@example.test',
- 'To': 'receiver@example.test, Folker Bernitt <%s>' % my_address})
-
- expected_recipients = ['receiver@example.test', 'test@example.test']
- actual_recipients = mail.as_dict()['replying']['all']['to-field']
- expected_recipients.sort()
- actual_recipients.sort()
-
- self.assertEqual(expected_recipients, actual_recipients)
-
- # TODO: fix this test
- def test_reply_all_does_not_contain_own_address_in_to_field_with_different_encodings(self):
- my_address = 'myaddress@example.test'
-
- with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
- mail = LeapMail('', 'INBOX',
- {'From': 'test@example.test',
- 'To': 'receiver@example.test, =?iso-8859-1?q?=C4lbert_=3Cmyaddress=40example=2Etest=3E?='})
-
- expected_recipients = [u'receiver@example.test', u'test@example.test']
- actual_recipients = mail.as_dict()['replying']['all']['to-field']
- expected_recipients.sort()
- actual_recipients.sort()
-
- self.assertEqual(expected_recipients, actual_recipients)
-
- def test_reply_all_result_does_not_contain_own_address_in_cc(self):
- my_address = 'myaddress@example.test'
-
- with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
- mail = LeapMail('', 'INBOX',
- {'From': 'test@example.test',
- 'To': 'receiver@example.test',
- 'Cc': my_address})
-
- self.assertEqual([my_address], mail.as_dict()['replying']['all']['cc-field'])
-
- def test_reply_all_result_does_not_contain_own_address_if_sender(self):
- my_address = 'myaddress@example.test'
-
- with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
- mail = LeapMail('', 'INBOX',
- {'From': 'myaddress@example.test',
- 'To': 'receiver@example.test'})
-
- self.assertEqual(['receiver@example.test'], mail.as_dict()['replying']['all']['to-field'])
-
- def test_reply_all_result_does_contain_own_address_if_only_recipient(self):
- my_address = 'myaddress@example.test'
-
- with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
- mail = LeapMail('', 'INBOX',
- {'From': 'myaddress@example.test',
- 'To': 'myaddress@example.test'})
-
- self.assertEqual(['myaddress@example.test'], mail.as_dict()['replying']['all']['to-field'])
-
- def test_reply_result_swaps_sender_and_recipient_if_i_am_the_sender(self):
- my_address = 'myaddress@example.test'
-
- with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
- mail = LeapMail('', 'INBOX',
- {'From': 'myaddress@example.test',
- 'To': 'recipient@example.test'})
-
- self.assertEqual('myaddress@example.test', mail.as_dict()['replying']['single'])
-
def test_as_dict_with_mixed_encodings(self):
subject = 'Another test with =?iso-8859-1?B?3G1s5Px0?= =?iso-8859-1?Q?s?='
mail = LeapMail('', 'INBOX',
diff --git a/service/test/unit/adapter/services/test_mail_sender.py b/service/test/unit/adapter/services/test_mail_sender.py
index cd4a84c3..9a7e8fea 100644
--- a/service/test/unit/adapter/services/test_mail_sender.py
+++ b/service/test/unit/adapter/services/test_mail_sender.py
@@ -67,7 +67,7 @@ class MailSenderTest(unittest.TestCase):
@defer.inlineCallbacks
def test_iterates_over_recipients(self):
- input_mail = InputMail.from_dict(mail_dict())
+ input_mail = InputMail.from_dict(mail_dict(), from_address='pixelated@org')
when(OutgoingMail).send_message(any(), any()).thenReturn(defer.succeed(None))
@@ -78,7 +78,7 @@ class MailSenderTest(unittest.TestCase):
@defer.inlineCallbacks
def test_problem_with_email_raises_exception(self):
- input_mail = InputMail.from_dict(mail_dict())
+ input_mail = InputMail.from_dict(mail_dict(), from_address='pixelated@org')
when(OutgoingMail).send_message(any(), any()).thenReturn(defer.fail(Exception('pretend something went wrong')))
@@ -91,7 +91,7 @@ class MailSenderTest(unittest.TestCase):
@defer.inlineCallbacks
def test_iterates_over_recipients_and_send_whitout_bcc_field(self):
- input_mail = InputMail.from_dict(mail_dict())
+ input_mail = InputMail.from_dict(mail_dict(), from_address='pixelated@org')
bccs = input_mail.bcc
when(OutgoingMail).send_message(any(), any()).thenReturn(defer.succeed(None))
diff --git a/service/test/unit/adapter/test_draft_service.py b/service/test/unit/adapter/test_draft_service.py
index bf5e18c5..c2516013 100644
--- a/service/test/unit/adapter/test_draft_service.py
+++ b/service/test/unit/adapter/test_draft_service.py
@@ -22,7 +22,7 @@ class DraftServiceTest(unittest.TestCase):
verify(self.mail_store).add_mail('DRAFTS', mail.raw)
def test_update_draft(self):
- mail = InputMail.from_dict(test_helper.mail_dict())
+ mail = InputMail.from_dict(test_helper.mail_dict(), from_address='pixelated@org')
when(self.mail_store).delete_mail(mail.ident).thenReturn(defer.succeed(True))
when(self.mail_store).add_mail('DRAFTS', mail.raw).thenReturn(defer.succeed(LeapMail('id', 'DRAFTS')))
diff --git a/service/test/unit/adapter/test_mail.py b/service/test/unit/adapter/test_mail.py
index 6e4943fa..d66eddd9 100644
--- a/service/test/unit/adapter/test_mail.py
+++ b/service/test/unit/adapter/test_mail.py
@@ -81,7 +81,7 @@ class InputMailTest(unittest.TestCase):
mail_dict['header']['cc'] = ''
mail_dict['header']['subject'] = ''
- mime_multipart = InputMail.from_dict(mail_dict).to_mime_multipart()
+ mime_multipart = InputMail.from_dict(mail_dict, from_address='pixelated@org').to_mime_multipart()
self.assertNotRegexpMatches(mime_multipart.as_string(), "\nTo: \n")
self.assertNotRegexpMatches(mime_multipart.as_string(), "\nBcc: \n")
@@ -99,14 +99,14 @@ class InputMailTest(unittest.TestCase):
}
}
- result = InputMail.from_dict(mail_single_recipient).raw
+ result = InputMail.from_dict(mail_single_recipient, from_address='pixelated@org').raw
self.assertRegexpMatches(result, 'To: to@pixelated.org')
def test_to_mime_multipart(self):
pixelated.support.date.mail_date_now = lambda: 'date now'
- mime_multipart = InputMail.from_dict(simple_mail_dict()).to_mime_multipart()
+ mime_multipart = InputMail.from_dict(simple_mail_dict(), from_address='pixelated@org').to_mime_multipart()
self.assertRegexpMatches(mime_multipart.as_string(), "\nTo: to@pixelated.org, anotherto@pixelated.org\n")
self.assertRegexpMatches(mime_multipart.as_string(), "\nCc: cc@pixelated.org, anothercc@pixelated.org\n")
@@ -120,20 +120,18 @@ class InputMailTest(unittest.TestCase):
mail_dict['header']['to'] = u'"Älbert Übrö \xF0\x9F\x92\xA9" <äüö@example.mail>'
pixelated.support.date.mail_date_now = lambda: 'date now'
- mime_multipart = InputMail.from_dict(mail_dict).to_mime_multipart()
+ mime_multipart = InputMail.from_dict(mail_dict, from_address='pixelated@org').to_mime_multipart()
expected_part_of_encoded_to = 'Iiwgw4QsIGwsIGIsIGUsIHIsIHQsICAsIMOcLCBiLCByLCDDtiwgICwgw7As'
self.assertRegexpMatches(mime_multipart.as_string(), expected_part_of_encoded_to)
def test_smtp_format(self):
- InputMail.FROM_EMAIL_ADDRESS = 'pixelated@org'
-
- smtp_format = InputMail.from_dict(simple_mail_dict()).to_smtp_format()
+ smtp_format = InputMail.from_dict(simple_mail_dict(), from_address='pixelated@org').to_smtp_format()
self.assertRegexpMatches(smtp_format, "\nFrom: pixelated@org")
def test_to_mime_multipart_handles_alternative_bodies(self):
- mime_multipart = InputMail.from_dict(multipart_mail_dict()).to_mime_multipart()
+ mime_multipart = InputMail.from_dict(multipart_mail_dict(), from_address='pixelated@org').to_mime_multipart()
part_one = 'Content-Type: text/plain; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\n\nHello world!'
part_two = 'Content-Type: text/html; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\n\n<p>Hello html world!</p>'
@@ -142,7 +140,7 @@ class InputMailTest(unittest.TestCase):
self.assertRegexpMatches(mime_multipart.as_string(), part_two)
def test_raw_with_attachment_data(self):
- input_mail = InputMail.from_dict(with_attachment_mail_dict())
+ input_mail = InputMail.from_dict(with_attachment_mail_dict(), from_address='pixelated@org')
attachment = MIMENonMultipart('text', 'plain', Content_Disposition='attachment; filename=ayoyo.txt')
attachment.set_payload('Hello World')
diff --git a/service/test/unit/adapter/test_mail_service.py b/service/test/unit/adapter/test_mail_service.py
index 27c80fde..a8b6d597 100644
--- a/service/test/unit/adapter/test_mail_service.py
+++ b/service/test/unit/adapter/test_mail_service.py
@@ -45,7 +45,7 @@ class TestMailService(unittest.TestCase):
def test_send_mail(self):
input_mail = InputMail()
- when(InputMail).from_dict(ANY()).thenReturn(input_mail)
+ when(InputMail).from_dict(ANY(), ANY()).thenReturn(input_mail)
when(self.mail_sender).sendmail(ANY()).thenReturn(defer.Deferred())
sent_deferred = self.mail_service.send_mail(mail_dict())
@@ -60,7 +60,7 @@ class TestMailService(unittest.TestCase):
def test_send_mail_removes_draft(self):
mail = LeapMail('id', 'INBOX')
when(mail).raw = 'raw mail'
- when(InputMail).from_dict(ANY()).thenReturn(mail)
+ when(InputMail).from_dict(ANY(), ANY()).thenReturn(mail)
when(self.mail_store).delete_mail('12').thenReturn(defer.succeed(None))
when(self.mail_store).add_mail('SENT', ANY()).thenReturn(mail)
@@ -77,7 +77,7 @@ class TestMailService(unittest.TestCase):
def test_send_mail_marks_as_read(self):
mail = InputMail()
when(mail).raw = 'raw mail'
- when(InputMail).from_dict(ANY()).thenReturn(mail)
+ when(InputMail).from_dict(ANY(), ANY()).thenReturn(mail)
when(self.mail_store).delete_mail('12').thenReturn(defer.succeed(None))
when(self.mail_sender).sendmail(mail).thenReturn(defer.succeed(None))
@@ -93,7 +93,7 @@ class TestMailService(unittest.TestCase):
@defer.inlineCallbacks
def test_send_mail_does_not_delete_draft_on_error(self):
input_mail = InputMail()
- when(InputMail).from_dict(ANY()).thenReturn(input_mail)
+ when(InputMail).from_dict(ANY(), ANY()).thenReturn(input_mail)
deferred_failure = defer.fail(Exception("Assume sending mail failed"))
when(self.mail_sender).sendmail(ANY()).thenReturn(deferred_failure)
diff --git a/service/test/unit/support/test_replier.py b/service/test/unit/support/test_replier.py
new file mode 100644
index 00000000..5e1c234a
--- /dev/null
+++ b/service/test/unit/support/test_replier.py
@@ -0,0 +1,42 @@
+import unittest
+from pixelated.support import replier
+
+
+class TestReplier(unittest.TestCase):
+ def test_reply_all_dont_exclude_own_address_if_only_recipient(self):
+ current_user = sender = 'me@pixelated.org'
+ to = [sender]
+ cc = []
+
+ reply_dict = replier.generate_recipients(sender, to, cc, current_user)
+ expected = {'single': sender, 'all': {'to-field': [current_user], 'cc-field': []}}
+ self.assertEquals(expected, reply_dict)
+
+ def test_reply_all_does_not_contain_own_address_in_to(self):
+ current_user = 'me@pixelated.org'
+ sender = 'sender@pixelated.org'
+ to = ['test@pixelated.org', current_user]
+ cc = []
+
+ reply_dict = replier.generate_recipients(sender, to, cc, current_user)
+ expected = {'single': sender, 'all': {'to-field': ['test@pixelated.org', sender], 'cc-field': []}}
+ self.assertEquals(expected, reply_dict)
+
+ def test_reply_all_does_not_contain_own_address_in_cc(self):
+ current_user = 'me@pixelated.org'
+ sender = 'sender@pixelated.org'
+ to = ['test@pixelated.org']
+ cc = ['test2@pixelated.org', current_user]
+
+ reply_dict = replier.generate_recipients(sender, to, cc, current_user)
+ expected = {'single': sender, 'all': {'to-field': ['test@pixelated.org', sender], 'cc-field': ['test2@pixelated.org']}}
+ self.assertEquals(expected, reply_dict)
+
+ def test_reply_single_swaps_current_user_and_recipient_if_a_am_the_sender(self):
+ current_user = sender = 'me@pixelated.org'
+ to = ['test@pixelated.org']
+ cc = []
+
+ reply_dict = replier.generate_recipients(sender, to, cc, current_user)
+ expected = {'single': 'test@pixelated.org', 'all': {'to-field': ['test@pixelated.org'], 'cc-field': []}}
+ self.assertEquals(expected, reply_dict)