forked from mirror/django-mailbox
Try skipping integration tests if not all environment variables are available.
This commit is contained in:
parent
498f38c461
commit
3cc035f58b
2 changed files with 22 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue