def test_postgresql():
 from openid.store import sqlstore
 try:
  import psycopg
 except ImportError:
  pass
 else:
  db_name = getTmpDbName()
  db_user = 'openid_test'
  conn_create = psycopg.connect(database='template1', user=db_user, host=db_host)
  conn_create.autocommit()
  cursor = conn_create.cursor()
  cursor.execute(('CREATE DATABASE %s;' % (db_name,)))
  conn_create.close()
  conn_test = psycopg.connect(database=db_name, user=db_user, host=db_host)
  store = sqlstore.PostgreSQLStore(conn_test)
  store.createTables()
  testStore(store)
  conn_test.close()
  import time
  time.sleep(1)
  conn_remove = psycopg.connect(database='template1', user=db_user, host=db_host)
  conn_remove.autocommit()
  cursor = conn_remove.cursor()
  cursor.execute(('DROP DATABASE %s;' % (db_name,)))
  conn_remove.close()

def test_postgresql ( ) : from openid . store import sqlstore try : import psycopg except ImportError : pass else : db_name = getTmpDbName ( ) db_user = 'openid_test' conn_create = psycopg . connect ( database = 'template1' , user = db_user , host = db_host ) conn_create . autocommit ( ) cursor = conn_create . cursor ( ) cursor . execute ( ( 'CREATE DATABASE %s;' % ( db_name , ) ) ) conn_create . close ( ) conn_test = psycopg . connect ( database = db_name , user = db_user , host = db_host ) store = sqlstore . PostgreSQLStore ( conn_test ) store . createTables ( ) testStore ( store ) conn_test . close ( ) import time time . sleep ( 1 ) conn_remove = psycopg . connect ( database = 'template1' , user = db_user , host = db_host ) conn_remove . autocommit ( ) cursor = conn_remove . cursor ( ) cursor . execute ( ( 'DROP DATABASE %s;' % ( db_name , ) ) ) conn_remove . close ( )
tests the postgresqlstore on a locally-hosted postgresql database cluster .