mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
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.mailbox = Mailbox.objects.create(from_email='from@example.com')
|
||||||
|
|
||||||
self.test_account = os.environ['EMAIL_ACCOUNT']
|
self.test_account = os.environ.get('EMAIL_ACCOUNT')
|
||||||
self.test_password = os.environ['EMAIL_PASSWORD']
|
self.test_password = os.environ.get('EMAIL_PASSWORD')
|
||||||
self.test_smtp_server = os.environ['EMAIL_SMTP_SERVER']
|
self.test_smtp_server = os.environ.get('EMAIL_SMTP_SERVER')
|
||||||
self.test_from_email = 'nobody@nowhere.com'
|
self.test_from_email = 'nobody@nowhere.com'
|
||||||
|
|
||||||
self.maximum_wait_seconds = 60 * 5
|
self.maximum_wait_seconds = 60 * 5
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
from unittest import SkipTest
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from six.moves.urllib import parse
|
from six.moves.urllib import parse
|
||||||
|
|
@ -15,9 +16,26 @@ __all__ = ['TestImap']
|
||||||
class TestImap(EmailMessageTestCase):
|
class TestImap(EmailMessageTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestImap, self).setUp()
|
super(TestImap, self).setUp()
|
||||||
|
|
||||||
self.test_imap_server = (
|
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(
|
self.mailbox = Mailbox.objects.create(
|
||||||
name='Integration Test Imap',
|
name='Integration Test Imap',
|
||||||
uri=self.get_connection_string()
|
uri=self.get_connection_string()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue