diff options
author | drebs <drebs@leap.se> | 2013-01-28 17:49:02 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-01-28 17:49:02 -0200 |
commit | badc4aedb69ec94abd7d66347d94ac817c73fff6 (patch) | |
tree | 11bb217c7eaf59d20a286b391349ce2b4d89c23d /src/leap | |
parent | 74797eea423aeeb3338b51d78c681bbbf27c8eba (diff) | |
parent | d461e547f4d239c2b377fdd723937614a98c7723 (diff) |
Merge branch 'feature/smtp-relay' into develop
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/email/smtp/README | 2 | ||||
-rw-r--r-- | src/leap/email/smtp/tests/__init__.py | 35 | ||||
-rw-r--r-- | src/leap/email/smtp/tests/test_smtprelay.py | 2 |
3 files changed, 29 insertions, 10 deletions
diff --git a/src/leap/email/smtp/README b/src/leap/email/smtp/README index a351dcec..2b2a1180 100644 --- a/src/leap/email/smtp/README +++ b/src/leap/email/smtp/README @@ -21,8 +21,10 @@ Dependencies Leap SMTP Relay depends on the following python libraries: * Twisted 12.3.0 [1] + * zope.interface 4.0.3 [2] [1] http://pypi.python.org/pypi/Twisted/12.3.0 +[2] http://pypi.python.org/pypi/zope.interface/4.0.3 How to run diff --git a/src/leap/email/smtp/tests/__init__.py b/src/leap/email/smtp/tests/__init__.py index d00ebeb5..ef5fd062 100644 --- a/src/leap/email/smtp/tests/__init__.py +++ b/src/leap/email/smtp/tests/__init__.py @@ -1,15 +1,29 @@ -from leap.email.smtp.smtprelay import GPGWrapper +import os import shutil +import tempfile +from leap.email.smtp.smtprelay import GPGWrapper from twisted.trial import unittest +from leap.testing.basetest import BaseLeapTest -class OpenPGPTestCase(unittest.TestCase): - - PREFIX = "/var/tmp" - GNUPG_HOME = "%s/gnupg" % PREFIX - EMAIL = 'leap@leap.se' +class OpenPGPTestCase(unittest.TestCase, BaseLeapTest): def setUp(self): - self._gpg = GPGWrapper(gpghome=self.GNUPG_HOME) + # mimic LeapBaseTest.setUpClass behaviour, because this is deprecated + # in Twisted: http://twistedmatrix.com/trac/ticket/1870 + self.old_path = os.environ['PATH'] + self.old_home = os.environ['HOME'] + self.tempdir = tempfile.mkdtemp(prefix="leap_tests-") + self.home = self.tempdir + bin_tdir = os.path.join( + self.tempdir, + 'bin') + os.environ["PATH"] = bin_tdir + os.environ["HOME"] = self.tempdir + # setup our own stuff + self.gnupg_home = self.tempdir + '/gnupg' + os.mkdir(self.gnupg_home) + self.email = 'leap@leap.se' + self._gpg = GPGWrapper(gpghome=self.gnupg_home) self.assertEqual(self._gpg.import_keys(PUBLIC_KEY).summary(), '1 imported', "error importing public key") @@ -19,7 +33,12 @@ class OpenPGPTestCase(unittest.TestCase): '0 imported', "error importing private key") def tearDown(self): - shutil.rmtree(self.GNUPG_HOME) + # mimic LeapBaseTest.tearDownClass behaviour + os.environ["PATH"] = self.old_path + os.environ["HOME"] = self.old_home + # safety check + assert self.tempdir.startswith('/tmp/leap_tests-') + shutil.rmtree(self.tempdir) def test_openpgp_encrypt_decrypt(self): text = "simple raw text" diff --git a/src/leap/email/smtp/tests/test_smtprelay.py b/src/leap/email/smtp/tests/test_smtprelay.py index dc0055c6..54aa6dea 100644 --- a/src/leap/email/smtp/tests/test_smtprelay.py +++ b/src/leap/email/smtp/tests/test_smtprelay.py @@ -6,9 +6,7 @@ from leap.email.smtp.smtprelay import ( EncryptedMessage, ) from leap.email.smtp import tests -from twisted.internet.error import ConnectionDone from twisted.test import proto_helpers -from twisted.internet import defer from twisted.mail.smtp import User |