示例#1
0
 def testFace(self):
     var = RestVariable()
     var_rest = var.faceRecognizeVar()
     rfeLib = RfeLibrary()
     except_rs = '{"faceInfo":[{"fId":"B0001234","uId":"test3000004","userSex":1,"recognizeTime":"20180425140826","rate":0.452894}],"faceNum":1,"status":0,"reqId":"20180425140826728","msg":"Success"}'
     if isinstance(var_rest, Rest):
         if var_rest.getMethod() == "POST":
             url = "http://172.16.31.36:9090" + var_rest.getUrl()
             rs = rfeLib.reqByJson(var_rest.getMethod(),
                                   url,
                                   json=var_rest.getJson())
             try:
                 rfeLib.assertJson(except_rs, rs.content, 0)
                 except_rs2 = '{"faceNum":' + str(len(var_rest.getExcepts(
                 ))) + ',"status":0,"msg":"Success"}'
                 rfeLib.assertJson(except_rs2, rs.content)
                 excepts_userImg = var_rest.getExcepts()
                 print excepts_userImg
                 print rs.content
                 actual_userInfo = rfeLib.getValueFromJson(
                     rs.content, "$.faceInfo")
                 print actual_userInfo
                 self.assertFace(excepts_userImg, actual_userInfo)
             except Exception, e:
                 raise AssertionError(repr(e))
示例#2
0
 def batchRegister(self):
     rest = RestVariable()
     var_rest = rest.batchRegist()
     rfeLib = RfeLibrary()
     if isinstance(var_rest, Rest):
         if var_rest.getMethod() == "POST":
             reqId = var_rest.getExcepts()
             excepts = '{"apiId":null,"timestamp":null,"sign":null,"reqId":"' + reqId + '","status":0,"msg":"Success","result":[]}'
             with self.locust.client.post(url=var_rest.getUrl(), json=var_rest.getJson(),
                                          catch_response=True) as response:
                 try:
                     rfeLib.assertJson(excepts, response.content)
                 except Exception, e:
                     response.failure(repr(e) + ", " + response.content)
                 else:
                     response.success()
示例#3
0
 def singleRegister(self):
     rest = RestVariable()
     var_rest = rest.batchRegist()
     rfeLib = RfeLibrary()
     if isinstance(var_rest, Rest):
         if var_rest.getMethod() == "POST":
             reqId = var_rest.getExcepts()
             excepts = '{"reqId": "20180511092955098", "status": 0, "msg": "Success"}'
             with self.locust.client.post(url=var_rest.getUrl(), json=var_rest.getJson(),
                                          catch_response=True) as response:
                 try:
                     rfeLib.assertJson(excepts, response.content, 0)
                     excepts2 = '{"status": 0, "msg": "Success"}'
                     rfeLib.assertJson(excepts2, response.content)
                 except Exception, e:
                     response.failure(repr(e))
                 else:
                     response.success()
示例#4
0
 def faceRecognize(self):
     var = RestVariable()
     var_rest = var.faceRecognizeVar()
     rfeLib = RfeLibrary()
     except_rs = '{"faceInfo":[{"fId":"B0001234","uId":"test3000004","userSex":1,"recognizeTime":"20180425140826","rate":0.452894}],"faceNum":1,"status":0,"reqId":"20180425140826728","msg":"Success"}'
     if isinstance(var_rest, Rest):
         if var_rest.getMethod() == "POST":
             with self.locust.client.post(url=var_rest.getUrl(), json=var_rest.getJson(),
                                          catch_response=True) as response:
                 try:
                     rfeLib.assertJson(except_rs, response.content, 0)
                     except_rs2 = '{"faceNum":' + str(len(var_rest.getExcepts())) + ',"status":0,"msg":"Success"}'
                     rfeLib.assertJson(except_rs2, response.content)
                     excepts_userImg = var_rest.getExcepts()
                     actual_userInfo = rfeLib.getValueFromJson(response.content, "$.faceInfo")
                     self.assertRecognize(excepts_userImg, actual_userInfo)
                 except Exception, e:
                     response.failure(repr(e))
                 else:
                     response.success()