summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2016-05-13 10:45:50 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2016-05-13 10:45:50 +0200
commit3e419b753a2844655362c824cff167583d604bfa (patch)
tree09347856040f92bcce81b3f31d1cc4746a789711 /tests
parent39e31385df84f1d46576ecc8461ab1d0177de1e7 (diff)
downloadpykolab-3e419b753a2844655362c824cff167583d604bfa.tar.gz
Trim spaces in surname/givenname/sn when generating mail/alias (#5360)
Reviewers: vanmeeuwen, #pykolab_developers Reviewed By: vanmeeuwen, #pykolab_developers Subscribers: vanmeeuwen Differential Revision: https://git.kolab.org/D136
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test-022-utils.py20
-rw-r--r--tests/unit/test-030-recipientpolicy.py30
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/unit/test-022-utils.py b/tests/unit/test-022-utils.py
new file mode 100644
index 0000000..ad65aea
--- /dev/null
+++ b/tests/unit/test-022-utils.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+
+import unittest
+
+from pykolab import utils
+
+
+class TestTranslate(unittest.TestCase):
+
+ def test_001_normalize(self):
+ attr = {"test1": " trim ", "test2": [" trim1 ", " trim2 "]}
+ result = utils.normalize(attr)
+
+ self.assertEqual(result['test1'], "trim")
+ self.assertEqual(result['test2'][0], "trim1")
+ self.assertEqual(result['test2'][1], "trim2")
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/unit/test-030-recipientpolicy.py b/tests/unit/test-030-recipientpolicy.py
new file mode 100644
index 0000000..0f50747
--- /dev/null
+++ b/tests/unit/test-030-recipientpolicy.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+
+import unittest
+
+from pykolab.plugins.recipientpolicy import KolabRecipientpolicy
+
+policy = KolabRecipientpolicy()
+
+
+class TestRecipientPolicy(unittest.TestCase):
+ def test_001_primary_mail(self):
+ """
+ The spaces in attributes used for mail generation.
+ """
+
+ entry = {
+ 'surname': ' sn ',
+ 'givenname': ' gn ',
+ }
+
+ mail = policy.set_primary_mail(
+ primary_mail='%(givenname)s.%(surname)s@%(domain)s',
+ primary_domain='example.org',
+ entry=entry
+ )
+
+ self.assertEqual('gn.sn@example.org', mail)
+
+if __name__ == '__main__':
+ unittest.main()