fix: timezone test case
This commit is contained in:
parent
2c68cffe6e
commit
ce122d7cd8
|
@ -524,19 +524,19 @@ class TDCom:
|
||||||
# print(con)
|
# print(con)
|
||||||
return con
|
return con
|
||||||
|
|
||||||
def newcur(self,host='localhost',port=6030,user='root',password='taosdata', timezone='asia/shanghai'):
|
def newcur(self,host='localhost',port=6030,user='root',password='taosdata'):
|
||||||
cfgPath = self.getClientCfgPath()
|
cfgPath = self.getClientCfgPath()
|
||||||
con=taos.connect(host=host, user=user, password=password, config=cfgPath, port=port, timezone=timezone)
|
con=taos.connect(host=host, user=user, password=password, config=cfgPath, port=port)
|
||||||
cur=con.cursor()
|
cur=con.cursor()
|
||||||
# print(cur)
|
# print(cur)
|
||||||
return cur
|
return cur
|
||||||
|
|
||||||
def newTdSql(self, host='localhost',port=6030,user='root',password='taosdata', timezone='asia/shanghai'):
|
def newTdSql(self, host='localhost',port=6030,user='root',password='taosdata'):
|
||||||
newTdSql = TDSql()
|
newTdSql = TDSql()
|
||||||
cur = self.newcur(host=host,port=port,user=user,password=password, timezone=timezone)
|
cur = self.newcur(host=host,port=port,user=user,password=password)
|
||||||
newTdSql.init(cur, False)
|
newTdSql.init(cur, False)
|
||||||
return newTdSql
|
return newTdSql
|
||||||
|
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
# port from the common.py of new test frame
|
# port from the common.py of new test frame
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
|
|
|
@ -543,16 +543,29 @@ class TDCom:
|
||||||
# print(con)
|
# print(con)
|
||||||
return con
|
return con
|
||||||
|
|
||||||
def newcur(self,host='localhost',port=6030,user='root',password='taosdata',database=None, timezone='asia/shanghai'):
|
def newcur(self,host='localhost',port=6030,user='root',password='taosdata',database=None):
|
||||||
cfgPath = self.getClientCfgPath()
|
cfgPath = self.getClientCfgPath()
|
||||||
con=taos.connect(host=host, user=user, password=password, config=cfgPath, port=port,database=database, timezone=timezone)
|
con=taos.connect(host=host, user=user, password=password, config=cfgPath, port=port,database=database)
|
||||||
cur=con.cursor()
|
cur=con.cursor()
|
||||||
# print(cur)
|
# print(cur)
|
||||||
return cur
|
return cur
|
||||||
|
|
||||||
def newTdSql(self, host='localhost',port=6030,user='root',password='taosdata', database = None, timezone='asia/shanghai'):
|
def newTdSql(self, host='localhost',port=6030,user='root',password='taosdata', database = None):
|
||||||
newTdSql = TDSql()
|
newTdSql = TDSql()
|
||||||
cur = self.newcur(host=host,port=port,user=user,password=password, database=database, timezone=timezone)
|
cur = self.newcur(host=host,port=port,user=user,password=password, database=database)
|
||||||
|
newTdSql.init(cur, False)
|
||||||
|
return newTdSql
|
||||||
|
|
||||||
|
def newcurWithTimezone(self, timezone, host='localhost', port=6030, user='root', password='taosdata'):
|
||||||
|
cfgPath = self.getClientCfgPath()
|
||||||
|
con=taos.connect(host=host, user=user, password=password, config=cfgPath, port=port, timezone=timezone)
|
||||||
|
cur=con.cursor()
|
||||||
|
# print(cur)
|
||||||
|
return cur
|
||||||
|
|
||||||
|
def newTdSqlWithTimezone(self, timezone, host='localhost',port=6030,user='root',password='taosdata'):
|
||||||
|
newTdSql = TDSql()
|
||||||
|
cur = self.newcurWithTimezone(host=host,port=port,user=user,password=password, timezone=timezone)
|
||||||
newTdSql.init(cur, False)
|
newTdSql.init(cur, False)
|
||||||
return newTdSql
|
return newTdSql
|
||||||
|
|
||||||
|
|
|
@ -130,26 +130,29 @@ class TDTestCase:
|
||||||
|
|
||||||
def timeZoneTest(self):
|
def timeZoneTest(self):
|
||||||
dbname = self.dbname
|
dbname = self.dbname
|
||||||
tdSql.execute(f'create table {dbname}.tzt(ts timestamp, c1 int)')
|
tdsql1 = tdCom.newTdSqlWithTimezone(timezone="Asia/Shanghai")
|
||||||
tdSql.execute(f'insert into {dbname}.tzt values({self.ts}, 1)')
|
tdsql1.execute(f'create table {dbname}.tzt(ts timestamp, c1 int)')
|
||||||
tdSql.query(f"select * from {dbname}.tzt")
|
tdsql1.execute(f'insert into {dbname}.tzt values({self.ts}, 1)')
|
||||||
tdSql.checkRows(1)
|
|
||||||
tdSql.checkData(0, 0, "2018-09-17 09:00:00")
|
|
||||||
|
|
||||||
tdsql1 = tdCom.newTdSql(timezone="UTC")
|
|
||||||
tdsql1.query(f"select * from {dbname}.tzt")
|
tdsql1.query(f"select * from {dbname}.tzt")
|
||||||
tdsql1.checkRows(1)
|
tdsql1.checkRows(1)
|
||||||
tdsql1.checkData(0, 0, "2018-09-17 01:00:00")
|
tdsql1.checkData(0, 0, "2018-09-17 09:00:00")
|
||||||
|
|
||||||
|
tdsql2 = tdCom.newTdSqlWithTimezone(timezone="UTC")
|
||||||
|
tdsql2.query(f"select * from {dbname}.tzt")
|
||||||
|
tdsql2.checkRows(1)
|
||||||
|
tdsql2.checkData(0, 0, "2018-09-17 01:00:00")
|
||||||
|
|
||||||
|
|
||||||
tdsql1.execute(f'insert into {dbname}.tzt values({self.ts + 1000}, 2)')
|
tdsql2.execute(f'insert into {dbname}.tzt values({self.ts + 1000}, 2)')
|
||||||
tdsql1.query(f"select * from {dbname}.tzt order by ts")
|
|
||||||
tdsql1.checkRows(2)
|
|
||||||
tdsql1.checkData(1, 0, "2018-09-17 01:00:01")
|
|
||||||
|
|
||||||
tdsql2 = tdCom.newTdSql(timezone="Asia/Shanghai")
|
|
||||||
tdsql2.query(f"select * from {dbname}.tzt order by ts")
|
tdsql2.query(f"select * from {dbname}.tzt order by ts")
|
||||||
tdsql2.checkRows(2)
|
tdsql2.checkRows(2)
|
||||||
|
tdsql2.checkData(0, 0, "2018-09-17 01:00:00")
|
||||||
|
tdsql2.checkData(1, 0, "2018-09-17 01:00:01")
|
||||||
|
|
||||||
|
tdsql2 = tdCom.newTdSqlWithTimezone(timezone="Asia/Shanghai")
|
||||||
|
tdsql2.query(f"select * from {dbname}.tzt order by ts")
|
||||||
|
tdsql2.checkRows(2)
|
||||||
|
tdsql2.checkData(0, 0, "2018-09-17 09:00:00")
|
||||||
tdsql2.checkData(1, 0, "2018-09-17 09:00:01")
|
tdsql2.checkData(1, 0, "2018-09-17 09:00:01")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
Loading…
Reference in New Issue