def infoQuery(self, membId, checkflag=1): """ query base info of member with special membId :param membId: :return:result dict """ # get org data org_data = httpRequest.HttpRequest() httpheader = {} httpheader["Content-Type"] = "application/x-www-form-urlencoded" httpbody = {} httpbody["membId"] = membId query_url = "http://192.168.8.212:15002/lejaneapp/lejane/usr/archives/v1" org_data.createRequest(query_url, httpheader, httpbody) res = org_data.sendRequest() print "[org_data]{r}".format(r=res) if checkflag: # check data correction org_data_json = json.loads(res) self.assertIn("result", org_data_json, "结果数据中没有result字段") self.assertIn("membId", org_data_json["result"], "结果数据中不存在会员ID") self.assertEqual(membId, org_data_json["result"]["membId"], "查询数据会员Id关联错误") return org_data_json["result"] else: org_data_json = json.loads(res, encoding="UTF-8", ensure_ascii=False) return org_data_json
def main(): request_url = "http://192.168.8.212:15002/lejaneapp/lejane/family/add/v1" httpheader = {} httpheader["Content-Type"] = "application/json" httpbody = [] child = {} child["membId"] = 241 child["membPhone"] = "15202124923" child["childPhone"] = "15810537243" child["contactName"] = "毕云涛" httpbody.append(child.copy()) child["membId"] = 241 child["membPhone"] = "15202124923" child["childPhone"] = "1234567891231456457986562213" child["contactName"] = "1234567891231456457986562213" httpbody.append(child.copy()) lejaneSend = httpRequest.HttpRequest() lejaneSend.createJsonRequest(request_url, httpheader, httpbody) res = lejaneSend.sendRequest() print res
def clientThreadRequest(conn, doc_root, firstRequest): #Process the input request toParse = httpRequest.HttpRequest() toParse.parseRequest(firstRequest) #Process the output response responseObj = httpResponse.HttpResponse() responseObj.serverResponse(toParse, doc_root) print(responseObj.response) tn = threading.currentThread().getName() print(tn) #Send the response to client conn.sendall(responseObj.response) global connStr #Check the connection state connStr = responseObj.connection
def main(): myQueryer = queryChildPhone.MySqlExecuter("192.168.8.213", "sifude", "sifude@2015", "posteritytest") pathList = myQueryer.queryPicsPath(24, 5034) request_url = "http://192.168.8.212:15002/lejaneposterity/pic/delete/v1" httpheader = {} httpheader["Content-Type"] = "application/x-www-form-urlencoded" for path in pathList: httpbody = {} httpbody["filePath"] = path lejaneSend = httpRequest.HttpRequest() lejaneSend.createRequest(request_url, httpheader, httpbody) res = lejaneSend.sendRequest() print res
def uploadUsrdata(): request_url = 'http://lecanbotest.sifude.cn/lejaneapi/lejane/usrdata/upload/v2.4.1' curTimeStamp = getTimestamp() httpheader = {} httpheader["Content-Type"] = "application/json" httpbody = [] request_params = {} request_params["checkTick"] = curTimeStamp request_params["checkTime"] = "" request_params["dataValue"] = "1000" request_params["membId"] = "327" request_params["dataType"] = "step" httpbody.append(request_params) lejaneSend = httpRequest.HttpRequest() lejaneSend.createJsonRequest(request_url, httpheader, httpbody) res = lejaneSend.sendRequest() print "[response content]:{}".format(res)
def setUp(self): self.lejaneTest = httpRequest.HttpRequest() self.request_url = "http://192.168.8.212:15002/lejaneapp/lejane/contact/sync/v1" self.defaultMembId = 239
if __name__ == "__main__": test_env = "qa" # set http post-request url if test_env == "qa": # for qa-env test_url = "http://192.168.8.206:803/lejaneapi/lejane/location/add/v1" elif test_env == "online": # for online-env test_url = "http://192.168.8.206:803/lejaneapi/lejane/location/add/v1" # set http post-request header test_header = {} test_header["Content-Type"] = "application/x-www-form-urlencoded" test_header["Connection"] = "Keep-Alive" test_header["Accept-Encoding"] = "gzip" test_header["Cache-Control"] = "no-cache" test_header["User-Agent"] = "Android 5.1,Safety-Qa,qatest201702101,"\ "TestDate_{}".format(datetime.datetime.now().strftime('%y%m%d_%H%M%S')) # set http post-request body test_body = {} test_body["lnkId"] = 18865 test_body["latitude"] = 39.933563 test_body["longitude"] = 116.468851 # trigger http post-request test_entity = httpRequest.HttpRequest() test_entity.createRequest(test_url, test_header, test_body) test_entity.sendRequest()
def setUp(self): self.lejaneTest = httpRequest.HttpRequest() self.request_url = "http://192.168.8.212:15002/lejaneapp/lejane/usr/detail/v1" #self.request_url = "http://lecanbo.sifude.com/lejaneapp/lejane/usr/detail/v1" self.defaultMembId = 239
def setUp(self): self.lejaneTest = httpRequest.HttpRequest() self.request_url = "http://192.168.8.212:15002/lejaneapp/lejane/usr/archives/edit/v1" self.defaultMembId = 256