Exemple #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)
Exemple #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)
Exemple #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)
Exemple #4
0
 def test_new_connection(self):
     handler = lib.ads_new_connection()
     if handler:
         self.addCleanup(lib.ads_free_connection, handler)
     self.assertIsNotNone(handler)