2020-12-09 14:13:35 -05:00
|
|
|
import sys
|
|
|
|
import unittest
|
|
|
|
|
2021-08-19 11:39:29 -04:00
|
|
|
from aprsd.plugins import email
|
2020-12-09 14:13:35 -05:00
|
|
|
|
2021-08-23 12:14:19 -04:00
|
|
|
|
2020-12-09 14:13:35 -05:00
|
|
|
if sys.version_info >= (3, 2):
|
|
|
|
from unittest import mock
|
|
|
|
else:
|
2021-01-08 15:47:30 -05:00
|
|
|
from unittest import mock
|
2020-12-09 14:13:35 -05:00
|
|
|
|
|
|
|
|
2021-01-06 17:50:02 -05:00
|
|
|
class TestMain(unittest.TestCase):
|
2021-08-19 11:39:29 -04:00
|
|
|
@mock.patch("aprsd.plugins.email._imap_connect")
|
|
|
|
@mock.patch("aprsd.plugins.email._smtp_connect")
|
2020-12-09 14:13:35 -05:00
|
|
|
def test_validate_email(self, imap_mock, smtp_mock):
|
|
|
|
"""Test to make sure we fail."""
|
|
|
|
imap_mock.return_value = None
|
|
|
|
smtp_mock.return_value = {"smaiof": "fire"}
|
2020-12-19 16:35:53 -05:00
|
|
|
config = mock.MagicMock()
|
2020-12-09 14:13:35 -05:00
|
|
|
|
2020-12-19 16:35:53 -05:00
|
|
|
email.validate_email_config(config, True)
|