Ejemplo n.º 1
0
 def test_connect(self):
     handler = lib.ads_new_connection()
     if handler:
         self.addCleanup(lib.ads_free_connection, handler)
     rc = lib.ads_connect(handler, b'')
     self.addCleanup(lib.ads_disconnect, handler)
     self.assertEqual(rc, 0)
Ejemplo n.º 2
0
 def test_disconnect_twice(self):
     handler = lib.ads_new_connection()
     if handler:
         self.addCleanup(lib.ads_free_connection, handler)
     self.assertIsNotNone(handler)
     self.assertEqual(lib.ads_disconnect(handler), 1)
     self.assertEqual(lib.ads_disconnect(handler), 1)
Ejemplo n.º 3
0
def connect(connection_string=None, **kwds):
    if not isinstance(connection_string, str):
        connection_string = ';'.join('{}={}'.format(*i) for i in kwds.items())
    connection_string = connection_string.encode('ascii')
    handler = lib.ads_new_connection()
    if not handler:
        raise InternalError(*_error(None))
    if not lib.ads_connect(handler, connection_string):
        lib.ads_free_connection(handler)
        raise OperationalError(*_error(handler))
    return Connection(handler)
Ejemplo n.º 4
0
 def test_new_connection(self):
     handler = lib.ads_new_connection()
     if handler:
         self.addCleanup(lib.ads_free_connection, handler)
     self.assertIsNotNone(handler)