def test_004_single_channel_statistics_default(self): """推广-渠道数据-单渠道统计-默认页面(按注册日期)""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'channel_summary_details', 4, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'channel_summary_details', 4, 6).get_body() payloads.update(StartDate=settings.str_today, EndDate=settings.str_today) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) # sql1 = "SELECT COUNT(id) FROM record_source_by_register_time WHERE register_date = '"+settings.str_today+"'" # sql2 = "SELECT page_uv, register_count, active_count, h5_register FROM record_source_by_register_time WHERE register_date = '"+settings.str_today+"' ORDER BY id LIMIT 1;" # # dbo1 = DbOperate(sql1).db_operate() # dbo2 = DbOperate(sql2).db_operate() self.assertEqual(res, 200)
def test_003_userInfo_black_list_register_time_today(self): """用户-用户管理-黑名单-注册时间-今天""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo_black_list', 3, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo_black_list', 3, 6).get_body() payloads.update(RegisterStartDate=settings.str_today, RegisterEndDate=settings.str_today) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql1 = "SELECT COUNT(*) FROM users_black ub LEFT JOIN users u ON u.id = ub.uid WHERE u.register_date = '" + settings.str_today + "'" sql2 = "SELECT ub.uid FROM users_black ub LEFT JOIN users u ON u.id = ub.uid WHERE u.register_date = '" + settings.str_today + "' ORDER BY ub.create_time LIMIT 1" dbo1 = DbOperate(sql1).db_operate() dbo2 = DbOperate(sql2).db_operate() self.assertEqual(res, 200) self.assertEqual(result["Result"]["UserSum"], dbo1[0]) if dbo2 != None: self.assertEqual(result["Result"]["List"][0]["Uid"], dbo2[0]) else: pass
def test_002_product_name(self): """运营-H5数据-数据明细-产品名称搜索""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'sysproduct_h5_date_detail', 2, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'sysproduct_h5_date_detail', 2, 6).get_body() payloads.update(StartDate=settings.str_today, EndDate=settings.str_today) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug('是测试点"%s"下的用例"%s",返回的结果res=%s]' % ( self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = "select pv1, pv2, uv, register_count from record_product_by_register_time where product_id = 357 and register_date = '"+settings.str_today+"'" dbo = DbOperate(sql).db_operate() self.assertEqual(res, 200) if dbo != None: self.assertEqual(result["SumPv1"], dbo[0]) self.assertEqual(result["SumPv2"], dbo[1]) self.assertEqual(result["SumUv"], dbo[2]) self.assertEqual(result["SumRegisterCount"], dbo[3]) else: pass
def test_008_userInfo_users_black_name_search(self): """用户-用户管理-黑名单-注册时间-姓名搜索""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo_black_list', 8, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo_black_list', 8, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql1 = "SELECT COUNT(*) FROM users_black ub LEFT JOIN users_info ui ON ui.uid = ub.uid WHERE ui.id_name = '黄超斌'" sql2 = "SELECT ub.uid FROM users_black ub LEFT JOIN users_info ui ON ui.uid = ub.uid WHERE ui.id_name = '黄超斌'" dbo1 = DbOperate(sql1).db_operate() dbo2 = DbOperate(sql2).db_operate() self.assertEqual(res, 200) self.assertEqual(result["Result"]["UserSum"], dbo1[0]) if dbo2 != None: self.assertEqual(result["Result"]["List"][0]["Uid"], dbo2[0]) else: pass
def test_011_firstApply_threeDays(self): """用户-申请记录-首次点击申请时间-近七天""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo_record_product_h5', 11, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo_record_product_h5', 11, 6).get_body() payloads.update(ApplyStartDate=settings.str_sevenDays, ApplyEndDate=settings.str_today) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = "select count(*) from record_product_h5 where first_apply_date between '" + settings.str_sevenDays + "' and '" + settings.str_today + "'" dbo = DbOperate(sql).db_operate() self.assertEqual(res, 200) if dbo[0] != None: self.assertEqual(result["Result"]["UserSum"], dbo[0]) else: pass
def test_003_register_time_today(self): """用户管理-搜索注册时间-今天""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo_list', 3, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo_list', 3, 6).get_body() payloads.update(RegisterStartDate=settings.str_today, RegisterEndDate=settings.str_today) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = "select count(*) from users where register_date = '" + settings.str_today + "'" dbo = DbOperate(sql).db_operate() self.assertEqual(res, 200) if dbo[0] != None: self.assertEqual(result["Result"]["UserSum"], dbo[0]) else: pass
def test_016_registerTime_userDefine(self): """用户-申请记录:注册时间-自定义""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo_record_product_h5', 16, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo_record_product_h5', 16, 6).get_body() payloads.update(RegisterStartDate=settings.str_nineDays, RegisterEndDate=settings.str_eightDays) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = "select count(*) from record_product_h5 where first_register_date between '" + settings.str_nineDays + "' and '" + settings.str_eightDays + "'" dbo = DbOperate(sql).db_operate() self.assertEqual(res, 200) if dbo[0] != None: self.assertEqual(result["Result"]["UserSum"], dbo[0]) else: pass
def test_006_userInfo_sysmessage(self): """用户-查看用户详情-查看-帖子记录/系统消息""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo', 6, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo', 6, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql1 = "SELECT COUNT(*) FROM users_msg WHERE uid = 1008624327" sql2 = "SELECT msg_title, msg_content FROM users_msg WHERE uid = 1008624327 ORDER BY create_time DESC LIMIT 1" dbo1 = DbOperate(sql1).db_operate() dbo2 = DbOperate(sql2).db_operate() self.assertEqual(res, 200) # 判段数据库搜索结果是否为空 if dbo1 != None: self.assertEqual(result["Result"]["UserSum"], dbo1[0]) # self.assertEqual(result["Result"]["List"][0]["MsgTitle"], dbo2[0]) # self.assertEqual(result["Result"]["List"][0]["MsgContent"], dbo2[1]) else: pass
def test_001_search_mobile(self): """用户管理-搜索手机号""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) # 读取token.yaml中的token值 Token = read_token.re_token() # 读取testcase_data.xlsx中的url与请求参数 url = ReadExcel(EXCEL_PATH, 'userinfo_list', 1, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo_list', 1, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = 'select id from users where account = "18768124236"' dbo = DbOperate(sql).db_operate() # 断言是否返回200 self.assertEqual(res, 200) # 断言返回结果数量是否一致 self.assertEqual(result["Result"]["UserSum"], 1) # 断言返回的id是否与该条件下数据库查询id一致 self.assertEqual(result["Result"]["List"][0]["Id"], str(dbo[0]))
def test_016_search_multiCondition(self): """用户-用户管理-综合查询:注册时间-全部,注册渠道-电销5,注册方式-H5,激活状态-已激活""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo_list', 12, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo_list', 12, 6).get_body() payloads.update(RegisterStartDate=settings.str_theDayBeforeYesterday, RegisterEndDate=settings.str_today) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = "SELECT COUNT(*) FROM `users` WHERE register_app = 5 AND out_put_source = '电销5' AND register_date BETWEEN '" + settings.str_sevenDays + "' AND '" + settings.str_today + "'" dbo = DbOperate(sql).db_operate() self.assertEqual(res, 200) if dbo != None: self.assertEqual(result["Result"]["UserSum"], dbo[0]) else: pass
def test_004_firstBrowsingTime_today(self): """申请记录-首次浏览时间-今天""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo_record_product_h5', 4, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo_record_product_h5', 4, 6).get_body() payloads.update(BrowseStartDate=settings.str_today, BrowseEndDate=settings.str_today) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = "select count(*) from record_product_h5 where first_browse_date = '" + settings.str_today + "'" dbo = DbOperate(sql).db_operate() self.assertEqual(res, 200) if dbo[0] != None: self.assertEqual(result["Result"]["UserSum"], dbo[0]) else: pass
def test_004_userInfo_h5list(self): """用户-用户管理-用户详情【查看】按钮-H5记录""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo', 4, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo', 4, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = "SELECT COUNT(ph.name) FROM record_product_h5 rp LEFT JOIN users u ON u.id=rp.uid LEFT JOIN product_h5 ph ON rp.product_id = ph.id WHERE u.id = '1008624327' AND rp.first_register_time IS NOT NULL" dbo1 = DbOperate(sql).db_operate() dbo2 = DbOperate(sql).db_operate_fetchall() self.assertEqual(res, 200) self.assertEqual(result["Result"]["UserSum"], dbo1[0]) self.assertEqual(result["Result"]["List"][0]["ProductName"], dbo2[0][0]) self.assertEqual(result["Result"]["List"][1]["ProductName"], dbo2[1][0])
def test_002_statistical_by_register_time(self): """推广-渠道数据-每日汇总-统计口径-按注册日期""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'channel_summary_details', 2, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'channel_summary_details', 2, 6).get_body() payloads.update(StartDate=settings.str_thirtyDays, EndDate=settings.str_today) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql1 = "SELECT SUM(page_uv), SUM(register_count), SUM(active_count), SUM(h5_uv), SUM(h5_register) FROM record_source_by_register_time WHERE register_date = '" + settings.str_yesterday + "'" sql2 = "SELECT SUM(register_count), SUM(active_count), SUM(h5_register) FROM record_source_by_register_time WHERE register_date BETWEEN '" + settings.str_thirtyDays + "' AND '" + settings.str_today + "'" sql3 = "SELECT COUNT(id) FROM users WHERE register_date = '" + settings.str_yesterday + "'" sql4 = "SELECT COUNT(id) FROM users WHERE register_date = '" + settings.str_yesterday + "' and login_date = '" + settings.str_yesterday + "'" sql5 = "SELECT COUNT(id) FROM users WHERE register_date BETWEEN '" + settings.str_thirtyDays + "' AND '" + settings.str_today + "'" sql6 = "SELECT COUNT(id) FROM users WHERE register_date = login_date AND register_date BETWEEN '" + settings.str_thirtyDays + "' AND '" + settings.str_today + "'" dbo1 = DbOperate(sql1).db_operate() dbo2 = DbOperate(sql2).db_operate() dbo3 = DbOperate(sql3).db_operate() dbo4 = DbOperate(sql4).db_operate() dbo5 = DbOperate(sql5).db_operate() dbo6 = DbOperate(sql6).db_operate() # 验证接口返回状态码 self.assertEqual(res, 200) # 断言请求返回的数据跟数据库record_source_by_register_time()查询数据是否一致 # 核对昨天进入产品详情页面的人数 self.assertEqual(result["Result"][1]["PageUv"], str(dbo1[0])) # 核对昨天APP的注册人数 self.assertEqual(result["Result"][1]["RegisterCount"], str(dbo1[1])) # 核对昨天的激活人数 self.assertEqual(result["Result"][1]["ActiveCount"], str(dbo1[2])) # 核对昨天的h5UV self.assertEqual(result["Result"][1]["H5Uv"], str(dbo1[3])) # 核对昨天的h5注册数 self.assertEqual(result["Result"][1]["H5Register"], str(dbo1[4])) # 核对总注册量 self.assertEqual(result["SumRegisterCount"], str(dbo2[0])) # 核对总激活量 self.assertEqual(result["SumActiveCount"], str(dbo2[1])) # 核对总H5注册量 self.assertEqual(result["SumH5Register"], str(dbo2[2])) # 断言请求返回数据跟数据库别的表查询数据是否一致 self.assertEqual(result["Result"][1]["RegisterCount"], str(dbo3[0])) self.assertEqual(result["Result"][1]["ActiveCount"], str(dbo4[0])) self.assertEqual(result["SumRegisterCount"], str(dbo5[0])) self.assertEqual(result["SumActiveCount"], str(dbo6[0]))
def test_008_single_channel_statistics_search_company_source(self): """推广-渠道数据-单渠道统计-渠道名称搜索""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'channel_summary_details', 8, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'channel_summary_details', 8, 6).get_body() payloads.update(StartDate=settings.str_eightDays, EndDate=settings.str_yesterday) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql1 = "SELECT SUM(register_count), SUM(active_count), SUM(h5_register) FROM record_source_by_register_time WHERE register_date BETWEEN '" + settings.str_eightDays + "' AND '" + settings.str_today + "' AND source = '电销5'" sql2 = "SELECT COUNT(*) FROM users WHERE register_date BETWEEN '" + settings.str_eightDays + "' AND '" + settings.str_today + "' AND out_put_source = '电销5'" sql3 = "SELECT COUNT(*) FROM users WHERE register_date = login_date AND register_date BETWEEN '" + settings.str_eightDays + "' AND '" + settings.str_today + "' AND out_put_source = '电销5'" dbo1 = DbOperate(sql1).db_operate() dbo2 = DbOperate(sql2).db_operate() dbo3 = DbOperate(sql3).db_operate() self.assertEqual(res, 200) # 判断record_source_by_register_time表与users表 数据是否相等 self.assertEqual(str(dbo1[0]), str(dbo2[0])) self.assertEqual(str(dbo1[1]), str(dbo3[0]))
def test_010_active_summary_source_name(self): """推广-渠道数据-激活汇总-渠道名称""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'channel_summary_details', 10, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'channel_summary_details', 10, 6).get_body() payloads.update(StartDate=settings.str_thirtyDays, EndDate=settings.str_today) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql1 = "SELECT COUNT(*) FROM users WHERE register_date='" + settings.str_tenDays + "' AND out_put_source = '电销5'" sql2 = "SELECT COUNT(*) FROM users WHERE login_date='" + settings.str_tenDays + "' AND out_put_source = '电销5'" # day1 sql3 = "SELECT count(DISTINCT u.id) FROM users as u LEFT JOIN login_record as lr ON u.id=lr.uid WHERE u.register_date = '" + settings.str_tenDays + "' AND lr.create_date = '" + settings.str_nineDays + "' AND u.out_put_source = '电销5'" # day2 sql4 = "SELECT count(DISTINCT u.id) FROM users as u LEFT JOIN login_record as lr ON u.id=lr.uid WHERE u.register_date = '" + settings.str_tenDays + "' AND lr.create_date = '" + settings.str_eightDays + "' AND u.out_put_source = '电销5'" # day3 sql5 = "SELECT count(DISTINCT u.id) FROM users as u LEFT JOIN login_record as lr ON u.id=lr.uid WHERE u.register_date = '" + settings.str_tenDays + "' AND lr.create_date = '" + settings.str_sevenDays + "' AND u.out_put_source = '电销5'" # day4 sql6 = "SELECT count(DISTINCT u.id) FROM users as u LEFT JOIN login_record as lr ON u.id=lr.uid WHERE u.register_date = '" + settings.str_tenDays + "' AND lr.create_date = '" + settings.str_sixDays + "' AND u.out_put_source = '电销5'" # day5 sql7 = "SELECT count(DISTINCT u.id) FROM users as u LEFT JOIN login_record as lr ON u.id=lr.uid WHERE u.register_date = '" + settings.str_tenDays + "' AND lr.create_date = '" + settings.str_fiveDays + "' AND u.out_put_source = '电销5'" # day6 sql8 = "SELECT count(DISTINCT u.id) FROM users as u LEFT JOIN login_record as lr ON u.id=lr.uid WHERE u.register_date = '" + settings.str_tenDays + "' AND lr.create_date = '" + settings.str_fourDays + "' AND u.out_put_source = '电销5'" # day7 sql9 = "SELECT count(DISTINCT u.id) FROM users as u LEFT JOIN login_record as lr ON u.id=lr.uid WHERE u.register_date = '" + settings.str_tenDays + "' AND lr.create_date = '" + settings.str_theDayBeforeYesterday + "' AND u.out_put_source = '电销5'" dbo1 = DbOperate(sql1).db_operate() dbo2 = DbOperate(sql2).db_operate() dbo3 = DbOperate(sql3).db_operate() dbo4 = DbOperate(sql4).db_operate() dbo5 = DbOperate(sql5).db_operate() dbo6 = DbOperate(sql6).db_operate() dbo7 = DbOperate(sql7).db_operate() dbo8 = DbOperate(sql8).db_operate() dbo9 = DbOperate(sql9).db_operate() self.assertEqual(res, 200) # 判断10天前(今天-9天)的数据是否正确 self.assertEqual(result["List1"][7]["RegisterCount"], dbo1[0]) self.assertEqual(result["List1"][7]["ActiveCount"], dbo2[0]) self.assertEqual(result["List1"][7]["Day1"], dbo3[0]) self.assertEqual(result["List1"][7]["Day2"], dbo4[0]) self.assertEqual(result["List1"][7]["Day3"], dbo5[0]) self.assertEqual(result["List1"][7]["Day4"], dbo6[0]) self.assertEqual(result["List1"][7]["Day5"], dbo7[0]) self.assertEqual(result["List1"][7]["Day6"], dbo8[0]) self.assertEqual(result["List1"][7]["Day7"], dbo9[0])
def test_007_data_detail(self): """运营-H5数据-数据明细-明细""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'sysproduct_h5_date_detail', 7, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'sysproduct_h5_date_detail', 7, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug('是测试点"%s"下的用例"%s",返回的结果res=%s]' % ( self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) self.assertEqual(res, 200)
def test_003_search_mobile(self): """短信记录-搜索手机号""" logger.logger.logger.debug('当前方法: %s' % p.get_current_function_name()) # 读取token.yaml中的token值 Token = read_token.re_token() # 读取testcase_data.xlsx中的url与请求参数 url = ReadExcel(EXCEL_PATH, 'userinfo_usermessage', 3, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo_usermessage', 3, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug('是测试点"%s"下的用例"%s",返回的结果res=%s]' % ( self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) self.assertEqual(res, 200)
def test_007_userInfo_userMessage(self): """用户-查看用户详情-查看-短信记录""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo', 7, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo', 7, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) self.assertEqual(res, 200)
def test_005_large_loan_list(self): """用户-用户管理-用户详情【查看】按钮-大额贷记录""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo', 5, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo', 5, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) self.assertEqual(res, 200)
def test_007_newsEdit(self): """运营-文章列表-查看文章""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'news_news_list', 7, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'news_news_list', 7, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) self.assertEqual(res, 200)
def test_011_imageEditList_2(self): """运营-广告管理-广告编辑(调用接口ImageEditList,参数"ImgState"="2")""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'sysproduct_image', 11, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'sysproduct_image', 11, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) self.assertEqual(res, 200)
def test_002_search_company(self): """推广-渠道管理-公司搜索""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'channel_list', 2, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'channel_list', 2, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) self.assertEqual(res, 200)
def test_003_addRecommend_sure(self): """运营-推荐位管理-添加-确定""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'sysproduct_down_list', 3, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'sysproduct_down_list', 3, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) self.assertEqual(res, 200)
def test_003_userInformation_newUsers(self): """用户-查看用户详情-新用户(未填写基础信息)""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo', 3, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo', 3, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) self.assertEqual(res, 200) self.assertEqual(result["RealNameInfo"]["IdNo"], "")
def test_005_single_channel_statistics_register_time(self): """推广-渠道数据-单渠道统计-按注册日期""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'channel_summary_details', 5, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'channel_summary_details', 5, 6).get_body() payloads.update(StartDate=settings.str_yesterday, EndDate=settings.str_yesterday) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql1 = "SELECT COUNT(rr.id), SUM(rr.register_count), SUM(rr.active_count), SUM(rr.h5_register) FROM source AS s LEFT JOIN record_source_by_register_time AS rr ON rr.source = s.source LEFT JOIN company AS c ON s.company_id = c.id WHERE rr.register_date = '" + settings.str_yesterday + "'" sql2 = "SELECT page_uv, register_count, active_count, h5_register FROM record_source_by_register_time WHERE register_date = '" + settings.str_yesterday + "' ORDER BY id LIMIT 1" sql3 = "SELECT COUNT(id) FROM users WHERE out_put_source = (SELECT source FROM record_source_by_register_time WHERE register_date = '" + settings.str_yesterday + "' ORDER BY id LIMIT 1) AND register_date = '" + settings.str_yesterday + "'" sql4 = "SELECT COUNT(id) FROM users WHERE out_put_source = (SELECT source FROM record_source_by_register_time WHERE register_date = '" + settings.str_yesterday + "' ORDER BY id LIMIT 1) AND register_date = '" + settings.str_yesterday + "' AND login_date = '" + settings.str_yesterday + "'" dbo1 = DbOperate(sql1).db_operate() dbo2 = DbOperate(sql2).db_operate() dbo3 = DbOperate(sql3).db_operate() dbo4 = DbOperate(sql4).db_operate() self.assertEqual(res, 200) # 断言请求返回的数据跟数据库record_source_by_happen_time()查询数据是否一致 self.assertEqual(result["UserSum"], dbo1[0]) self.assertEqual(result["SumRegisterCount"], str(dbo1[1])) self.assertEqual(result["SumActiveCount"], str(dbo1[2])) self.assertEqual(result["SumH5Register"], str(dbo1[3])) self.assertEqual(result["Result"][0]["PageUv"], str(dbo2[0])) self.assertEqual(result["Result"][0]["RegisterCount"], str(dbo2[1])) self.assertEqual(result["Result"][0]["ActiveCount"], str(dbo2[2])) self.assertEqual(result["Result"][0]["H5Register"], str(dbo2[3])) # 断言请求返回数据跟数据库别的表查询数据是否一致 self.assertEqual(result["Result"][0]["RegisterCount"], str(dbo3[0])) self.assertEqual(result["Result"][0]["ActiveCount"], str(dbo4[0]))
def test_007_single_channel_statistics_search_company(self): """推广-渠道数据-单渠道统计-公司搜索(按注册日期统计)""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'channel_summary_details', 7, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'channel_summary_details', 7, 6).get_body() payloads.update(StartDate=settings.str_yesterday, EndDate=settings.str_yesterday) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql1 = "SELECT COUNT(rr.id) FROM source AS s LEFT JOIN record_source_by_register_time AS rr ON rr.source = s.source LEFT JOIN company AS c ON s.company_id = c.id WHERE rr.register_date BETWEEN '" + settings.str_eightDays + "' AND '" + settings.str_yesterday + "' AND c. name = '多选科技'" sql2 = "SELECT SUM(rr.register_count), SUM(rr.active_count), SUM(rr.h5_register) FROM source AS s LEFT JOIN record_source_by_register_time AS rr ON rr.source = s.source LEFT JOIN company AS c ON s.company_id = c.id WHERE rr.register_date BETWEEN '" + settings.str_eightDays + "' AND '" + settings.str_yesterday + "' AND c. name = '多选科技'" # sql4 = "SELECT COUNT(id) FROM `users` WHERE register_date = '" + settings.str_yesterday + "'" # sql3 = "SELECT c.name, rr.source, rr.page_uv, rr.register_count, rr.active_count, rr.h5_register, rr.register_date FROM source AS s LEFT JOIN record_source_by_register_time AS rr ON rr.source = s.source LEFT JOIN company AS c ON s.company_id = c.id WHERE rr.register_date BETWEEN '" + settings.str_yesterday + "' AND '" + settings.str_yesterday + "' AND c. name = '多选科技'" sql5 = "SELECT COUNT(*) FROM source AS so LEFT JOIN company AS co ON so.company_id=co.id LEFT JOIN users AS u ON so.source=u.out_put_source WHERE u.register_date BETWEEN '" + settings.str_eightDays + "' AND '" + settings.str_yesterday + "' AND co.name='多选科技'" sql6 = "SELECT COUNT(*) FROM source AS so LEFT JOIN company AS co ON so.company_id=co.id LEFT JOIN users AS u ON so.source=u.out_put_source WHERE u.register_date = u.login_date AND u.register_date BETWEEN '" + settings.str_eightDays + "' AND '" + settings.str_yesterday + "' AND co.name='多选科技'" dbo1 = DbOperate(sql1).db_operate() dbo2 = DbOperate(sql2).db_operate() dbo5 = DbOperate(sql5).db_operate() dbo6 = DbOperate(sql6).db_operate() self.assertEqual(res, 200) # 断言请求返回的数据跟数据库record_source_by_register_time()查询数据是否一致 self.assertEqual(result["UserSum"], dbo1[0]) self.assertEqual(result["SumRegisterCount"], str(dbo2[0])) self.assertEqual(result["SumActiveCount"], str(dbo2[1])) self.assertEqual(result["SumH5Register"], str(dbo2[2])) # 断言请求返回数据跟数据库别的表查询数据是否一致 self.assertEqual(result["SumRegisterCount"], str(dbo5[0])) self.assertEqual(result["SumActiveCount"], str(dbo6[0]))
def test_004_billingMode_CPS(self): """运营-H5数据-数据明细-结算方式:按成交收费(CPS)""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'sysproduct_h5_date_detail', 4, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'sysproduct_h5_date_detail', 4, 6).get_body() payloads.update(StartDate=settings.str_today, EndDate=settings.str_today) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug('是测试点"%s"下的用例"%s",返回的结果res=%s]' % ( self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = "SELECT COUNT(DISTINCT ph.name) FROM product_h5 as ph INNER JOIN record_product_by_register_time as rp on ph.id = rp.product_id WHERE rp.register_date='" + settings.str_today + "' AND ph.billing_mode='CPS'" dbo = DbOperate(sql).db_operate() self.assertEqual(res, 200) self.assertEqual(result["UserSum"], dbo[0])
def test_001_today_register_date(self): """运营-H5数据-默认搜索(当天、按注册日期统计)""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'sysproduct_h5_date_detail', 1, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'sysproduct_h5_date_detail', 1, 6).get_body() payloads.update(StartDate=settings.str_today, EndDate=settings.str_today) result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug('是测试点"%s"下的用例"%s",返回的结果res=%s]' % ( self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = "select distinct count(product_id) from record_product_by_register_time where register_date = '"+settings.str_today+"'" dbo = DbOperate(sql).db_operate() self.assertEqual(res, 200) self.assertEqual(result["UserSum"], dbo[0])
def test_001_userInfo(self): """用户-查看用户详情-【查看】按钮userinfo""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo', 1, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo', 1, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = "select coalesce(out_put_source, market_source) from users where id='1008623658'" dbo = DbOperate(sql).db_operate() self.assertEqual(res, 200) self.assertEqual(result["List"]["MarketSource"], dbo[0])
def test_002_userInformation_oldUsers(self): """用户-查看用户详情-老用户(已填写基础信息)""" logger.logger.logger.debug('当前方法:%s' % p.get_current_function_name()) Token = read_token.re_token() url = ReadExcel(EXCEL_PATH, 'userinfo', 2, 3).get_url() payloads = ReadExcel(EXCEL_PATH, 'userinfo', 2, 6).get_body() result = post_request(url, payloads, Token) res = result["Ret"] logger.logger.logger.debug( '是测试点"%s"下的用例"%s",返回的结果res=%s]' % (self.__class__.__name__, getattr(self, self.get_current_function_name()).__doc__, res)) sql = "select id_no from users_info where account='18768124236'" dbo = DbOperate(sql).db_operate() self.assertEqual(res, 200) self.assertEqual(result["RealNameInfo"]["IdNo"], dbo[0])