def test_edit_profile(self, nickname): token = file_operation.read_file('token.json') body = { 'access_token': token['access_token'], 'birthday': '2000-01-01', 'city': '', 'nickname': nickname, 'province': '', 'sex': 3 } # print(json.dumps(body)) HmacSHA256.sh256(json.dumps(body)) path = '/api/user/edit_profile' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) print(response.text) datas = response.json() except Exception as e: print('出错了:', e) assert_that(response.json()['code']).is_equal_to(0) assert_that(datas['msg']).is_equal_to('请求成功')
def test_check_nickname_disabled_word(self, nickname): token = file_operation.read_file('token.json') body = {'access_token': token['access_token'], 'title': nickname} # print(json.dumps(body)) HmacSHA256.sh256(json.dumps(body)) path = '/api/user/check_nickname_disabled_word' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) print(response.text) datas = response.json()['data'] if datas['status']: print('没有禁词') else: print('包含禁词') except Exception as e: print('出错了:', e) assert_that(response.json()['code']).is_equal_to(0)
def test_recommend(self, page): config_path = readConfig.ReadConfig.get_config_path('path') body = {'page': page, 'pageSize': '20', 'app_key': 'lemondream'} # print(json.dumps(body)) HmacSHA256.sh256(json.dumps(body)) path = '/api/recommend/get_recommend_content_list' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) # print(response.text) dataList = response.json()['data'] obj_ids = get_response_value.get_target_value( 'obj_id', dataList, []) obj_id = {"obj_id": obj_ids[0]} print(obj_id) file_operation.write_file(obj_id, 'datas.json') tpyes = get_response_value.get_target_value('type', dataList, []) except Exception as e: print('出错了:', e) assert_that(response.status_code).is_equal_to(200) for i in range(0, len(tpyes)): assert_that(tpyes[i]).is_not_empty() assert_that(['1', '2', '4', '7', '8', '9', '10']).contains(tpyes[i])
def test_recommend_content(self, page): body = {"page": "1", "pageSize": "20", "app_key": "lemondream"} HmacSHA256.sh256(json.dumps(body)) path = '/api/recommend/get_recommend_content_list' url = readConfig.ReadConfig.get_http('baseurl') + path with open("../config/headers.json", 'r') as load_f: headers = json.load(load_f) print(headers) response = requests.post(url, json=body, headers=headers, verify=False) status = response.json()['msg'] self.assertEqual(status, '请求成功') print(response.text)
def test_user_home_page(self): token = file_operation.read_file('token.json') uid = file_operation.read_file('datas.json') body = {'user_id':uid['uid'],'access_token':token['access_token']} HmacSHA256.sh256(json.dumps(body)) path = '/api/user_home_page/get_user_home_page_info' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) print(response.text) # datas = response.json()['data'] except Exception as e: print('出错了:', e) assert_that(response.json()['code']).is_equal_to(0)
def test_get_module_unread(self): token = file_operation.read_file('token.json') body = {'access_token': token['access_token']} HmacSHA256.sh256(json.dumps(body)) path = '/api/app/get_module_unread' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) datas = response.json()['data'] except Exception as e: print('出错了:', e) assert_that(response.status_code).is_equal_to(200)
def test_get_external_content_info(self, value): body = {'content_id': 190648615} HmacSHA256.sh256(json.dumps(body)) path = '/api/External/get_external_content_info' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) # print(response.text) except Exception as e: print('出错了:', e) assert_that(response.json()['code']).is_equal_to(0) single_info = response.json()['data']['info'] assert_that(single_info['content']).is_not_none()
def test_get_recommend_tag(self): token = file_operation.read_file('token.json') body = {'access_token': token['access_token'], 'page': '1', 'pagesize': '12', } # print(json.dumps(body)) HmacSHA256.sh256(json.dumps(body)) path = '/api/user_tag/get_recommend_tag_list' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) # print(response.text) datas = response.json()['data'] print(datas['list']) assert_that(datas['list']).is_not_none() except Exception as e: print('出错了:', e) assert_that(response.status_code).is_equal_to(200)
def test_get_game_single_info(self, value): token = file_operation.read_file('token.json') body = {'single_id': value, 'access_token': token['access_token']} # print(json.dumps(body)) HmacSHA256.sh256(json.dumps(body)) path = '/api/adventure/get_game_single_info' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) # print(response.text) except Exception as e: print('出错了:', e) assert_that(response.json()['code']).is_equal_to(0) single_info = response.json()['data']['single_info'] assert_that(single_info['author_id']).is_not_none() assert_that(single_info['data_json']).is_not_none()
def test_third_login(self): config_path = readConfig.ReadConfig.get_config_path('path') body = { 'avatar': 'http://thirdqq.qlogo.cn/g?b=oidb&k=edlgyevh0NKzuOHe2SX6yg&s=100', 'birthday': '2000-01-01', 'city': '', 'device': 1, 'nickname': 'ssk', 'openid': 'FD717EC03696FFB9E78AADEC85E6565D', 'province': '', 'sex': 2, 'type': 2 } HmacSHA256.sh256(json.dumps(body)) path = '/api/user/third_login' url = readConfig.ReadConfig.get_http('baseurl') + path headers = file_operation.read_file('headers.json') try: response = requests.post(url, json=body, headers=headers, verify=False) datas = response.json()['data'] token = { 'access_token': datas['access_token'], 'refresh_token': datas['refresh_token'] } # print(token) file_operation.write_file(token, 'token.json') except Exception as e: print('出错了:', e) assert_that(response.json()['code']).is_equal_to(0) assert_that(datas['uid']).is_equal_to(1042) assert_that(datas['is_bind']).is_equal_to(1)
def test_get_tab_list(self): token = file_operation.read_file('token.json') body = { 'access_token': token['access_token'], 'page': '1', 'pagesize': '20' } HmacSHA256.sh256(json.dumps(body)) path = '/api/voice_template/get_tab_list' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) except Exception as e: print('出错了:', e) assert_that(response.status_code).is_equal_to(200)
def test_get_external_content_info(self, value): token = file_operation.read_file('token.json') body = {'content_id': value, 'access_token': token['access_token']} HmacSHA256.sh256(json.dumps(body)) path = '/api/External/get_external_content_info' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) info = response.json()['data']['info'] print(info['video_obj']) except Exception as e: print('出错了:', e) assert_that(response.json()['code']).is_equal_to(0) if info['type'] == 2: assert_that(info['type']).is_not_none() assert_that(info['video_obj']).contains_entry({'max_height': 1280}, {'max_width': 720}) elif type == 1: assert_that(info['video_obj']).is_empty()
def test_check_nickname(self, nickname): token = file_operation.read_file('token.json') body = {'access_token': token['access_token'], 'nickname': nickname} # print(json.dumps(body)) HmacSHA256.sh256(json.dumps(body)) path = '/api/user/check_nickname' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) print(response.text) datas = response.json()['data'] if datas['is_used'] == 0: print('可以调用编辑昵称接口') elif datas['is_used'] == 1: print('昵称已被占用') except Exception as e: print('出错了:',e) assert_that(response.json()['code']).is_equal_to(0)
def test_user_profile(self): token = file_operation.read_file('token.json') body = {'access_token': token['access_token']} # print(json.dumps(body)) HmacSHA256.sh256(json.dumps(body)) path = '/api/user/profile' url = readConfig.ReadConfig.get_http('baseurl') + path try: headers = file_operation.read_file('headers.json') response = requests.post(url, json=body, headers=headers, verify=False) # print(response.text) datas = response.json()['data'] except Exception as e: print('出错了:', e) assert_that(response.json()['code']).is_equal_to(0) assert_that(datas['id']).is_equal_to(1042) assert_that(datas['nickname']).is_not_none()