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
class GetTestlinkCaseDate: def __init__(self): self.url = '' self.method = '' self.data_res = '' self.exp_resp = '' self.data = '' def get_case_data(self, case_name='test'): try: self.ret = testlink_module.TestLink_Module().get_case(case_name) except Exception, e: logging.error("------------调用testlink出错!------------") print e self.data = json.loads(self.ret[0])["data"] self.url = env_module.Env_Module().get_env_url() + json.loads(self.ret[0])["path"] self.method = json.loads(self.ret[0])["method"] """期望返回值获取""" exp_resp = self.ret[1] logging.info("------------期望值是:------------" + json.dumps(exp_resp)) print exp_resp # # data = "a=%s" % json.dumps({"b": "c"}) """真实返回值获取""" headers = setting.REQUEST_HEADER act_resp_handle = restquests_module.Get_Response(self.url, rev_method=self.method) act_resp = act_resp_handle.get_response(data=self.data, headers=headers).text logging.info("------------真实值是:------------" + json.dumps(act_resp)) print act_resp # resp_analysis = restquests_module.Analysis_Response(act_resp) # act_resp_dic = resp_analysis.DIC_CONTENT # self.assertIn(expect, act_resp, "notmatch") return exp_resp, act_resp
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
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
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
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
def setUp(self): self.se = restquests_module.Get_Response('get').with_session print "setup"