Exemplo n.º 1
0
 def test_get_access_token03_error_secret(self):
     self._testMethodDoc = '验证asecret错误,access_token获取失败'
     response = API().get_access_token_value("wx6245840484d8734b",
                                             "b2aa7a7874a7b")
     actual_result = response.json()['errcode']
     self.assertEqual(actual_result, 40125,
                      'case03 : 获取access_token接口调用失败!')
     logger.info(actual_result)
Exemplo n.º 2
0
 def test_get_access_token02_error_appid(self):
     self._testMethodDoc = '验证appid错误,access_token获取失败'
     response = API().get_access_token_value(
         "wx6245840484d8734b1111", "b2aa7a7874a77d1350f9822a53d838eb")
     actual_result = response.json()['errcode']
     self.assertEqual(actual_result, 40013,
                      'case02 : 获取access_token接口调用失败!')
     logger.info(actual_result)
Exemplo n.º 3
0
 def test_create_tag02_Duplicate_Label(self):
     self._testMethodDoc = 'Case02'
     self._testMethodDoc = '验证编辑标签重复'
     post_dict = {   "tag" : {     "name" : 'H7HENu' } }
     token_id = Base().get_token()
     response = self.session.post(url='https://api.weixin.qq.com/cgi-bin/tags/update?access_token=%s'%token_id,
                                  json=post_dict)
     actual_result = response.json()['errcode']
     self.assertEqual(actual_result,45157,'Case02 标签重复,编辑标签失败')
     logger.info(response.json())
Exemplo n.º 4
0
 def test_update_tag03_default_tag(self):
     self._testMethodDoc = 'Case02'
     self._testMethodDoc = '验证不能修改0/1/2这三个系统默认保留的标签'
     ramdonstr = Base().randomStr(5)
     token_id = Base().get_token()
     post_dict = {   "tag" : {     "id" : 1,     "name" : ramdonstr   } }
     response = self.session.post(url='https://api.weixin.qq.com/cgi-bin/tags/update?access_token=%s'%token_id,
                                  json=post_dict)
     actual_result = response.json()['errcode']
     self.assertEqual(actual_result,45058,'Case02 不能修改0/1/2这三个系统默认保留的标签,编辑标签失败')
     logger.info(response.json())
Exemplo n.º 5
0
 def test_get_access_token01_success(self):
     self._testMethodDoc = '验证token_success接口成功调用'
     response = API().get_access_token_default_value()
     actual_result = response.status_code
     self.assertEqual(actual_result, 200, 'case01 : 获取access_token接口调用成功!')
     yamlpath = os.path.join(os.path.dirname(__file__), '..',
                             config.yamal_path)
     access_token = response.json()
     logger.info(access_token)
     with open(yamlpath, 'w+', encoding='utf-8') as f:
         yaml.dump(access_token, f, Dumper=yaml.RoundTripDumper)
Exemplo n.º 6
0
 def test_update_tag01_success(self):
     self._testMethodDoc = 'Case01'
     self._testMethodDoc = '验证修改标签成功'
     ramdonstr = Base().randomStr(5)
     token_id = Base().get_token()
     tag_id = Base().get_tag_id()
     print(tag_id)
     post_dict = {   "tag" : {     "id" : tag_id,     "name" : ramdonstr   } }
     response = self.session.post(url='https://api.weixin.qq.com/cgi-bin/tags/update?access_token=%s'%token_id,
                                  json=post_dict)
     ascual_result = response.json()['errmsg']
     self.assertEqual(ascual_result,'ok','Case01 编辑标签成功')
     logger.info(response.json())
Exemplo n.º 7
0
 def test_create_tag04_Tag_More_than_100(self):
     self._testMethodDoc = 'Case04'
     self._testMethodDoc = '创建的标签数过多,超过100'
     random1 = Base().randomStr(31)
     post_dict = {"tag": {"name": random1}}
     token_id = Base().get_token()
     response = self.session.post(
         url='https://api.weixin.qq.com/cgi-bin/tags/create?access_token=%s'
         % token_id,
         json=post_dict)
     actual_result = response.json()['errcode']
     self.assertEqual(actual_result, 45056, 'case04 创建的标签数过多,超过100,标签创建失败')
     logger.info(response.json())
Exemplo n.º 8
0
 def test_create_tag03_longTagName(self):
     self._testMethodDoc = 'Case03'
     self._testMethodDoc = '标签名长度超过30个字节,标签创建失败'
     random1 = Base().randomStr(31)
     post_dict = {"tag": {"name": random1}}
     token_id = Base().get_token()
     response = self.session.post(
         url='https://api.weixin.qq.com/cgi-bin/tags/create?access_token=%s'
         % token_id,
         json=post_dict)
     actual_result = response.json()['errcode']
     self.assertEqual(actual_result, 45158, 'case03 标签名长度超过30个字节,标签创建失败')
     logger.info(response.json())
Exemplo n.º 9
0
    def test_delete_tag01_success(self):
        self._testMethodDoc = 'Case01'
        self._testMethodDoc = '验证删除标签成功'
        token_id = Base().get_token()
        tag_id = Base().get_tag_id()
        post_dict = {"tag": {"id": tag_id}}
        response = self.session.post(
            url='https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=%s'
            % token_id,
            json=post_dict)

        actual_result = response.json()['errmsg']
        self.assertEqual(actual_result, 'ok', '删除标签成功')
        logger.info(response.json())
Exemplo n.º 10
0
    def test_create_tag01_success(self):
        self._testMethodDoc = 'Case01 '
        self._testMethodDoc = '验证创建标签接口调用成功'
        random1 = Base().randomStr(6)
        post_dict = {"tag": {"name": random1}}
        token_id = Base().get_token()
        response = self.session.post(
            url='https://api.weixin.qq.com/cgi-bin/tags/create?access_token=%s'
            % token_id,
            json=post_dict)

        actual_result = response.json()['tag']['name']
        self.assertEqual(actual_result, random1, 'case01 验证create_tag接口能否成功调用')
        logger.info(response.json())

        yamlpath = os.path.join(os.path.dirname(__file__), '../../',
                                config.yamal_path)
        print(yamlpath)
        tag_id = response.json()
        with open(yamlpath, 'a', encoding='utf-8') as f:
            yaml.dump(tag_id, f, Dumper=yaml.RoundTripDumper)