Example #1
0
 def test_save_competition(self):
     cmp_id = competition_pk_serv.save_cmp_nonreg_1()
     # cmp_id = competition_pk_serv.save_cmp_nonreg_13()
     # cmp_id = competition_pk_serv.save_cmp_nonreg_17()
     # cmp_id = competition_pk_serv.save_cmp_reg_1()
     assert cmp_id
     logger.info(f"赛事ID:{cmp_id}")
Example #2
0
def result_check(result):
    origin = 'api'
    if origin == 'case':
        return

    if result.rsp is not None:
        response_code = result.rsp.status_code
        if response_code == 200:
            rsp_json = result.rsp.json()  # 响应文本如果不是合法的json文本就会报错
            if rsp_json['success'] is True:
                result.status = True  # 写入1
                if 'data' in rsp_json:
                    # 写入2
                    logger.info('响应体是: ' + str(rsp_json['data']))
                    result.sdata = rsp_json['data']
                else:
                    logger.info('接口正常,响应体内不包含data')
                    logger.info(rsp_json)
            else:
                logger.info('响应码200,但success为False')
                logger.info('rsp_json' + str(rsp_json))
        else:
            logger.error('异常响应码: ' + str(response_code))
        # logger.debug(str(result.rsp.json))
    else:
        logger.error('无法成功获取res响应体对象')
        exit()
Example #3
0
 def test_upload_info(self, kwargs):
     result = leads_api.get_token()
     res_token = result.sdata
     logger.info(res_token)
     kwargs['token'] = res_token
     result = leads_api.upload_info(**kwargs)
     assert result.status is True
Example #4
0
def save_match_enable(kwargs):
    res = bbc_signUp.save_match(**kwargs)
    match_id = sql_util.sql_matchid()
    # match_id = res.sdata  # TODO 等开发改好接口后要换成这个
    logger.info(f"创建的蓝桥杯赛事活动ID是{match_id}")
    res1 = bbc_signUp.enable(1, match_id)
    assert res1.status is True
Example #5
0
 def test_aaa(self, kwargs):
     kwargs['identityNo'] = 123
     res = user.result_inquiry(**kwargs)
     prom = res.sdata.get('resultInquiryList')[0].get('promotionResult')
     logger.info(f'晋级情况={prom}')
     kwargs8 = data_pool.supply('bbc_submit_paper.yml',
                                'submit_official_paper')[0]
     res8 = user.submit_official_paper(**kwargs8)
     assert res.status is True
Example #6
0
def create_coupon_campus():
    kwargs = data_pool.supply('coupon_data.yml', 'create_coupon_school')[0]
    meet_amount = kwargs['meetamount']
    sub_amount = kwargs['subamount']
    kwargs['sendType'] = 2
    kwargs['title'] = f'续费校区-{meet_amount}-{sub_amount}-{fakerist.word()}'
    res1 = coupon.create_coupon(**kwargs)
    couponId = res1.sdata.get('id')
    logger.info(f'第一张的id是{couponId}')
    assert res1.status is True
Example #7
0
def create_coupon_referral():
    kwargs = data_pool.supply_one('coupon_data.yml', 'create_coupon_referral')

    # kwargs['subamount'] = int(kwargs['subamount'])+1
    kwargs['subamount'] = 2003
    meet_amount = kwargs['meetamount']
    sub_amount = kwargs['subamount']
    kwargs['title'] = f'转介绍-{fakerist.word()}-{meet_amount}-{sub_amount}'
    res1 = coupon.create_coupon(**kwargs)
    couponId = res1.sdata.get('id')
    logger.info(f'第一张的id是{couponId}')
    assert res1.status is True
 def test_submit_registration_information(self, kwargs):
     kwargs['matchId'] = '58'
     phone = kwargs['phone']
     userid = sql_util.sql_phone_to_userid(phone)
     user.reset_pwd(userid)
     user.login(phone)
     res = bbc_signUp.submit_registration_information(**kwargs)
     assert res.status is True
     signin_id = res.sdata.get('id')
     logger.info(f"报名ID是{signin_id}")
     # 将用户的openid设置为iphone12mini上的
     sql_util.sql_fix_openid(signin_id)
 def test_result_inquiry(self, kwargs):
     kwargs_query = dict(identityNo='111', phone='222')
     kwargs_query['identityNo'] = kwargs['identityNo']
     kwargs_query['phone'] = kwargs['phone']
     kwargs_query['identityType'] = 'IDCARD'
     res = bbc_match.result_inquiry(**kwargs_query)
     # award = res.sdata.get('resultInquiryList')[0].get('winningResults')
     # logger.info(f'获奖情况={award}')
     # assert award == kwargs['award']
     prom = res.sdata.get('resultInquiryList')[0].get('promotionResult')
     logger.info(f'晋级情况={prom}')
     assert prom == kwargs['prom']
Example #10
0
 def execute(self, sql):
     """更新/新增/删除"""
     try:
         # 检查连接是否断开,如果断开就进行重连
         self.conn.ping(reconnect=True)
         # 使用 execute() 执行sql
         self.cur.execute(sql)
         # 提交事务
         self.conn.commit()
     except Exception as e:
         logger.info("操作MySQL出现错误,错误原因:{}".format(e))
         # 回滚所有更改
         self.conn.rollback()
Example #11
0
 def test_add_coupon_school(self, kwargs):
     # 下发渠道分别是1,2,3
     # 金额分别是直减1011,1012,1013
     meet_amount = kwargs['meetamount']
     sub_amount = kwargs['subamount']
     kwargs['type'] = 'CASH_COUPON'  # 现金
     kwargs['couponTypeId'] = 53  # 校区直减券_不可叠加
     kwargs['couponAmount'] = 1  # 限量1张
     kwargs['sendType'] = 1
     kwargs['title'] = f'限量2校区-{meet_amount}-{sub_amount}-{fakerist.word()}'
     res1 = coupon.create_coupon(**kwargs)
     couponId = res1.sdata.get('id')
     logger.info(f'第一张的id是{couponId}')
     assert res1.status is True
Example #12
0
    def test_sample_get(self, kwargs):
        # case层可直接调用api层发起请求,请求前可自行修改kwargs任意键的值
        kwargs['token'] = 'res_token'
        result = sample.req_get(kwargs)
        prom = result.sdata.get('resultInquiryList')[0].get('promotionResult')
        logger.info('prom的值')
        assert prom == 4

        # case层也能直接调用serv层发起请求
        kwargs3 = data_pool.supply('bbc_signup_data.yml', 'create_order')[0]
        kwargs3['payType'] = "WX"
        sample_serv.save_match_enable(kwargs3)
        res3 = sample.request(kwargs3)
        pay_record_id = res3.sdata.get("payrecordId")
        out_trade_no = sql_util.sql_payrecordid_to_outtradeno(pay_record_id)
        assert result.status is True
Example #13
0
 def edit_scoring_dimension(self, **kwargs):
     self.req_method = 'POST'
     self.req_url = '/core/scoringDimension/saveScoringDimension'
     self.req_body = kwargs
     self.req_cookies = {
         'JSESSIONID': auth_util.get_cookie('crm'),
         'exam_token': auth_util.get_token('bbc', 'exam_token'),
     }
     result = self.request(method=self.req_method,
                           url=self.req_url,
                           headers=self.req_headers,
                           cookies=self.req_cookies,
                           json=self.req_body)
     assert_util.result_check(result)
     finvalue = mysqler.query(
         'SELECT min_points FROM scoring_dimension where id = 3')[0][0]
     if finvalue == 2:
         logger.info(finvalue)
     return result
Example #14
0
def main(path, cls_true):
    if cls_true not in classes.keys():
        print(
            f'ERROR: Please input {json.dumps(classes, indent=4, ensure_ascii=False)}'
        )
        return 0
    path = path[:-1] if path[-1] in [r'/', '\\'] else path
    mark_dir = op.join(path, 'mark')
    others_dir = op.join(
        path,
        'others_images' + datetime.datetime.now().strftime('%Y%m%d_%H%M%S'))
    img_paths = []
    for d in os.listdir(mark_dir):
        if op.isdir(op.join(mark_dir, d)):
            for f in os.listdir(op.join(mark_dir, d)):
                if len(re.findall(img_format, f)) > 0:
                    img_paths.append(op.join(mark_dir, d, f))
    if 0:  # 是否处理已标注数据?默认不处理
        marked_dir = op.join(path, 'marked')
        for d in os.listdir(marked_dir):
            if op.isdir(op.join(marked_dir, d)):
                for f in os.listdir(op.join(marked_dir, d)):
                    if len(re.findall(img_format, f)) > 0:
                        img_paths.append(op.join(marked_dir, d, f))

    other_count = 0
    for idx, img_path in enumerate(img_paths):
        print(f'\rProcess: {idx + 1}/{len(img_paths)}', end='')
        img_dir = op.dirname(img_path)
        res = req_classify(img_path)
        if res:
            if float(res['data']['result']['probability'][0]) > 0.9:
                cls_img = res['data']['result']['classes'][0]
                logger.info(f'{img_path} --> {cls_img}')
                if cls_img != cls_true:
                    logger.warning(
                        f'{img_path} --> {cls_img} is not {cls_true}')
                    shutil.move(img_dir,
                                op.join(others_dir, op.basename(img_dir)))
                    other_count += 1
    print(f'\nothers_count:{other_count}')
Example #15
0
    def crm_login(self):
        self.req_method = 'get'
        self.req_url = '/core/account/login'
        self.req_body = {
            "accountName": "*****@*****.**",
            "accountPassword": "******",  # 对应的明文是'Qwe123!@#'   589678262728104112
            "captcha": 'qwe123EWQ#@!'  # '262728293031'
        }
        result = self.x_request()
        assert_util.result_check(result)

        # 保存jsessionid,在core项目中用到
        core_jsessionid = result.rsp.cookies["JSESSIONID"]
        auth_util.set_cookie('crm', core_jsessionid)

        # 保存api_account_token,在蓝桥杯项目中用到
        api_account_token = result.rsp.cookies["api_account_token"]
        auth_util.set_gz_token('crm', api_account_token)
        logger.info(api_account_token)

        return result
Example #16
0
def lzp(request):
    func_sign_1 = str(request.function).split(' ')
    logger.info(func_sign_1)
    sun_sign = []

    # name_module = func_sign_1[4].split('.')[-2]
    name_module_tmp = 'sample_data'
    name_module = name_module_tmp + '.yml'
    logger.info('模块名:' + name_module)
    sun_sign.append(name_module)

    # name_cls = func_sign_1[2].split('.')[-2]
    name_cls = 'TestZeusMongo'
    logger.info('类名:' + name_cls)
    sun_sign.append(name_cls)

    # name_func = func_sign_1[2].split('.')[-1]
    name_func = 'test_reset_pwd2'
    logger.info('方法名:' + name_func)
    sun_sign.append(name_func)

    kwargs = data_pool.supply(sun_sign[0], sun_sign[2])
    return kwargs
Example #17
0
 def test_dbf_accept_zong_zi(self):
     logger.info("*************** 结束执行用例 ***************")
Example #18
0
	def test_pytest_collect_file(self, kwargs):
		# print("hello", path)
		# sun_sign_ret = lzp
		# print(sun_sign_ret)
		logger.info(kwargs)
Example #19
0
def sub_pay_audit_login_answer(kwargs, m_match_id, m_paper_id, m_exam_id):
    # 报名活动ID
    match_id = m_match_id
    # 试卷ID
    paper_id = m_paper_id
    # 考试ID,不是考试UUID
    exam_id = m_exam_id

    phone = kwargs['phone']
    userid = sql_util.sql_phone_to_userid(phone)
    # user.reset_pwd(userid)
    user.login(phone)
    # id_number = kwargs['identityNo']
    id_number = fakerist.ssn()
    kwargs['idNumber'] = id_number
    kwargs['matchId'] = match_id
    kwargs['dateOfBirth'] = "2012年08月11日"  # TODO
    kwargs['typeOfCertificate'] = 'IDCARD'  # TODO
    kid_name = fakerist.name()
    kwargs['participants'] = kid_name
    kwargs['guardian'] = kid_name + '的男妈妈'
    kwargs['city'] = fakerist.city()
    kwargs['mailbox'] = fakerist.email()
    kwargs['address'] = fakerist.street_address()
    kwargs['code'] = "123456"  # TODO
    kwargs['areaCode'] = "86"  # TODO
    kwargs['idPhoto'] = "https://competition/files/1625672893591.jpeg"
    kwargs['gender'] = fakerist.sex()
    kwargs['province'] = fakerist.province()  # 注意在非中文语种下会报错
    kwargs['region'] = fakerist.district()
    kwargs['provinceAndCity'] = f"{kwargs['province']},{kwargs['region']}"
    kwargs['school'] = fakerist.word()

    # 提交报名信息
    res = bbc_signUp.submit_registration_information(**kwargs)
    signin_id = res.sdata.get('id')
    logger.info(f"报名手机号是{phone}, 报名身份证是{id_number}, 报名ID是{signin_id}")

    # 下单支付-微信
    kwargs3 = data_pool.supply('bbc_signup_data.yml', 'create_order')[0]
    kwargs3['id'] = int(signin_id)
    # kwargs3['userId'] = userid
    # kwargs3['payType'] = 'ALI'  # fakerist.pay_type()
    res3 = bbc_signUp.create_order(**kwargs3)
    # TODO 会导致'prepay_id=null'

    # 模拟支付回调成功
    pay_record_id = res3.sdata.get("payrecordId")
    out_trade_no = sql_util.sql_payrecordid_to_outtradeno(pay_record_id)
    goods_order.pay_callback_suc(out_trade_no)

    # 审核通过
    kwargs4 = data_pool.supply('bbc_signup_data.yml', 'audit_pass')[0]
    kwargs4['enable'] = 1
    kwargs4['id'] = signin_id
    bbc_signUp.audit(**kwargs4)

    # 用户登录: 身份证-考试id为70
    # 将查到的userid保存到 临时的kwargs['userId'] 中用于后续的作品保存和答卷提交
    kwargs5 = data_pool.supply('bbc_submit_paper.yml', 'exam_login')[0]
    exam_uuid = sql_util.sql_examid_to_uuid(exam_id)
    kwargs5['examId'] = exam_uuid  # 考试uuid
    kwargs5['identityType'] = 'IDCARD'  # TODO
    kwargs5['identityNo'] = id_number
    kwargs5['phone'] = phone
    res5 = bbc_match.exam_login(**kwargs5)

    # # 保存作品 提交试卷的编程题4
    # 需要提前修改 subjectId
    kwargs6 = data_pool.supply('bbc_submit_paper.yml', 'save_project_43')[0]
    kwargs6['userId'] = userid
    kwargs6['subjectId'] = '560'
    kwargs6['examinationId'] = exam_id
    kwargs6['dataURL'] = "https://9c011017-e2a0-4cd8-86be-4982660c4e85.mxc"
    res6 = bbc_match.save_project(**kwargs6)
    assert res6.status is True
    # # 保存作品 提交试卷的编程题3
    kwargs7 = kwargs6
    kwargs6['userId'] = userid
    kwargs7['subjectId'] = '561'
    kwargs6['examinationId'] = exam_id
    kwargs7['dataURL'] = "https://e0519ef5-fdc9-4ecf-8129-b8bddcfb3d41.mxc"
    res7 = bbc_match.save_project(**kwargs7)
    assert res7.status is True

    # 提交试卷(非编程题部分)
    kwargs8 = data_pool.supply('bbc_submit_paper.yml',
                               'submit_official_paper')[0]
    # 实际上不是传userid,而是传 报名活动下的该用户自己的报名id
    kwargs8['userId'] = str(signin_id)
    kwargs8['examinationId'] = str(exam_id)
    kwargs8['testPaperId'] = int(paper_id)
    res8 = bbc_match.submit_official_paper(**kwargs8)
    # assert res8.status is True f返回false  # TODO 找开发改接口,返回data
    return res8
Example #20
0
 def request_log(self,
                 url,
                 data=None,
                 json=None,
                 params=None,
                 headers=None,
                 cookies=None,
                 files=None,
                 **kwargs):
     # Python3中需要设置 ensure_ascii=False,避免json在做dumps操作时将中文转换成unicode字符
     logger.info(f"请求URL     ==>> {url}")
     if headers is not None:
         logger.debug(f"请求header  ==>> {headers}")
     if cookies is not None:
         logger.info(f"请求cookies ==>> {cookies}")
     if params is not None:
         logger.info(f"请求params  ==>> {params}")
     if data is not None:
         logger.info(f"请求data    ==>> {data}")
     if json is not None:
         logger.info(f"请求json    ==>> {json}")
     if files is not None:
         logger.info(f"请求files   ==>> {files}")
Example #21
0
def save_match_enable(kwargs):
    res = bbc_signUp.save_match(**kwargs)
    match_id = res.sdata
    logger.info(f"创建的蓝桥杯赛事活动ID是{match_id}")
    res1 = bbc_signUp.enable(1, match_id)
    assert res1.status is True
Example #22
0
def step_first():
    logger.info("******************************")
    logger.info("前置步骤开始 ==>> 清理数据")
Example #23
0
def step_last():
    logger.info("后置步骤开始 ==>> 清理数据")
Example #24
0
def call_method(url):
    # result = base_requests.request("GET", url)
    res = requests.get(url)
    logger.info(res.text)
Example #25
0
def step_login(username, password):
    logger.info("前置步骤 ==>> 管理员 {} 登录,返回信息 为:{}".format(username, password))
Example #26
0
 def test_dbf_leader_board(self):
     logger.info("*************** 结束执行用例 ***************")
Example #27
0
 def test_dbf_set_time_running(self):
     # dbf.dbf_set_time('1624204800000', '1625065200000')  # 21-30 未开始
     dbf.dbf_set_time('1622476800000', '1625065200000')  # 1-30  进行中
     # dbf.dbf_set_time('1622476800000', '1622646000000')  # 1-2   已结束
     logger.info("*************** 结束执行用例 ***************")
Example #28
0
 def test_get_scoring_dimension_list(self):
     # logger.info("\n*************** 开始执行用例 ***************")
     result = project_pk.get_scoring_dimension_list()
     dimension_len = len(result.sdata)
     assert dimension_len > 0
     logger.info(f"评分维度总数 ==>> 期望大于0个, 实际结果:{dimension_len}")