def test_timestamp(self): id = getId() i = datetime.datetime(1980, 12, 28, 8, 8, 0, 234) o = [None] yield waitD(self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, NULL, %s)',(id, i,))) d = waitD(self.pool.runQuery( 'select t_timestamp from t_tbl where id = %d', (id,))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def test_char(self): id = getId() i = "'wh\\" yield waitD(self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, %s, NULL, NULL)',(id, i,))) d = waitD(self.pool.runQuery( 'select t_char from t_tbl where id = %d', (id,))) yield d o = d.getResult() self.assertEquals(i + (' ' * (5 - len(i))), o[0][0])
def test_text(self): id = getId() i = "how's s\x13he doing; good)?'" yield waitD(self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, NULL, %s, NULL)',(id, i,))) d = waitD(self.pool.runQuery( 'select t_text from t_tbl where id = %d', (id,))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def test_money(self): id = getId() i = Decimal('3.29') yield waitD(self.pool.runOperation( 'insert into t_tbl VALUES(%d, %s)',(id, pgasync.MONEY(i)))) d = waitD( self.pool.runQuery( 'select t_money from t_tbl where id = %d', (id,))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def test_money(self): id = getId() i = Decimal('3.29') yield waitD( self.pool.runOperation('insert into t_tbl VALUES(%d, %s)', (id, pgasync.MONEY(i)))) d = waitD( self.pool.runQuery('select t_money from t_tbl where id = %d', (id, ))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def test_bytea(self): id = getId() import random i = ''.join([chr(random.randint(0,255)) for x in range(100 * 1024)]) yield waitD(self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, NULL, NULL, %s)',(id, pgasync.BINARY(i),))) d = waitD(self.pool.runQuery( 'select t_bytea from t_tbl where id = %d', (id,))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def test_bigint(self): id = getId() i = 6000000000 yield waitD( self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, NULL, %d)',(id, i,))) d = waitD( self.pool.runQuery( 'select t_bigint from t_tbl where id = %d', (id,))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def testnull(self): id = getId() i = None yield waitD(self.pool.runOperation( 'insert into t_tbl VALUES(%d, %s)',(id, i,))) d = waitD( self.pool.runQuery( 'select nil from t_tbl where id = %d', (id,)) ) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def test_numeric(self): id = getId() i = Decimal('3.291283719') yield waitD( self.pool.runOperation( 'insert into t_tbl VALUES(%d, %s, NULL, NULL)',(id, i,))) d = waitD( self.pool.runQuery( 'select t_numeric from t_tbl where id = %d', (id,))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def testnull(self): id = getId() i = None yield waitD( self.pool.runOperation('insert into t_tbl VALUES(%d, %s)', ( id, i, ))) d = waitD( self.pool.runQuery('select nil from t_tbl where id = %d', (id, ))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def test_double(self): id = getId() i = 3.291283719 ti = type(i) yield waitD( self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, NULL, %s)',(id, i,))) d = waitD( self.pool.runQuery( 'select t_dp from t_tbl where id = %d', (id,))) yield d o = d.getResult() self.assertEquals(ti, type(o[0][0]))
def test_char(self): id = getId() i = "'wh\\" yield waitD( self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, %s, NULL, NULL)', ( id, i, ))) d = waitD( self.pool.runQuery('select t_char from t_tbl where id = %d', (id, ))) yield d o = d.getResult() self.assertEquals(i + (' ' * (5 - len(i))), o[0][0])
def test_double(self): id = getId() i = 3.291283719 ti = type(i) yield waitD( self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, NULL, %s)', ( id, i, ))) d = waitD( self.pool.runQuery('select t_dp from t_tbl where id = %d', (id, ))) yield d o = d.getResult() self.assertEquals(ti, type(o[0][0]))
def test_text(self): id = getId() i = "how's s\x13he doing; good)?'" yield waitD( self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, NULL, %s, NULL)', ( id, i, ))) d = waitD( self.pool.runQuery('select t_text from t_tbl where id = %d', (id, ))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def test_timestamp(self): id = getId() i = datetime.datetime(1980, 12, 28, 8, 8, 0, 234) o = [None] yield waitD( self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, NULL, %s)', ( id, i, ))) d = waitD( self.pool.runQuery('select t_timestamp from t_tbl where id = %d', (id, ))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def test_bigint(self): id = getId() i = 6000000000 yield waitD( self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, NULL, %d)', ( id, i, ))) d = waitD( self.pool.runQuery('select t_bigint from t_tbl where id = %d', (id, ))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def test_numeric(self): id = getId() i = Decimal('3.291283719') yield waitD( self.pool.runOperation( 'insert into t_tbl VALUES(%d, %s, NULL, NULL)', ( id, i, ))) d = waitD( self.pool.runQuery('select t_numeric from t_tbl where id = %d', (id, ))) yield d o = d.getResult() self.assertEquals(i, o[0][0])
def test_bytea(self): id = getId() import random i = ''.join([chr(random.randint(0, 255)) for x in range(100 * 1024)]) yield waitD( self.pool.runOperation( 'insert into t_tbl VALUES(%d, NULL, NULL, NULL, %s)', ( id, pgasync.BINARY(i), ))) d = waitD( self.pool.runQuery('select t_bytea from t_tbl where id = %d', (id, ))) yield d o = d.getResult() self.assertEquals(i, o[0][0])