def test_01_Login1(self):
     #开始第一个get请求获取sessionid和sessiondata
     self.url1 = Login_Element.login_url1
     params1 = Login_Element.params1
     self.params1 = params1
     response1 = requests.get(url=self.url1, params=self.params1)
     print("status_code1:" + str(response1.status_code))
     sessionid = Fun.getSessionId(response1.text)
     self.sessionid = sessionid
     sessiondata = Fun.getSessionData(response1.text)
     self.sessiondata = sessiondata
     #开始第二个post请求
     self.url2 = Login_Element.login_url2
     message2 = {"sessionId": sessionid, "sessionData": sessiondata}
     message2_2 = Fun.merge_Two_Dicts(Login_Element.message2, message2)
     header2 = Login_Element.header2
     print(message2_2)
     print(type(message2_2))
     response2 = requests.post(url=self.url2,
                               data=message2_2,
                               headers=header2)
     print("status_code2:" + str(response2.status_code))
     #获取token请求
     self.url3 = Login_Element.login_url3
     message3 = {"sessionId": sessionid}
     header3 = Login_Element.header3
     response3 = requests.post(url=self.url3,
                               data=message3,
                               headers=header3)
     print("status_code3:" + str(response3.status_code))
     print("token:" + response3.text)
     token_info = Fun.re_write(response3.text)
     Fun.save_to_jsonfile('../common/token.json', token_info)
 def test_1_getToken(self):
     print("get Token")
     url1 = self.url1 = Login_getToken.login_url
     header1 = Login_getToken.header
     body1 = Login_getToken.body
     data1_1 = json.dumps(body1)
     #进行post请求
     r = requests.post(url=self.url1, data=data1_1, headers=header1)
     #获取token值
     response = r.json()
     token = str(response["data"])
     #将字符串里的单引号替换成双引号
     token = re.sub('\'', '\"', token)
     token = re.sub('accessToken', 'Authorization', token)
     #保存到文件token.json
     Fun.save_to_jsonfile('../common/token.json', token)
     print("status_code:" + str(r.status_code))
     print("response:" + str(r.text))