def test_get_create_usertag(self): self._testMethodName = 'api_case_05' self._testMethodDoc = '获取已创建的用户标签接口' token_id = public_api_infos.get_access_token(self.session) url_params = {"access_token": token_id} response = public_api_infos.get_create_usertag(self.session, url_params) print(response.text) actual_result = jsonpath.jsonpath(response.json(), '$.tags[0].name')[0] self.assertEqual(actual_result, "星标组", 'api_case_05用例执行成功')
def test_01_get_access_token(self): self._testMethodName = 'API_CASE_03' self._testMethodDoc = '测试正常进行创建标签接口调用' logger.info('正在执行【%s】' % self._testMethodDoc) token_id = public_api_infos.get_access_token(self.session) url_params = {"access_token": token_id} tag_info = {"tag": {"name": "贵州贵阳09"}} response = public_api_infos.create_user_tag_api(self.session, url_params, tag_info) actual_result = jsonpath.jsonpath(response.json(), '$.tag.name')[0] self.assertEqual(actual_result, '贵州贵阳09')
def test_tagid_0(self): self._testMethodName = 'VXC_YH_003' self._testMethodDoc = '验证不能删除标签id为0的标签' token_id = public_api_infos.get_access_token(self.session) url_params = { "access_token":token_id } post_data = { "tag":{ "id" : 0 } } response = public_api_infos.delete_user_tag_api(self.session,url_params,post_data) actual_result = jsonpath.jsonpath( response.json(),'$.errcode' )[0] self.assertEqual( actual_result , 45058 ,'[VXC_YH_003]用例执行失败')
def test_01_create_user_tag(self): self._testMethodName = 'VXC_YH_002' self._testMethodDoc = '验证调用创建标签接口,标签名参数与已存在的标签重名能否正常处理' token_id = public_api_infos.get_access_token(self.session) url_params = { "access_token":token_id } post_data_json = { "tag" : { "name" : "湖南长沙" } } response = public_api_infos.create_user_tag_api(self.session,url_params,post_data_json) actual_result = jsonpath.jsonpath( response.json(),'$.errcode' )[0] self.assertEqual( actual_result,45157 )
def test_delect_tagsID_0(self): self._testMethodName = 'API_CASE_04' self._testMethodDoc = '验证不能删除tagsId为0的标签' logger.info('执行用例【%s】' % self._testMethodDoc) token_id = public_api_infos.get_access_token(self.session) logger.info('获取token成功') url_params = {"access_token": token_id} post_data = {"tag": {"id": 0}} response = public_api_infos.delect_user_tag_api( self.session, url_params, post_data) actual_result = jsonpath.jsonpath(response.json(), '$.errcode')[0] self.assertEqual(actual_result, 45058, 'API_CASE_04用例执行失败')
def test_gettag_fans_list(self): self._testMethodName = 'api_case_07' self._testMethodDoc = '获取标签下粉丝列表接口' token_id = public_api_infos.get_access_token(self.session) url_params = {"access_token": token_id} post_data_json = {"tagid": 9990, "next_openid": ""} response = public_api_infos.gettag_fans_list(self.session, url_params, post_data_json) actual_result = jsonpath.jsonpath(response.json(), '$.next_openid')[0] self.assertEqual(actual_result, "ojxbq6qbXhwaqnYj2L-DJJLXU4eU", 'api_case_07用例执行成功')
def test_01_create_user_tag(self): self._testMethodName = 'api_case_03' self._testMethodDoc = '验证调用创建标签接口,标签名参数已存在的标签名能否正常处理' token_id = public_api_infos.get_access_token(self.session) url_params = { "access_token": token_id } post_data_json = {"tag": {"name": "湖南长沙"}} response = public_api_infos.create_user_tag_api(self.session,url_params,post_data_json) print(response.json()) actual_result = jsonpath.jsonpath(response.json(),'$.errcode')[0] #返回数组取值'$.tag.name' self.assertTrue(actual_result,45157)
def test_update_usertag(self): self._testMethodName = 'api_case_06' self._testMethodDoc = '更新用户标签接口' token_id = public_api_infos.get_access_token(self.session) url_params ={ "session_token": token_id } post_data_json = {"tag": {"id": 100, "name": "13366"}} response = public_api_infos.update_usertag(self.session, url_params, post_data_json) actual_result = jsonpath.jsonpath(response.json(), '$.errcode')[0] self.assertEqual(actual_result, 0, 'api_case_06用例执行结束')
def test_tagid_0(self): self._testMethodName = 'VXC_YH_003' self._testMethodDoc = '验证不能删除标签id为0的标签' token_id = public_api_infos.get_access_token(self.session) ''' url_params = { "grant_type": "client_credential", "appid": "wxb4835daaf8499dbe", "secret": "4f78328f444f39760e2919ce248f317e" } response = public_api_infos.get_access_token_api(self.session,url_params) json_body = response.json() token_id = jsonpath.jsonpath(json_body,'$.access_token')[0] ''' url_params = {"access_token": token_id} post_data = {"tag": {"id": 0}} response = public_api_infos.delete_user_tag_api( self.session, url_params, post_data) actual_result = jsonpath.jsonpath(response.json(), '$.errcode')[0] self.assertEqual(actual_result, 45058, '[VXC_YH_003]用例执行失败')