Commits

jordilin committed ae90ce8

test exits connection

  • Participants
  • Parent commits 9145de3

Comments (0)

Files changed (1)

File log4client/tests/test_mailaction.py

     def login(self, user, passwd):
         pass
 
+    def quit(self):
+        pass
+
 
 class SMTPStubRaise(object):
     def __init__(self, hostname, port):
         return SMTPStubRaise
 
 
+class SMTPStubLoginRaise(SMTPStub):
+
+    def quit(self):
+        raise SystemExit
+        
+
+class SMTPFactoryLoginRaiseStub(notifications.SMTPFactory):
+
+    def connection_type(self):
+        return SMTPStubLoginRaise
+
+
 class SMPTFactoryTestCase(unittest.TestCase):
 
     def test_smtpssl(self):
         except SystemExit:
             pass
 
+    def test_connection_exit(self):
+        hostname = "localhost"
+        port = 3456
+        user = "test"
+        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_connection_exit_raises(self):
+        hostname = "localhost"
+        port = 3456
+        user = "test"
+        passwd = "test"
+        mail = notifications.Mail(hostname=hostname,
+                port=port, user=user, passwd=passwd,
+                smtpfactory=SMTPFactoryLoginRaiseStub)
+        mail.connectSMTP()
+        try:
+            mail.quitSMTP()
+            self.fail()
+        except SystemExit:
+            pass
+
 
 class TimeStub(object):
     def __init__(self):