from util.dnodes import * from util.log import * from util.sql import * from util.cases import * from util.sqlset import * class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(),True) self.setsql = TDSetSql() # name of normal table self.ntbname = 'ntb' # name of stable self.stbname = 'stb' # structure of column self.column_dict = { 'ts':'timestamp', 'c1':'int', 'c2':'float', 'c3':'double' } # structure of tag self.tag_dict = { 't0':'int' } # number of child tables self.tbnum = 2 # values of tag,the number of values should equal to tbnum self.tag_values = [ f'10', f'100' ] self.values_list = [ f'now,10,99.99,11.111111', f'today(),100,11.111,22.222222' ] self.time_unit = ['b','u','a','s','m','h','d','w'] self.symbol = ['+','-','*','/'] self.error_values = [1.5,'abc','"abc"','!@','today()'] self.db_percision = ['ms','us','ns'] def tbtype_check(self,tb_type): if tb_type == 'normal table' or tb_type == 'child table': tdSql.checkRows(len(self.values_list)) elif tb_type == 'stable': tdSql.checkRows(len(self.values_list) * self.tbnum) def data_check(self,tbname,tb_type): tdSql.query(f'select now() from {tbname}') self.tbtype_check(tb_type) for unit in self.time_unit: for symbol in self.symbol: if symbol in ['+','-']: tdSql.query(f'select now() {symbol}1{unit} from {tbname}') self.tbtype_check(tb_type) for k,v in self.column_dict.items(): if v.lower() != 'timestamp': continue else: tdSql.query(f'select * from {tbname} where {k}>=now()') tdSql.checkRows(0) tdSql.query(f'select * from {tbname} where {k}