diff options
Diffstat (limited to 'src/leap/mail/smtp/tests')
| -rw-r--r-- | src/leap/mail/smtp/tests/__init__.py | 10 | ||||
| -rw-r--r-- | src/leap/mail/smtp/tests/test_gateway.py | 14 | 
2 files changed, 13 insertions, 11 deletions
| diff --git a/src/leap/mail/smtp/tests/__init__.py b/src/leap/mail/smtp/tests/__init__.py index 1459cea..dc24293 100644 --- a/src/leap/mail/smtp/tests/__init__.py +++ b/src/leap/mail/smtp/tests/__init__.py @@ -21,6 +21,7 @@ Base classes and keys for SMTP gateway tests.  """  import os +import distutils.spawn  import shutil  import tempfile  from mock import Mock @@ -39,9 +40,14 @@ from leap.keymanager import (  from leap.common.testing.basetest import BaseLeapTest +def _find_gpg(): +    gpg_path = distutils.spawn.find_executable('gpg') +    return os.path.realpath(gpg_path) if gpg_path is not None else "/usr/bin/gpg" +     +  class TestCaseWithKeyManager(BaseLeapTest): -    GPG_BINARY_PATH = '/usr/bin/gpg' +    GPG_BINARY_PATH = _find_gpg()      def setUp(self):          # mimic BaseLeapTest.setUpClass behaviour, because this is deprecated @@ -148,7 +154,7 @@ class TestCaseWithKeyManager(BaseLeapTest):          os.environ["PATH"] = self.old_path          os.environ["HOME"] = self.old_home          # safety check -        assert self.tempdir.startswith('/tmp/leap_tests-') +        assert 'leap_tests-' in self.tempdir          shutil.rmtree(self.tempdir) diff --git a/src/leap/mail/smtp/tests/test_gateway.py b/src/leap/mail/smtp/tests/test_gateway.py index 88ee5f7..466677f 100644 --- a/src/leap/mail/smtp/tests/test_gateway.py +++ b/src/leap/mail/smtp/tests/test_gateway.py @@ -23,13 +23,9 @@ SMTP gateway tests.  import re  from datetime import datetime -from gnupg._util import _make_binary_stream  from twisted.test import proto_helpers -from twisted.mail.smtp import ( -    User, -    Address, -    SMTPBadRcpt, -) +from twisted.mail.smtp import User, Address +  from mock import Mock  from leap.mail.smtp.gateway import ( @@ -137,7 +133,7 @@ class TestSmtpGateway(TestCaseWithKeyManager):              self._config['port'], self._config['cert'], self._config['key'])          for line in self.EMAIL_DATA[4:12]:              m.lineReceived(line) -        #m.eomReceived()  # this includes a defer, so we avoid calling it here +        # m.eomReceived()  # this includes a defer, so we avoid calling it here          m.lines.append('')  # add a trailing newline          # we need to call the following explicitelly because it was deferred          # inside the previous method @@ -181,7 +177,7 @@ class TestSmtpGateway(TestCaseWithKeyManager):          for line in self.EMAIL_DATA[4:12]:              m.lineReceived(line)          # trigger encryption and signing -        #m.eomReceived()  # this includes a defer, so we avoid calling it here +        # m.eomReceived()  # this includes a defer, so we avoid calling it here          m.lines.append('')  # add a trailing newline          # we need to call the following explicitelly because it was deferred          # inside the previous method @@ -229,7 +225,7 @@ class TestSmtpGateway(TestCaseWithKeyManager):          for line in self.EMAIL_DATA[4:12]:              m.lineReceived(line)          # trigger signing -        #m.eomReceived()  # this includes a defer, so we avoid calling it here +        # m.eomReceived()  # this includes a defer, so we avoid calling it here          m.lines.append('')  # add a trailing newline          # we need to call the following explicitelly because it was deferred          # inside the previous method | 
