1
0
Fork 0

Try skipping integration tests if not all environment variables are available.

This commit is contained in:
Adam Coddington 2015-07-21 20:56:04 -07:00
parent 498f38c461
commit 3cc035f58b
2 changed files with 22 additions and 4 deletions

View file

@ -40,9 +40,9 @@ class EmailMessageTestCase(TestCase):
self.mailbox = Mailbox.objects.create(from_email='from@example.com')
self.test_account = os.environ['EMAIL_ACCOUNT']
self.test_password = os.environ['EMAIL_PASSWORD']
self.test_smtp_server = os.environ['EMAIL_SMTP_SERVER']
self.test_account = os.environ.get('EMAIL_ACCOUNT')
self.test_password = os.environ.get('EMAIL_PASSWORD')
self.test_smtp_server = os.environ.get('EMAIL_SMTP_SERVER')
self.test_from_email = 'nobody@nowhere.com'
self.maximum_wait_seconds = 60 * 5

View file

@ -1,4 +1,5 @@
import os
from unittest import SkipTest
import uuid
from six.moves.urllib import parse
@ -15,9 +16,26 @@ __all__ = ['TestImap']
class TestImap(EmailMessageTestCase):
def setUp(self):
super(TestImap, self).setUp()
self.test_imap_server = (
os.environ['EMAIL_IMAP_SERVER']
os.environ.get('EMAIL_IMAP_SERVER')
)
required_settings = [
self.test_imap_server,
self.test_account,
self.test_password,
self.test_smtp_server,
self.test_from_email,
]
if not all(required_settings):
raise SkipTest(
"Integration tests are not available without having "
"the the following environment variables set: "
"EMAIL_ACCOUNT, EMAIL_PASSWORD, EMAIL_SMTP_SERVER, "
"EMAIL_IMAP_SERVER."
)
self.mailbox = Mailbox.objects.create(
name='Integration Test Imap',
uri=self.get_connection_string()