changeset 3918:b54044da7d09

test_sendmail: new test for encodeSpamSafeEmail
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 03 Aug 2008 21:33:58 +0200
parents c1110b025133
children 87c6a9ad850f
files MoinMoin/mail/_tests/test_sendmail.py
diffstat 1 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/mail/_tests/test_sendmail.py	Sun Aug 03 15:01:55 2008 +0200
+++ b/MoinMoin/mail/_tests/test_sendmail.py	Sun Aug 03 21:33:58 2008 +0200
@@ -40,6 +40,31 @@
         for coded, expected in self._tests:
             assert sendmail.decodeSpamSafeEmail(coded) == expected
 
+class TestencodeSpamSafeEmail:
+    """mail.sendmail: testing spam safe mail"""
+
+    _tests = (
+        ('', ''),
+        ('@', ' AT '),
+        ('.', ' DOT '),
+        ('-', ' DASH '),
+        ('lower', 'lower'),
+        ('Firstname.Lastname@example.net',
+         'firstname DOT lastname AT example DOT net'),
+        ('F.Lastname@example.net',
+         'f DOT lastname AT example DOT net'),
+        )
+
+    def testEncodeSpamSafeMail(self):
+        """mail.sendmail: encoding mail address to spam safe mail"""
+        for coded, expected in self._tests:
+            assert sendmail.encodeSpamSafeEmail(coded) == expected
+
+    def testEncodeSpamSafeMailAndObfuscate(self):
+        """mail.sendmail: encoding mail address by an obfuscate string to spam safe mail """
+        for coded, expected in self._tests:
+            expected = expected.replace(' AT ', ' AT SYCTE ')
+            assert sendmail.encodeSpamSafeEmail(coded, 'SYCTE') == expected
 
 class TestEncodeAddress:
     """ Address encoding tests
@@ -103,6 +128,5 @@
         expected = address.encode(config.charset)
         assert sendmail.encodeAddress(address, self.charset) == expected
 
-
 coverage_modules = ['MoinMoin.mail.sendmail']