smallint.py 4.4 KB
Newer Older
1 2 3 4 5 6 7 8 9
# -*- coding: utf-8 -*-

import sys
from util.log import *
from util.cases import *
from util.sql import *


class TDTestCase:
S
Shuduo Sang 已提交
10
    def init(self, conn, logSql):
11
        tdLog.debug("start to execute %s" % __file__)
S
Shuduo Sang 已提交
12
        tdSql.init(conn.cursor(), logSql)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106

    def run(self):
        tdSql.prepare()

        tdLog.info('=============== step1')
        tdLog.info('create table tb (ts timestamp, speed smallint)')
        tdSql.execute('create table tb (ts timestamp, speed smallint)')
        tdLog.info("insert into tb values (now, NULL)")
        tdSql.execute("insert into tb values (now, NULL)")
        tdLog.info('select * from tb order by ts desc')
        tdSql.query('select * from tb order by ts desc')
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        tdLog.info('tdSql.checkData(0, 1, null)')
        tdSql.checkData(0, 1, None)
        tdLog.info('=============== step2')
        tdLog.info("insert into tb values (now+1m, -32768) -x step2")
        tdSql.error("insert into tb values (now+1m, -32768)")
        tdLog.info("insert into tb values (now+1m, NULL)")
        tdSql.execute("insert into tb values (now+1m, NULL)")
        tdLog.info('select * from tb order by ts desc')
        tdSql.query('select * from tb order by ts desc')
        tdLog.info('tdSql.checkRow(2)')
        tdSql.checkRows(2)
        tdLog.info('tdSql.checkData(0, 1, null)')
        tdSql.checkData(0, 1, None)
        tdLog.info('=============== step3')
        tdLog.info("insert into tb values (now+2m, 32767)")
        tdSql.execute("insert into tb values (now+2m, 32767)")
        tdLog.info('select * from tb order by ts desc')
        tdSql.query('select * from tb order by ts desc')
        tdLog.info('tdSql.checkRow(3)')
        tdSql.checkRows(3)
        tdLog.info('tdSql.checkData(0, 1, 32767)')
        tdSql.checkData(0, 1, 32767)
        tdLog.info('=============== step4')
        tdLog.info("insert into tb values (now+3m, 32768) -x step4")
        tdSql.error("insert into tb values (now+3m, 32768)")
        tdLog.info("insert into tb values (now+3m, NULL)")
        tdSql.execute("insert into tb values (now+3m, NULL)")
        tdLog.info('select * from tb order by ts desc')
        tdSql.query('select * from tb order by ts desc')
        tdLog.info('tdSql.checkRow(4)')
        tdSql.checkRows(4)
        tdLog.info('tdSql.checkData(0, 1, null)')
        tdSql.checkData(0, 1, None)
        tdLog.info('=============== step5')
        tdLog.info("insert into tb values (now+4m, a2)")
        tdSql.error("insert into tb values (now+4m, a2)")
        tdLog.info("insert into tb values (now+4m, 0)")
        tdSql.execute("insert into tb values (now+4m, 0)")
        tdLog.info('select * from tb order by ts desc')
        tdSql.query('select * from tb order by ts desc')
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        tdLog.info('tdSql.checkData(0, 1, 0)')
        tdSql.checkData(0, 1, 0)
        tdLog.info('=============== step6')
        tdLog.info("insert into tb values (now+5m, 2a)")
        tdSql.error("insert into tb values (now+5m, 2a)")
        tdLog.info("insert into tb values (now+5m, 2)")
        tdSql.execute("insert into tb values (now+5m, 2)")
        tdLog.info('select * from tb order by ts desc')
        tdSql.query('select * from tb order by ts desc')
        tdLog.info('tdSql.checkRow(6)')
        tdSql.checkRows(6)
        tdLog.info('tdSql.checkData(0, 1, 2)')
        tdSql.checkData(0, 1, 2)
        tdLog.info('=============== step7')
        tdLog.info("insert into tb values (now+6m, 2a'1)")
        tdSql.error("insert into tb values (now+6m, 2a'1)")
        tdLog.info("insert into tb values (now+6m, 2)")
        tdSql.execute("insert into tb values (now+6m, 2)")
        tdLog.info('select * from tb order by ts desc')
        tdSql.query('select * from tb order by ts desc')
        tdLog.info('tdSql.checkRow(7)')
        tdSql.checkRows(7)
        tdLog.info('tdSql.checkData(0, 1, 2)')
        tdSql.checkData(0, 1, 2)
        tdLog.info('drop database db')
        tdSql.execute('drop database db')
        tdLog.info('show databases')
        tdSql.query('show databases')
        tdLog.info('tdSql.checkRow(0)')
        tdSql.checkRows(0)
# convert end

    def stop(self):
        tdSql.close()
        tdLog.success("%s successfully executed" % __file__)


tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())