def test_create_tag(self):
        self._testMethodName = 'case04'
        self._testMethodDoc = '验证create_tag接口能否成功调用'
        '''
        get_param_dict = {
            "grant_type": "client_credential",
            "appid": "wx55614004f367f8ca",
            "secret": "65515b46dd758dfdb09420bb7db2c67f"
        }
        response = self.session.get(url='https://%s/cgi-bin/token' % self.HOSTS,
                                  params=get_param_dict)'''
        response = api_info.get_access_token_api(
            self.session, self.HOSTS, 'wx55614004f367f8ca',
            '65515b46dd758dfdb09420bb7db2c67f')
        token_id = response.json()['access_token']
        post_data = {"tag": {"name": "南P4"}}
        token_id = api_info.get_access_token_value(self.session, self.HOSTS)
        ''' str_data=json.dumps(post_data,ensure_ascii=False) #把json数据转化成字符串
        print( str_data)
        response = self.session.post(url='https://api.weixin.qq.com/cgi-bin/tags/create?access_token=%s'%token_id,
                                             #json=post_data
                                             data=str_data.encode('utf-8'))'''

        response = api_info.create_user_tag_api(self.session, self.HOSTS,
                                                token_id, post_data)
        actual_result = response.json()['tag']['name']
        self.assertEqual(actual_result, '南P4', 'case04 验证create_tag接口能否成功调用')
示例#2
0
    def test_create_tag(self):
        requests.packages.urllib3.disable_warnings()

        self._testMethodName = 'case04'
        self._testMethodDoc = '验证create_tag接口能否成功调用'
        # get_param_dict = {
        #     "grant_type": "client_credential",
        #     "appid": "wx55614004f367f8ca",
        #     "secret": "65515b46dd758dfdb09420bb7db2c67f"
        # }
        # response = self.session.get(url='https://%s/cgi-bin/token' % self.HOSTS,
        #                             params=get_param_dict, verify=False)
        # token_id = response.json()['access_token']
        # print(token_id)

        post_data = {"tag": {"name": "广东浪子"}}  #
        str_data = json.dumps(post_data, ensure_ascii=False)
        print(str_data)
        token_id = get_access_token_value(self.session, self.HOSTS)
        response = self.session.post(
            url='https://api.weixin.qq.com/cgi-bin/tags/create?access_token=%s'
            % token_id,
            data=str_data.encode('utf-8'),
            verify=False)  #json传递数据时会把python字典中的中文转化为unicode编码
        print(response.json())
        actual_result = response.json()['tag']['name']
        self.assertEqual(actual_result, '广东浪子', '验证create_tag接口能否成功调用')
 def test_create_tag(self):
     self._testMethodName = 'case04'
     self._testMethodDoc = '验证create_tag接口能否成功调用'
     token_id = api_info.get_access_token_value(self.session,self.HOSTS)
     post_data = {   "tag" : {     "name" : "梦想P3"   } }
     response = api_info.create_user_tag_api(self.session,self.HOSTS,token_id,post_data)
     actual_result = response.json()['tag']['name']
     self.assertEqual(actual_result,'梦想P3','case04 验证create_tag接口能否成功调用')
 def test_create_tag(self):
     self._testMethodName = 'case05'
     self._testMethodDoc = '验证create_tag接口是否正常'
     logger.info('case02 验证test_create_tag接口是否正常 --开始执行--')
     token_id = api_info.get_access_token_value(self.session, self.HOSTS)
     # 创建标签
     post_data = {"tag": {"name": "圣罗3"}}
     response = api_info.test_create_tag(self.session, self.HOSTS, token_id,
                                         post_data)
     actula_result = response.json()['tag']['name']
     logger.info('case02 验证test_create_tag接口是否正常 --执行结束--')
     self.assertEqual(actula_result, '圣罗3', 'case05 验证create_tag接口是否正常处理')
示例#5
0
    def test_delete_tag(self):

        self._testMethodName = 'case04'
        self._testMethodDoc = '验证create_tag接口能否成功调用'
        # get_param_dict = {
        #     "grant_type": "client_credential",
        #     "appid": "wx55614004f367f8ca",
        #     "secret": "65515b46dd758dfdb09420bb7db2c67f"
        # }
        # response = self.session.get(url='https://%s/cgi-bin/token' % self.HOSTS,
        #                             params=get_param_dict, verify=False)
        # token_id = response.json()['access_token']
        token_id = get_access_token_value(self.session, self.HOSTS)
        post_data = {"tag": {"id": 532}}
        response = self.session.post(
            url='https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=%s'
            % token_id,
            json=post_data,
            verify=False)
        print(response.json())
        actual_result = response.json()['errmsg']
        self.assertEqual('ok', actual_result, '验证create_tag删除接口能否成功调用')