def test_01_get_token(self):  #编写测试用例
     url_params = {
         "grant_type": "client_credential",
         "appid": "wx351a03f64f7b147f",
         "secret": "d80a853d34c3fc7788a8cd9579302b84"
     }
     response = public_api_infos.get_access_token_api(
         self.session, url_params)
     json_obj = response.json()
     actual_result = jsonpath.jsonpath(json_obj, '$.expires_in')[0]
     self.assertEqual(actual_result, 7200)  #断言语句
 def test_02_grant_type_none(self):
     self._testMethodName = 'api_case_02'
     self._testMethodDoc = '验证grant_type为空时,获取token接口是否能正常处理'
     url_params = {
             "grant_type": "",
             "appid": "wx15938bc8b042cee0",
             "secret": "f01c3e1836d6b40fb24db5dbc0142253"
         }
     response = public_api_infos.get_access_token_api(self.session,url_params)
     json_body = response.json()
     actual_result = jsonpath.jsonpath(json_body,'$.errcode')[0]
     self.assertTrue(actual_result,40002)
 def test_02_grant_type_none(self):
     self._testMethodName = 'VXC_KS_002'
     self._testMethodDoc = '验证grant_type不填值时,获取access_token接口能否正常处理'
     url_params = {
         "grant_type": "",
         "appid": "wx55614004f367f8ca",
         "secret": "65515b46dd758dfdb09420bb7db2c67f"
     }
     response = public_api_infos.get_access_token_api(
         self.session, url_params)
     json_body = response.json()
     actual_result = jsonpath.jsonpath(json_body, '$.errcode')[0]
     self.assertEqual(actual_result, 40002)
 def test_02_appid_false(self):
     self._testMethodName = 'api_case_02'
     self._testMethodDoc = '测试获取access_token接口在appid错误时,能否正常处理错误'
     url_params = {
         "grant_type": "client_credential",
         "appid": "wxb4835daaf8499d",
         "secret": "4f78328f444f39760e2919ce248f317e"
     }
     # response = self.session.get(url='https://%s/cgi-bin/token'%self.hosts,
     #                             params=url_params)
     response = public_api_infos.get_access_token_api(self.session,url_params)
     json_body = response.json()
     actual_result = jsonpath.jsonpath(json_body,'$.errcode')[0]
     self.assertEqual(actual_result,40013)
 def test_01_get_access_token(self):
     '''[api_case_01]验证获取token接口能否正常调用'''
     logger.info('*                                  *')
     logger.info('*      用例[api_case_01]开始执行     *')
     try:
         url_params={
             "grant_type": "client_credential",
             "appid": "wx15938bc8b042cee0",
             "secret": "f01c3e1836d6b40fb24db5dbc0142253"
         }
         response = public_api_infos.get_access_token_api(self.session,url_params)
         json_body = response.json()
         actual_result=jsonpath.jsonpath(json_body,'$.access_token')[0]
         self.assertTrue(actual_result)
     except AssertionError as e:
         logger.info('*      用例[api_case_01]断言失败     *')
     except Exception as e:
         logger.error('%s'%e.__str__())
     finally:
         logger.info('*                                  *')
         logger.info('*      用例[api_case_01]执行结束     *')
 def test_01_get_access_token(self):
     logger.info('***********************************')
     logger.info('*     用例【VXC_KS_001】开始执行     *')
     try:
         url_params = {
             "grant_type": "client_credential",
             "appid": "wx55614004f367f8ca",
             "secret": "65515b46dd758dfdb09420bb7db2c67f"
         }
         response = public_api_infos.get_access_token_api(
             self.session, url_params)
         json_body = response.json()
         actual_result = jsonpath.jsonpath(json_body, '$.access_token')[0]
         self.assertTrue(actual_result)
     except AssertionError as e:
         logger.info('*     用例【VXC_KS_001】断言失败     *')
     except Exception as e:
         logger.error('%s' % e.__str__())
     finally:
         logger.info('*      用例【VXC_KS_001】执行结束    *')
         logger.info('***********************************')
 def test_01_get_access_token(self):
     logger.info('------------------------------------------')
     logger.info('-----执行第一条测试用例【获取access_token】----')
     try:
         url_params = {
             "grant_type": "client_credential",
             "appid": "wx70e792e1147fa788",
             "secret": "f44e3b57ff66ca6d632ee646974024c8"
         }
         response = public_api_infos.get_access_token_api(
             self.session, url_params)
         json_body = response.json()
         actual_result = jsonpath.jsonpath(json_body, '$.access_token')[0]
         logger.info('获取token成功【%s】' % actual_result)
         self.assertTrue(actual_result)  # 断言是否存在
     except AssertionError as e:
         logger.info('用例【获取access_token】断言失败')
     except Exception as e:
         logger.error('%s' % e.__str__())
     finally:
         logger.info('---执行第一条测试用例【获取access_token】结束---')
         logger.info('------------------------------------------')
Esempio n. 8
0
 def test_01_create_user_tag(self):
     self._testMethodName = 'VXC_YH_001'
     self._testMethodDoc = '验证调用创建标签接口能否成功创建'
     url_params = {
         "grant_type": "client_credential",
         "appid": "wx351a03f64f7b147f",
         "secret": "d80a853d34c3fc7788a8cd9579302b84"
     }
     # response = self.session.get(url='https://%s/cgi-bin/token' % self.hosts, params=url_params)
     response = public_api_infos.get_access_token_api(
         self.session, url_params)
     json_obj = response.json()
     token_id = jsonpath.jsonpath(json_obj, '$.access_token')[0]
     url_params = {"access_token": token_id}
     post_data = {"tag": {"name": "大学生8"}}
     post_data_str1 = json.dumps(post_data, ensure_ascii=False)
     # response = requests.post(url='https://%s/cgi-bin/tags/create'%self.hosts, params=url_params,
     #                             data=post_data_str1.encode('utf-8'))
     response = public_api_infos.creat_user_tag_api(self.session,
                                                    url_params, post_data)
     actual_result = jsonpath.jsonpath(response.json(), '$.tag.name')[0]
     self.assertEqual(actual_result, '大学生8')
 def test_01_get_access_token(self):
     ''' 【api_case_01】测试获取access_token能否正常调用 '''
     logger.info('*********************************************')
     logger.info('*          用例[api_case_01]开始执行          *')
     try:
         url_params = {
             "grant_type": "client_credential",
             "appid": "wxb4835daaf8499dbe",
             "secret": "4f78328f444f39760e2919ce248f317e"
         }
         # response = self.session.get(url='https://%s/cgi-bin/token'%self.hosts,
         #                             params=url_params)
         response = public_api_infos.get_access_token_api(self.session,url_params)
         json_body = response.json()
         actual_result = jsonpath.jsonpath(json_body,'$.expires_in')[0]
         self.assertEqual(actual_result,7200)
     except Exception as e:
         logger.info('*          用例[api_case_01]断言失败          *')
     except RequestException as e:
         logger.error('%s'%e.__str__())
     finally:
         logger.info('*          用例[api_case_01]执行结束          *')
         logger.info('*********************************************')