def setup_mail(properties, get_pass=getpass.getpass): username = properties.get_value("mail_username") hostname = properties.get_value("mail_hostname") port = properties.get_value("mail_port") or 25 ssl = properties.get_value("mail_ssl") mail_from = properties.get_value("mail_from") mail_to = properties.get_value("mail_to") password = get_pass() mailAction = notifications.Mail(mail_from, mail_to, hostname, username, password, port, ssl) return mailAction
def test_connects_login(self): hostname = "localhost" port = 3456 user = "******" passwd = "test" mail = notifications.Mail(hostname=hostname, port=port, user=user, passwd=passwd, smtpfactory=SMTPFactoryStub) conn = mail.connectSMTP() self.assertTrue(isinstance(mail.conn, SMTPStub))
def test_connection_exit(self): hostname = "localhost" port = 3456 user = "******" passwd = "test" mail = notifications.Mail(hostname=hostname, port=port, user=user, passwd=passwd, smtpfactory=SMTPFactoryStub) mail.connectSMTP() try: mail.quitSMTP() except SystemExit: self.fail()
def test_connect_raises(self): hostname = "localhost" port = 3456 user = "******" passwd = "test" mail = notifications.Mail(hostname=hostname, port=port, user=user, passwd=passwd, smtpfactory=SMTPFactoryStubRaise) try: conn = mail.connectSMTP() self.fail() except SystemExit: pass
def test_is_ssl(self): mail = notifications.Mail(ssl=True) self.assertTrue(isinstance(mail.smtpfactory, notifications.SMTPFactory))
def test_instantiates(self): mail = notifications.Mail() self.assertTrue(isinstance(mail, notifications.Mail))