コード例 #1
0
    def bind_user(self):
        """设为达人"""
        # 目的:将这些手机号码的用户设为达人
        # 1、上面生成了100电话号码
        # 2、根据手机号码从数据库里面获取用户id
        #       1、从执行sql语句获取用户id
        # 3、循环发送请求
        db = odbc('juparty-business')
        sql = 'select user_id from `juparty-business`.ju_user where phone in (%s);' % str(
            self.phone_list)[1:-1]
        user_id = db.selectSQL(sql)

        for i in user_id[1]:
            self.user_id_list.append(i[0])

        for i in self.user_id_list:
            response = requests.post(
                url='http://10.113.248.198/sys_user/Organization/bindUser',
                data={
                    'respHtml': 0,
                    'orgId': 100020,
                    'userId': i,
                    'bindType': 1,
                    'remark': ''
                },
                headers={
                    'Cookie':
                    'admin_username=admin; PHPSESSID=kl838tn7mp8740d99dabb1lhe9; thinkphp_show_page_trace=0|0',
                    'X-Requested-With': 'XMLHttpRequest'
                })
            self.assertEqual(response.text, 200, msg="阿斯顿发")
            print(response.text)
コード例 #2
0
def getUserId():
    """从数据库中直接获取100个上架视频id"""
    db = odbc("qiaoku_user")
    dump = db.selectSQL(
        "select user_id from tb_user_info where del_flag = 0 limit 0,100;")
    # print(dump)
    user_list = [dump[1][i][0] for i in range(len(dump[1]))]
    # print(len(user_list))
    # print(user_list)
    return user_list
コード例 #3
0
def getVideoId():
    """从数据库中直接获取100个上架视频id"""
    db = odbc("qiaoku_video")
    dump = db.selectSQL(
        "select video_id from tb_video where video_up_down_status = 3 limit 0,100;"
    )
    # print(dump)
    video_list = [dump[1][i][0] for i in range(len(dump[1]))]
    # print(video_list)
    return video_list
コード例 #4
0
def getUserVideoChk(user_id):
    videoDb = odbc("qiaoku_video")
    chk_id_list = []
    video_id_list = videoDb.selectSQL(
        "select video_id from tb_video where user_id ='%s'" % user_id)[1]
    print(video_id_list)
    for video_id in video_id_list:
        chk_id = videoDb.selectSQL(
            "select id from tb_video_chk where video_id ='%s'" % video_id[0])
        chk_id_list.append(chk_id)
        print(chk_id)
    print(chk_id_list)
コード例 #5
0
    def insert_real_auth(self):
        """app端创建合集"""
        db = odbc('juparty-business')
        sql = 'select user_id from `juparty-business`.ju_user where phone in (%s);' % str(
            self.phone_list)[1:-1]
        user_id = db.selectSQL(sql)

        for i in user_id[1]:
            self.user_id_list.append(i[0])

        for i in self.user_id_list:
            sql = "INSERT INTO `juparty-business`.ju_user_certification " \
                  "(certification_id,user_id,realname,identity_no,identity_img,living_snapshot_img,audit_third_status,audit_status,create_time,update_time,audit_third_time) VALUE" \
                  "(%s,%s,'Eden自动化测试数据','511111111111111122','','',1,1,1596868507220,1596868507220,1596868507220);"%(i,i)
            db.commitSQL(sql)
コード例 #6
0
def write_in_datebase(api_list):
    """yapi中获取的接口数据写入脚本中"""
    # pass
    db = odbc("qa_platform")
    for i in range(len(api_list)):
        api_name = api_list[i][2]
        api_method = api_list[i][1]
        api_uri = api_list[i][0]
        if api_method == 'GET':
            db.commitSQL("INSERT INTO `qa_platform`.`tb_api`"
                         "(`project_id`, `api_name`, `content_type`, `method`, `path`, `text`, `is_status`, `is_delete`, `create_time`, `update_time`) VALUES "
                         "(1, '%s', 'application/x-www-form-urlencoded', '%s', '%s', '', 1, 0, '2020-05-30 11:00:14.298704', '2020-05-30 11:00:14.298746');"%(api_name,api_method,api_uri))
        else:
            db.commitSQL("INSERT INTO `qa_platform`.`tb_api`"
                         "(`project_id`, `api_name`, `content_type`, `method`, `path`, `text`, `is_status`, `is_delete`, `create_time`, `update_time`) VALUES "
                         "(1, '%s', 'application/json', '%s', '%s', '', 1, 0, '2020-05-30 11:00:14.298704', '2020-05-30 11:00:14.298746');"%(api_name,api_method,api_uri))

    print("done")
コード例 #7
0
def test():
    """测试推荐接口"""
    # userId,token,udid = autoLogin(15361899636)
    for i in range(100):
        token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODcwOTQ3MTUsInVzZXJJZCI6NjI3NDcyNDgxMjI5MjA5NjAwLCJ1c2VyUGxhdGZvcm0iOiJhcHAiLCJ1ZGlkIjoibG9naW4iLCJpc3MiOiJxaWFva3UifQ.nXjmUHzsH2ly2nS4rSNm5okMT6BGkT9M5dQUIkRzCHw"
        for i in range(3):
            if i == 1:
                # userId,token,udid = autoLogin(15353913452)#a
                token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODcxMDM1MTcsInVzZXJJZCI6Njg0NTQ5MTcyOTg4NTkyMTI4LCJ1c2VyUGxhdGZvcm0iOiJhcHAiLCJ1ZGlkIjoibG9naW4iLCJpc3MiOiJxaWFva3UifQ.2-RDpRa9lqcH9Km7lvkE2hEx4qhXHjRQ_J3hzoLHeY8"
            if i == 2:
                # userId,token,udid = autoLogin(15350711208)#c
                token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODcxMDM2MzYsInVzZXJJZCI6NzAwNzA4OTYyMTgwODAwNTEyLCJ1c2VyUGxhdGZvcm0iOiJhcHAiLCJ1ZGlkIjoibG9naW4iLCJpc3MiOiJxaWFva3UifQ.F_AJ2AFGEWUnN-9fByFQDce01D9WTsudnAy3AwUAUrg"
            data = {
                # "pageIndex": random.randint(1, 3),
                "pageIndex": 1,
                "pageSize": 10,
                "type": "recommend",
            }
            response = apiObj.video_getVideos(data, token)
            # print(response)
            arraylist = response.get("data")

            if len(arraylist) != 6:
                print("+" * 50)
                print(len(arraylist))
                print(arraylist)

            video_db = odbc("qiaoku_video")

            for i in arraylist:
                videoId = i.get("videoId")
                boo = video_db.selectSQL(
                    "select id,video_id from qiaoku_video.tb_video where video_id = %s"
                    % videoId)
                # print(boo)
                if not boo:
                    print("==" * 50)
                    print(boo)
コード例 #8
0
def deleteData(userPhone):
    list = []
    videoList = []
    logName = log()
    """更新配置文件,返回连接配置文件对象"""
    database = parserMethod(dataPath() + "dataBase.ini")
    # database = parserMethod(dirPath.dataPath()+"dataBase.ini")

    # 创建连接qiaoku_user数据库对象
    userDb = odbc("qiaoku_user")
    # 创建连接qiaoku_user数据库对象
    videoDb = odbc("qiaoku_video")
    # 创建连接qiaoku_user数据库对象
    liveDb = odbc("qiaoku_live")
    # 创建连接qiaoku_user数据库对象
    homeDb = odbc("qiaoku_home")
    # 创建连接qiaoku_user数据库对象
    dataDb = odbc("qiaoku_data")

    # todo:用上面的方法获取所有需要初始化的表

    # 获取database.ini下配置的数据库所有表
    userTable = database.getOptions("userTable")
    videoTable = database.getOptions("videoTable")
    liveTable = database.getOptions("liveTable")
    homeTable = database.getOptions("homeTable")
    dataTable = database.getOptions("dataTable")

    logName.info("开始执行初始化配置")
    for i in range(1):
        user_id = [("624978533432688640", "随意填充")]
        # user_id = userDb.selectSQL("select user_id from tb_user_info where user_phone = %s"%userPhone)
        # 如果userId(元组)有数据则删除用户数据
        """user库"""
        if len(user_id) >= 1:
            user_id = user_id[0][0]
            # 如果删除token成功,返回1则写日志,如果删除token失败则返回None写入日志
            logName.info("token清理成功:%s" %
                         user_id) if rmToken(user_id) else logName.info(
                             "token清理失败:%s" % user_id)
            # 循环执行delete sql语句
            for i in userTable:
                # 如果存在该数据,返回True,执行数据删除
                if userDb.selectSQL("select * from %s where user_id = %s" %
                                    (i, user_id)):
                    try:
                        list.append(
                            userDb.commitSQL(
                                "delete from %s where user_id = %s" %
                                (i, user_id)))
                        time.sleep(0.01)
                    except:
                        logName.warning("初始化sql失败")
            """video库"""
            videoTuple = videoDb.selectSQL(
                "select video_id from tb_video where user_id = %s" % user_id)
            if len(videoTuple) >= 1:
                videoList = [i for i in videoTuple]
                # 遍历该用户下的video视频列表
                for video_id in videoList:
                    # 遍历video库的表,都根据用户的video视频删除
                    for i in videoTable:
                        # 如果存在该数据,返回True,执行数据删除
                        if videoDb.selectSQL(
                                "select * from %s where video_id = %s" %
                            (i, video_id[0])):
                            try:
                                list.append(
                                    videoDb.commitSQL(
                                        "delete from %s where video_id = %s" %
                                        (i, video_id[0])))
                                time.sleep(0.01)
                            except:
                                logName.warning("初始化sql失败")
            """live库"""
            room_id = liveDb.selectSQL(
                "select room_id from tb_player_info where user_id = %s" %
                user_id)
            if len(room_id) >= 1:
                for i in liveTable:
                    # 如果存在该数据,返回True,执行数据删除
                    if liveDb.selectSQL("select * from %s where room_id = %s" %
                                        (i, room_id[0][0])):
                        try:
                            list.append(
                                liveDb.commitSQL(
                                    "delete from %s where room_id = %s" %
                                    (i, room_id[0][0])))
                            time.sleep(0.01)
                        except:
                            logName.warning("初始化sql失败")
                for i in liveTable:
                    # 如果存在该数据,返回True,执行数据删除
                    if liveDb.selectSQL("select * from %s where user_id = %s" %
                                        (i, user_id)):
                        try:
                            list.append(
                                liveDb.commitSQL(
                                    "delete from %s where user_id = %s" %
                                    (i, user_id)))
                            time.sleep(0.01)
                        except:
                            logName.warning("初始化sql失败")
            """home库"""
            for i in homeTable:
                # 如果存在该数据,返回True,执行数据删除
                if homeDb.selectSQL("select * from %s where user_id = %s" %
                                    (i, user_id)):
                    try:
                        list.append(
                            homeDb.commitSQL(
                                "delete from %s where user_id = %s" %
                                (i, user_id)))
                        time.sleep(0.01)
                    except:
                        logName.warning("初始化sql失败")
            # 一个用户可能有多个video视频
            for video_id in videoList:
                for i in homeTable:
                    # 如果存在该数据,返回True,执行数据删除
                    if homeDb.selectSQL(
                            "select * from %s where video_id = %s" %
                        (i, video_id[0])):
                        try:
                            list.append(
                                homeDb.commitSQL(
                                    "delete from %s where video_id = %s" %
                                    (i, video_id[0])))
                            time.sleep(0.01)
                        except:
                            logName.warning("初始化sql失败")
            """data库"""
            for i in dataTable:
                # 如果存在该数据,返回True,执行数据删除
                if homeDb.selectSQL("select * from %s where user_id = %s" %
                                    (i, user_id)):
                    try:
                        list.append(
                            homeDb.commitSQL(
                                "delete from %s where user_id = %s" %
                                (i, user_id)))
                        time.sleep(0.01)
                    except:
                        logName.warning("初始化sql失败")
            # 一个用户可能有多个video视频
            for video_id in videoList:
                for i in dataTable:
                    # 如果存在该数据,返回True,执行数据删除
                    if dataDb.selectSQL(
                            "select * from %s where video_id = %s" %
                        (i, video_id[0])):
                        try:
                            list.append(
                                dataDb.commitSQL(
                                    "delete from %s where video_id = %s" %
                                    (i, video_id[0])))
                            time.sleep(0.01)
                        except:
                            logName.warning("初始化sql失败")

            # todo:这里是for循执行其他数据库SQL的地方,如上面for循环代码

            # 统计失败次数
                countFalse = len([i for i in list if not i])
                # 存在失败sql,写入日志
                if countFalse > 0:
                    logName.error("初始化sql失败数:%s" % countFalse)

                # 有失败的sql则返回False
                return True if countFalse == 0 else False
        else:
            # userDb.commitSQL("INSERT INTO `qiaoku_user`.`tb_user_info` "
            #              "(`id`, `user_id`, `qiaoku_id`, `nick_name`, `birthday`, `gender`, `avatar`, `avatar_large`, `user_phone`, `province`, `city`, `region`, `user_sign`, `user_origin`, `belong_back_user`, `udid`, `user_status`, `talent_mark`, `player_mark`, `total_publish_count`, `total_thumb_up_count`, `total_collection_count`, `user_follow_count`, `user_fans_count`, `binding_wx`, `binding_qq`, `del_flag`, `create_time`, `last_update_time`) "
            #              "VALUES ('1', '111111111111111111', '1111111111', 'EdenTestUser', NULL, '3', 'https://thirdwx.qlogo.cn/mmopen/vi_32/iblOuNxMNQoloaPo5xMM0acNt5jezgAyAIpnNDpRjJWDCxficmU4DPMEONuzpWor7FXOLDtYWIq8zOHHptpULUoQ/132', NULL, '12345678901', '', '', NULL, NULL, '0', NULL, '64d96dba-2e5f-4168-ade8-06652cbafeec', '1', '2', '1', NULL, NULL, NULL, NULL, NULL, '1', '2', '0', '2019-08-19 20:52:59', '2019-08-19 20:53:55');")
            # pass
            logName.warning("tb_user_info没有该用户数据,请确认是否存在绑定该手机号的用户")
        return True
コード例 #9
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from src.utils.ODBC import odbc
import json, requests

test_platform_db = odbc("test_platform")

# eden=1,唐甜=2,国梁=3,嵩鹏=4
plan_id = 2


def select_interface():
    """查询是否存在接口"""
    # url地址信息(/platform/login/)
    path = '/app-http/v104/user/getAppUserBasicInfo'

    interface_info = test_platform_db.selectSQL(
        "SELECT * FROM `test_platform`.`tb_interface` WHERE `path` LIKE '%{}%' LIMIT 0,1000"
        .format(path))
    print(interface_info[0])
    print(interface_info[1])


def select_test_case():
    """查询测试用例"""
    case_info = test_platform_db.selectSQL(
        "SELECT * FROM `test_platform`.`tb_test_case` WHERE `plan_id` = '{}' LIMIT 0,1000"
        .format(plan_id))
    print(case_info[0])
    print(case_info[1])