def testGoodMappings(self):
     ontology = self._gaObject
     for term in self._oboReader:
         self.assertIn(term.id, ontology.getTermIds(term.name))
         gaTerm = ontology.getGaTermByName(term.name)
         self.assertTrue(protocol.validate(protocol.toJson(gaTerm),
                                           OntologyTerm))
         self.assertEqual(gaTerm.term, term.name)
         self.assertIn(gaTerm.term_id, ontology.getTermIds(term.name))
示例#2
0
文件: backend.py 项目: kozbo/server
 def validateRequest(self, jsonDict, requestClass):
     """
     Ensures the jsonDict corresponds to a valid instance of requestClass
     Throws an error if the data is invalid
     """
     if self._requestValidation:
         if not protocol.validate(jsonDict, requestClass):
             raise exceptions.RequestValidationFailureException(
                 jsonDict, requestClass)
示例#3
0
 def validateRequest(self, jsonDict, requestClass):
     """
     Ensures the jsonDict corresponds to a valid instance of requestClass
     Throws an error if the data is invalid
     """
     if self._requestValidation:
         if not protocol.validate(jsonDict, requestClass):
             raise exceptions.RequestValidationFailureException(
                 jsonDict, requestClass)
示例#4
0
 def sendSearchRequest(self, path, request, responseClass):
     """
     Sends the specified protocol request instance as JSON, and
     parses the result into an instance of the specified response.
     """
     response = self.sendJsonPostRequest(path, protocol.toJson(request))
     self.assertEqual(200, response.status_code)
     responseData = protocol.fromJson(response.data, responseClass)
     self.assertTrue(
         protocol.validate(protocol.toJson(responseData), responseClass))
     return responseData
示例#5
0
文件: test_g2p.py 项目: ga4gh/server
 def sendSearchRequest(self, path, request, responseClass):
     """
     Sends the specified protocol request instance as JSON, and
     parses the result into an instance of the specified response.
     """
     response = self.sendJsonPostRequest(path, protocol.toJson(request))
     self.assertEqual(200, response.status_code)
     responseData = protocol.fromJson(response.data, responseClass)
     self.assertTrue(
         protocol.validate(protocol.toJson(responseData), responseClass))
     return responseData
示例#6
0
 def sendSearchRequest(self, path, request, responseClass):
     """
     Sends the specified protocol request instance as JSON, and
     parses the result into an instance of the specified response.
     """
     response = self.sendJsonPostRequest(path, protocol.toJson(request))
     # self.assertEqual(200, response.status_code) federated search can return 404
     responseData = self.deserialize(response.data, responseClass)
     # responseData = protocol.fromProtobufString(response.data,
     #                                           responseClass)
     self.assertTrue(
         protocol.validate(protocol.toJson(responseData), responseClass))
     return responseData
示例#7
0
 def sendSearchRequest(self, path, request, responseClass):
     """
     Sends the specified protocol request instance as JSON, and
     parses the result into an instance of the specified response.
     """
     response = self.sendJsonPostRequest(path, protocol.toJson(request))
     # self.assertEqual(200, response.status_code) federated search can return 404
     response_json = json.loads(response.data)
     response = json.dumps(response_json.get('results', {}))
     responseData = protocol.deserialize(response, self.serialization,
                                         responseClass)
     self.assertTrue(
         protocol.validate(protocol.toJson(responseData), responseClass))
     return responseData
示例#8
0
 def testValidate(self):
     classes = protocol.getProtocolClasses()
     for clazz in classes:
         obj = clazz()
         jsonStr = protocol.toJson(obj)
         protocol.validate(jsonStr, clazz)
示例#9
0
 def testValidate(self):
     classes = protocol.getProtocolClasses()
     for clazz in classes:
         obj = clazz()
         jsonStr = protocol.toJson(obj)
         protocol.validate(jsonStr, clazz)