コード例 #1
0
    def testVariantsSearch(self):
        referenceName = '1'

        request = protocol.SearchVariantsRequest()
        request.reference_name = referenceName
        request.start = 0
        request.end = 0
        request.variant_set_id = self.variantSet.getId()

        # Request windows is too small, no results
        path = '/variants/search'
        responseData = self.sendSearchRequest(
            path, request, protocol.SearchVariantsResponse)
        self.assertEqual("", responseData.next_page_token)
        self.assertEqual(0, len(responseData.variants))

        # Larger request window, expect results
        request.end = 2 ** 16
        responseData = self.sendSearchRequest(
            path, request, protocol.SearchVariantsResponse)
        self.assertTrue(protocol.validate(
            protocol.toJson(responseData), protocol.SearchVariantsResponse))
        self.assertGreater(len(responseData.variants), 0)

        # Verify all results are in the correct range, set and reference
        for variant in responseData.variants:
            self.assertGreaterEqual(variant.start, 0)
            self.assertLessEqual(variant.end, 2 ** 16)
            self.assertEqual(variant.variant_set_id, self.variantSet.getId())
            self.assertEqual(variant.reference_name, referenceName)
コード例 #2
0
ファイル: backend.py プロジェクト: Philip-Wu/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 assertObjectNotSupported(self, response):
     """
     Checks that the specified response returns a not supported 501 status
     """
     self.assertEqual(501, response.status_code)
     error = protocol.fromJson(response.data, protocol.GAException)
     self.assertTrue(protocol.validate(protocol.toJson(error), type(error)))
     self.assertGreater(error.error_code, 0)
     self.assertGreater(len(error.message), 0)
コード例 #4
0
 def assertObjectNotFound(self, response):
     """
     Checks that the specified response contains a search failure.
     """
     self.assertEqual(404, response.status_code)
     error = protocol.fromJson(response.data, protocol.GAException)
     self.assertTrue(protocol.validate(protocol.toJson(error), type(error)))
     self.assertGreater(error.error_code, 0)
     self.assertGreater(len(error.message), 0)
コード例 #5
0
ファイル: backend.py プロジェクト: holtlab/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)
コード例 #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)
     responseData = protocol.fromJson(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)
     responseData = protocol.fromJson(response.data, responseClass)
     self.assertTrue(
         protocol.validate(protocol.toJson(responseData), responseClass))
     return responseData
コード例 #8
0
ファイル: test_ontologies.py プロジェクト: ga4ghpoc/server
 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.id, ontology.getTermIds(term.name))
         self.assertEqual(
             gaTerm.source_version, ontology.getSourceVersion())
         self.assertEqual(gaTerm.source_name, ontology.getName())
コード例 #9
0
    def testVariantAnnotationSetsSearch(self):
        self.assertIsNotNone(self.variantAnnotationSet)

        request = protocol.SearchVariantAnnotationSetsRequest()

        request.variant_set_id = "b4d=="
        path = '/variantannotationsets/search'
        response = self.sendJsonPostRequest(path, protocol.toJson(request))
        responseData = protocol.fromJson(response.data, protocol.GAException)
        self.assertTrue(protocol.validate(protocol.toJson(responseData),
                                          protocol.GAException))
        self.assertEqual(responseData.error_code, 758389611)
        self.assertEqual(responseData.message,
                         'No object of this type exists with id \'b4d==\'')

        request.variant_set_id = self.variantSet.getId()
        response = self.sendJsonPostRequest(path, protocol.toJson(request))
        responseData = protocol.fromJson(response.data, protocol.
                                         SearchVariantAnnotationSetsResponse)
        self.assertTrue(protocol.validate(
            protocol.toJson(responseData),
            protocol.SearchVariantAnnotationSetsResponse))
        self.assertGreater(len(responseData.variant_annotation_sets), 0,
                           "Expect some results for a known good ID")