def test_02_user_login(self): r = APIUtils.send_request(self.url_data.get('user_login')) data = dict(r.json()) # assert 'OK' in data_fj.get('message') assert 200 == r.status_code userinfo = data.get('data') assert userinfo is not None if userinfo is not None: constant.user_info = None DataUtils.set_data(userinfo, 'user_info.yaml')
def get_gift_list(): """礼物列表""" get_my_follow_param = {'page': 1, 'size': 20} # r = requests.get(get_gift_list_url, headers=DataUtils.get_user_info(), params=get_my_follow_param) print(get_gift_list_url) r = requests.get(get_gift_list_url, headers=DataUtils.get_user_info()) print(r) print(r.json()) data = dict(r.json()) DataUtils.set_data(data.get('data_fj').get('list'), 'gift_list.yaml') FileUtils.downdload_gift_icon() return r
def get_current_ranking(owneruid: int): """本场守护榜""" top_ranking_param = {'owner_uid': owneruid} r = requests.get(constant.gift_current_ranking_url, headers=DataUtils.get_user_info(), params=top_ranking_param) print(r) print(r.json())
def downdload_gift_icon(): file_path = BASE_DIR + os.sep + 'data_fj' + os.sep + 'giftdata' FileUtils.clear_file(file_path) dataList = DataUtils.get_yaml_data('gift_list.yaml') # print(dataList) for i in range(len(dataList)): iconUrl = dataList[i].get('icon') fileName = file_path + os.sep + 'gift' + '_' + str(dataList[i].get('gift_id')) + '_' + dataList[i].get( 'name') + '.png' DownLoadThread(iconUrl, fileName).start()
def get_top_ranking(owneruid: int): ''' 守护总榜单 :param owneruid: 房间拥有者id :return: ''' top_ranking_param = {'owner_uid': owneruid} r = requests.get(constant.gift_top_ranking_url, headers=DataUtils.get_user_info(), params=top_ranking_param) print(r) print(r.json())
def live_report(reportee, room_id): """直播间举报""" live_report_param = { # "reporter": DataUtils.get_user_info('user').get('uid'), "reportee": reportee, "report_type": 1, "reason": "hahaha6666", "room_id": room_id, "reportee_type": 1 # "pics": "[]" } r = requests.post(constant.live_report_url, headers=DataUtils.get_user_info(), json=live_report_param) print(r.json())
def send_request(params_data): url = constant.BASE_URL + params_data.get('url') params = params_data.get('params') type = params_data.get('type').lower() header = DataUtils.get_user_info() header.update(FanjiaoConfig.signature_fj(params, type)) requests.DEFAULT_RETRIES = 5 s = requests.session() s.keep_alive = False if 'get'.__eq__(type): r = requests.get(url, headers=header, params=params, timeout=10) else: r = requests.post(url, headers=header, json=params, timeout=10) LogUtils.print_response(r, params_data.get('comment')) return r
def get_curl_command1(type, *data): ''' :param type: 接口类型 get post :param data: url ,params :return: ''' datas: dict = DataUtils.get_yaml_data('curl_model.yaml') # print(datas) typedata: str = datas.get(type) if type == 'post': url, params = data command = typedata.format(url, params) else: url = data[0] command = typedata.format(url) print(command) return command
def __init__(self): self.url_data = DataUtils.get_yaml_data('t04_cv_info_api_data.yaml')
def user_login(self): r = APIUtils.send_request(self.url_data, 'user_login') datas = r.json().get('data_fj') if datas is not None: DataUtils.set_data(datas, 'user_info.yaml') return r
def __init__(self): self.url_data = DataUtils.get_yaml_data('t01_login_api_data.yaml')
def setUp(self) -> None: self.url_data = DataUtils.get_yaml_data('t03_my_api_data.yaml')
def setUp(self) -> None: self.url_data = DataUtils.get_yaml_data('t07_account_api_data.yaml')
def setUp(self) -> None: self.url_data = DataUtils.get_yaml_data('t08_comment_api_data.yaml')
def __init__(self): self.url_data = DataUtils.get_yaml_data('t03_my_api_data.yaml')
def setUp(self) -> None: self.url_data = DataUtils.get_yaml_data('t05_album_info_api_data.yaml')