Beispiel #1
0
 def testProtected(self):
     protectedPath = "datasets/search"
     request = protocol.SearchDatasetsRequest()
     response = self.sendPostRequest(protectedPath, request)
     self.assertEquals(
         response.status_code, 401, "If Auth0 is enabled this endpoint "
         "is not accessible without auth.")
Beispiel #2
0
 def getAllDatasets(self):
     """
     Gets all datasets available
     """
     path = 'datasets/search'
     request = protocol.SearchDatasetsRequest()
     responseData = self.sendSearchRequest(
         path, request, protocol.SearchDatasetsResponse)
     return responseData.datasets
Beispiel #3
0
 def testPhenotypeAssociationSetSearch(self):
     request = protocol.SearchDatasetsRequest()
     response = self.sendSearchRequest("datasets/search", request,
                                       protocol.SearchDatasetsResponse)
     datasetId = response.datasets[0].id
     request = protocol.SearchPhenotypeAssociationSetsRequest()
     request.dataset_id = datasetId
     response = self.sendSearchRequest(
         "phenotypeassociationsets/search", request,
         protocol.SearchPhenotypeAssociationSetsResponse)
     # there should be an array
     self.assertIsNotNone(response.phenotype_association_sets)
     # there should be at least one entry
     self.assertGreater(len(response.phenotype_association_sets), 0)
Beispiel #4
0
 def testBadBearer(self):
     """
     Tests to see if a malformed bearer token fails in expected ways
     """
     response = self.client.get('/')
     self.assertEqual(response.status_code, 401)
     protectedPath = "datasets/search"
     request = protocol.SearchDatasetsRequest()
     headers = {"Authorization": ""}
     response = self.sendPostRequest(protectedPath, request, headers)
     self.assertEquals(response.status_code, 401, "No bearer should fail"
                       "with 401")
     headers = {"Authorization": "Bearer"}
     response = self.sendPostRequest(protectedPath, request, headers)
     self.assertEquals(response.status_code, 401, "")
Beispiel #5
0
 def getPhenotypeAssociationSetId(self):
     """
     Gets the dataset phenotype association set ID
     """
     request = protocol.SearchDatasetsRequest()
     response = self.sendSearchRequest("datasets/search", request,
                                       protocol.SearchDatasetsResponse)
     datasetId = response.datasets[0].id
     request = protocol.SearchPhenotypeAssociationSetsRequest()
     request.dataset_id = datasetId
     response = self.sendPostRequest("phenotypeassociationsets/search",
                                     request)
     response = protocol.fromJson(
         response.data, protocol.SearchPhenotypeAssociationSetsResponse)
     return response.phenotype_association_sets[0].id
Beispiel #6
0
 def sendDatasetsSearch(self):
     request = protocol.SearchDatasetsRequest()
     return self.sendPostRequest('/datasets/search', request)