Loading test/test.py +26 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import logging from common.database import Database from common.mixins.postgres import PostgresMixin from common.logz import create_logger from common.mail import send_email class DBPG(Database, PostgresMixin): Loading Loading @@ -121,5 +122,30 @@ class LogzTestCase(unittest.TestCase): self.assertTrue(isinstance(log, logging.Logger)) class MailTestCase(unittest.TestCase): """MailTestCase.""" def test_send_email(self): """Test to make sure that then send_mail function can actually send mail""" send_email("TEST SUBJECT", "THIS IS A TEST MESSAGE") def test_send_email_attachment(self): """Test to make sure that we can send attachments..""" ATTACHMENT_PATHS = ["/test/test_attachments/test_attachment.txt", "/test/test_attachments/test_attachment2.txt"] ATTACHMENT_PATHS_W_BAD_FILE = [ "/test/test_attachments/test_attachment.txt", "/this/is/not/a/real/file/path.txt"] send_email( "TEST SUBJECT WITH ATTACHMENT", "THIS IS A TEST MESSAGE", files=[ATTACHMENT_PATHS[0]] ) send_email("TEST SUBJECT MULTI-ATTACHMENTS", "TEST MESSAGE", files=ATTACHMENT_PATHS) send_email("TEST SUBJECT WITH BAD PATH", "TEST MESSAGE", files=ATTACHMENT_PATHS_W_BAD_FILE) if __name__ == "__main__": unittest.main(verbosity=2) Loading
test/test.py +26 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import logging from common.database import Database from common.mixins.postgres import PostgresMixin from common.logz import create_logger from common.mail import send_email class DBPG(Database, PostgresMixin): Loading Loading @@ -121,5 +122,30 @@ class LogzTestCase(unittest.TestCase): self.assertTrue(isinstance(log, logging.Logger)) class MailTestCase(unittest.TestCase): """MailTestCase.""" def test_send_email(self): """Test to make sure that then send_mail function can actually send mail""" send_email("TEST SUBJECT", "THIS IS A TEST MESSAGE") def test_send_email_attachment(self): """Test to make sure that we can send attachments..""" ATTACHMENT_PATHS = ["/test/test_attachments/test_attachment.txt", "/test/test_attachments/test_attachment2.txt"] ATTACHMENT_PATHS_W_BAD_FILE = [ "/test/test_attachments/test_attachment.txt", "/this/is/not/a/real/file/path.txt"] send_email( "TEST SUBJECT WITH ATTACHMENT", "THIS IS A TEST MESSAGE", files=[ATTACHMENT_PATHS[0]] ) send_email("TEST SUBJECT MULTI-ATTACHMENTS", "TEST MESSAGE", files=ATTACHMENT_PATHS) send_email("TEST SUBJECT WITH BAD PATH", "TEST MESSAGE", files=ATTACHMENT_PATHS_W_BAD_FILE) if __name__ == "__main__": unittest.main(verbosity=2)