Beispiel #1
0
 def test_db(self):
     # 定义sql语句
     sql = "select is_delect from news_collection where user_id =1 and acticle_id=2"
     # 调用get_sql_one方法
     data = ReadDB().get_sql_one()
     print(data)
     # 断言
     self.assertEquals(0, data[0])
Beispiel #2
0
 def test_db(self):
     #定义sql语句
     sql = "select a from lbq where user_id=12 "
     #调用get_sql_one 方法
     data = ReadDB().get_sql_one(sql)
     print(data)
     #断言
     self.assertEquals(0, data[0])
Beispiel #3
0
 def test_db(self):
     # 定义sql
     sql = "select status from axd_activity_coupon where id='34'"
     # 调用 get_sql_one 方法
     data = ReadDB().get_sql_one(sql)
     # 调试
     print(data)
     # 断言
     self.assertEquals(1, data[0])
Beispiel #4
0
 def test_db(self):
     sql = "select admin_status from admin where admin_id=23"
     result = ReadDB().get_sql_one(sql)
     self.assertEquals(0,result[0])
     try:
         0 == result[0]
         print("修改成功")
     except:
         print(result)
 def test_db(self):
     # 定义sql语句
     sql = "select * from table1 where id=1"
     # 调用方法
     data = ReadDB().get_sql_one(sql)
     # 调试 查看响应数据
     print(data)
     # 断言
     self.assertEquals(0, data[0])
    def test_db(self):
        # sql = "select is_deleted from news_collection where user_id=1 and article_id=2"
        sql = "select article_id,is_deleted from news_collection where user_id=1"
        #调用get_sql_one方法
        # data = ReadDB().get_sql_one(sql)
        data = ReadDB().get_sql_all(sql)
        print "data响应数据:", data
        #断言
        sql2 = "select count(is_deleted) from news_collection where user_id=1"
        data2 = ReadDB().get_sql_one(sql2)  #sql获取结果的个数
        print "sql结果获取,数量:", data2[0]

        for i in range(0, data2[0]):
            # self.assertEquals(0, data[i][1]) #多个结果中只要有1就会判定为失败,而且不会打印出失败的是哪一个,所以不方便,只适合用于判断对错
            # self.assertEqual(1, data[i][1], "deleted") #如果有结果是1的,就会判定为失败,并且会打印出deleted字样

            if data[i][1] is 0:
                print "文章id", data[i][0], "未取消收藏", data[i][1]
            else:
                print "文章id", data[i][0], "已取消收藏", data[i][1]
Beispiel #7
0
    def test_admin(self, url, admin_id, username, admin_name, password,
                   admin_status, status_code):
        # 调用登陆方法
        response = Api_Admin().api_admin(url, admin_id, username, admin_name,
                                         password, admin_status, status_code)
        print("查看响应结果:", response.json())

        # 第三条数据为修改admin_id=23的数据返回的结果;admin_id=0表示新增管理员
        self.assertEqual(status_code, response.status_code)  # 检查返回的状态是否等于200
        print(response.status_code)

        # 数据库查询
        sql = "select admin_id from admin where admin_id=23 and admin_status=0"
        result = ReadDB().get_sql_one(sql)
        print(result)
        self.assertEquals(23, result[0])
        try:
            23 == result[0]
            print("修改成功:" + result)
        except:
            print(result)
Beispiel #8
0
 def test_db(self):
     sql = "SELECT name,is_deleted FROM `tb_device_category` WHERE code=9996 OR code=9997"
     data = ReadDB().get_sql_all(sql)
     # self.assertEqual(0, data[1])
     data1 = data[1][0]
     print(data1)