Exemplo n.º 1
0
 def test_connect(self):
     check = SmtpHealthCheck()
     self.mox.StubOutWithMock(socket, 'socket')
     sock = self.mox.CreateMockAnything()
     socket.socket(1, 2, 3).AndReturn(sock)
     sock.connect(('test', 13))
     self.mox.ReplayAll()
     check._connect([(1, 2, 3, '', ('test', 13))])
     self.assertIn('Connect-Elapsed', check.results)
Exemplo n.º 2
0
 def test_connect(self):
     check = SmtpHealthCheck()
     self.mox.StubOutWithMock(socket, 'socket')
     sock = self.mox.CreateMockAnything()
     socket.socket(1, 2, 3).AndReturn(sock)
     sock.connect(('test', 13))
     self.mox.ReplayAll()
     check._connect([(1, 2, 3, '', ('test', 13))])
     self.assertIn('Connect-Elapsed', check.results)
Exemplo n.º 3
0
 def test_run_exception(self):
     check = SmtpHealthCheck()
     check.sock = self.mox.CreateMockAnything()
     self.mox.StubOutWithMock(check, '_lookup')
     self.mox.StubOutWithMock(check, '_connect')
     self.mox.StubOutWithMock(check, '_get_banner')
     self.mox.StubOutWithMock(check, '_check_banner')
     check._lookup('test', 13).AndReturn('beep')
     check._connect('beep').AndRaise(Exception('test test'))
     check.sock.close()
     self.mox.ReplayAll()
     check.run('test', 13)
     self.assertEqual('Exception', check.results['Exception-Type'])
     self.assertEqual('test test', check.results['Exception-Value'])
Exemplo n.º 4
0
 def test_run(self):
     check = SmtpHealthCheck()
     check.sock = self.mox.CreateMockAnything()
     self.mox.StubOutWithMock(check, '_lookup')
     self.mox.StubOutWithMock(check, '_connect')
     self.mox.StubOutWithMock(check, '_get_banner')
     self.mox.StubOutWithMock(check, '_check_banner')
     check._lookup('test', 13).AndReturn('beep')
     check._connect('beep')
     check._get_banner().AndReturn('beep beep')
     check._check_banner('beep beep')
     check.sock.close()
     self.mox.ReplayAll()
     check.run('test', 13)
Exemplo n.º 5
0
 def test_run_exception(self):
     check = SmtpHealthCheck()
     check.sock = self.mox.CreateMockAnything()
     self.mox.StubOutWithMock(check, '_lookup')
     self.mox.StubOutWithMock(check, '_connect')
     self.mox.StubOutWithMock(check, '_get_banner')
     self.mox.StubOutWithMock(check, '_check_banner')
     check._lookup('test', 13).AndReturn('beep')
     check._connect('beep').AndRaise(Exception('test test'))
     check.sock.close()
     self.mox.ReplayAll()
     check.run('test', 13)
     self.assertEqual('Exception', check.results['Exception-Type'])
     self.assertEqual('test test', check.results['Exception-Value'])
Exemplo n.º 6
0
 def test_run(self):
     check = SmtpHealthCheck()
     check.sock = self.mox.CreateMockAnything()
     self.mox.StubOutWithMock(check, '_lookup')
     self.mox.StubOutWithMock(check, '_connect')
     self.mox.StubOutWithMock(check, '_get_banner')
     self.mox.StubOutWithMock(check, '_check_banner')
     check._lookup('test', 13).AndReturn('beep')
     check._connect('beep')
     check._get_banner().AndReturn('beep beep')
     check._check_banner('beep beep')
     check.sock.close()
     self.mox.ReplayAll()
     check.run('test', 13)
Exemplo n.º 7
0
 def test_connect_bad_dns(self):
     check = SmtpHealthCheck()
     with self.assertRaises(DNSError):
         check._connect([])
Exemplo n.º 8
0
 def test_connect_bad_dns(self):
     check = SmtpHealthCheck()
     with self.assertRaises(DNSError):
         check._connect([])