Пример #1
0
 def get_case_data_act_crm(self, **kwargs):
     """
     真实数据获取
     1、设置headers
     2、获取response
     3、获取字典格式的response
     :return:实际结果
     """
     headers = copy.copy(setting.REQUEST_HEADER)
     headers['content-type'] = self.contype['content-type']
     for i in kwargs:
         if i == "access_token":
             headers['Cookie'] = kwargs[i]
     act_resp_handle = restquests_module.Get_Response(
         self.url, rev_method=self.method)
     if (headers['content-type'] == 'application/json'):
         act_resp_cur = act_resp_handle.get_response(data=json.dumps(
             self.data),
                                                     headers=headers)
     else:
         act_resp_cur = act_resp_handle.get_response(data=self.data,
                                                     headers=headers)
     # act_resp_cur = act_resp_handle.get_response(data=self.data, headers=headers)
     resp_analysis = restquests_module.Analysis_Response(act_resp_cur)
     act_resp = resp_analysis.STR_CONTENT
     cookies = requests.utils.dict_from_cookiejar(resp_analysis.COOKIES)
     print "\n" + "Input"
     print json.dumps(self.data)
     logging.debug("-----------------data---------------------------" +
                   json.dumps(self.data))
     logging.debug("-----------------2.real-------------------------" +
                   act_resp)
     return act_resp, cookies
Пример #2
0
def get_aes_encrypt(key, data):
    __get_resp = restquests_module.Get_Response(url_resource.ENCRYPT_TOOL)
    __data = {'key': key, 'data': data}
    __resp = __get_resp.get_response(params=__data)
    __an_resp = restquests_module.Analysis_Response(__resp)
    __resp = __an_resp.STR_CONTENT
    return __resp
Пример #3
0
def get_sign(cid=None, q=None, uid='', aes_key=''):
    __sign_str = "cid=%s;q=%s%s%s" % (cid, q, uid, aes_key)
    __get_resp = restquests_module.Get_Response(url_resource.MD5_TOOL)
    __data = {'data': __sign_str}
    logging.info(__data)
    __resp = __get_resp.get_response(params=__data)
    __an_resp = restquests_module.Analysis_Response(__resp)
    __resp = __an_resp.STR_CONTENT
    return __resp
Пример #4
0
def get_aes_decrypt(key, data):
    __get_resp = restquests_module.Get_Response(url_resource.DECRYPT_TOOL)
    __data = {'key': key, 'data': data}
    __resp = __get_resp.get_response(params=__data)
    __an_resp = restquests_module.Analysis_Response(__resp)
    __resp = __an_resp.STR_CONTENT
    logging.debug("json格式的response = %s" % __resp)
    __resp = json.loads(__resp)
    # __resp = unicode_to_utf(__resp)
    return __resp
Пример #5
0
 def get_case_data_act2(self, url, method, data):
     """
     真实数据获取
     1、设置headers
     2、获取response
     3、获取字典格式的response
     :return:实际结果
     """
     headers = copy.copy(setting.REQUEST_HEADER)
     act_resp_handle = restquests_module.Get_Response(url, method)
     act_resp_cur = act_resp_handle.get_response(data=data, headers=headers)
     resp_analysis = restquests_module.Analysis_Response(act_resp_cur)
     act_resp = resp_analysis.STR_CONTENT
     print "\n" + "Input"
     print json.dumps(self.data)
     logging.debug("-----------------data---------------------------" +
                   json.dumps(self.data))
     logging.debug("-----------------headers---------------------------" +
                   json.dumps(headers))
     logging.debug("-----------------2.real-------------------------" +
                   act_resp)
     return act_resp