summaryrefslogtreecommitdiff
path: root/service/test/unit/support
diff options
context:
space:
mode:
authorGiovane <giovaneliberato@gmail.com>2016-01-14 18:34:00 -0200
committerBruno Wagner <bwagner@riseup.net>2016-01-15 11:11:55 -0200
commitcd831d1dfc42c2a0d292fe5c1b7f497b2ca393eb (patch)
tree4069da65211b163f7718b8628349976748a6d0ee /service/test/unit/support
parent36972dc55f64100f4e056130cc1d32a266785a41 (diff)
Removes InputMail.FROM_EMAIL_ADDRESS constant #578
- Created the replier component to generate the reply dict for the email. This was needed to decouple the InputMail from the need to know who is the logged user.
Diffstat (limited to 'service/test/unit/support')
-rw-r--r--service/test/unit/support/test_replier.py42
1 files changed, 42 insertions, 0 deletions
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)