Пример #1
0
 def testConnUnixString(self):
     """Tests that unix:// protocol works and connects to a socket."""
     sfile = "unix:///some/path/to/socket.socket"
     c = conn.HaPConn(sfile, socket_module=SimpleConnMock)
     addr, stype = c.sfile
     self.assertEqual("/some/path/to/socket.socket", addr)
     self.assertEqual(stype, AF_UNIX)
Пример #2
0
 def testConnSimple(self):
     """Tests that connection to non-protocol path works and fallsback to UNIX socket."""
     sfile = "/some/path/to/socket.sock"
     c = conn.HaPConn(sfile, socket_module=SimpleConnMock)
     addr, stype = c.sfile
     self.assertEqual(sfile, addr)
     self.assertEqual(stype, AF_UNIX)
Пример #3
0
 def testConnTCPStringNoPort(self):
     """Tests that passing a tcp:// address with no port, raises an Exception."""
     sfile = "tcp://1.2.3.4"
     # Not using assertRaises because we still support 2.6
     try:
         conn.HaPConn(sfile, socket_module=SimpleConnMock)
         raise Exception('Connection should have thrown an exception')
     except conn.HapError:
         pass
Пример #4
0
 def testConnTCPString(self):
     """Tests that tcp:// protocol works and connects to an IP."""
     sfile = "tcp://1.2.3.4:8080"
     c = conn.HaPConn(sfile, socket_module=SimpleConnMock)
     addr, stype = c.sfile
     ip, port = addr
     self.assertEqual("1.2.3.4", ip)
     self.assertEqual(8080, port)
     self.assertEqual(stype, AF_INET)