Exemplo n.º 1
0
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
Exemplo n.º 2
0
 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))
Exemplo n.º 3
0
 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()
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 def test_is_ssl(self):
     mail = notifications.Mail(ssl=True)
     self.assertTrue(isinstance(mail.smtpfactory,
                                notifications.SMTPFactory))
Exemplo n.º 6
0
 def test_instantiates(self):
     mail = notifications.Mail()
     self.assertTrue(isinstance(mail, notifications.Mail))