Exemple #1
0
 def test_gene(self):
     response = get_response('genes-list', self.gene)
     response_duplicate = get_response('htsfiles-list', self.duplicate_gene)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(response_duplicate.status_code,
                      status.HTTP_400_BAD_REQUEST)
     self.assertEqual(m.Gene.objects.count(), 1)
 def test_procedure(self):
     response = get_response('procedure-list', self.valid_procedure)
     response_duplicate = get_response(
         'procedure-list', self.duplicate_procedure)
     response_duplicate_code = get_response(
         'procedure-list', self.valid_procedure_duplicate_code)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(response_duplicate.status_code, status.HTTP_201_CREATED)
     self.assertEqual(response_duplicate_code.status_code, status.HTTP_201_CREATED)
     self.assertEqual(Procedure.objects.count(), 2)
Exemple #3
0
 def test_get_fhir(self):
     get_response('procedures-list', self.valid_procedure)
     get_resp = self.client.get('/api/procedures?format=fhir')
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     get_resp_obj = get_resp.json()
     self.assertIsNotNone(get_resp_obj['specimen.collections'][0]['method'])
     self.assertIsInstance(
         get_resp_obj['specimen.collections'][0]['bodySite'], dict)
     self.assertIsNot(
         get_resp_obj['specimen.collections'][0]['method']['coding'], [])
Exemple #4
0
 def test_get_fhir(self):
     response_1 = get_response('individual-list', self.individual)
     response_2 = get_response('individual-list', self.individual_second)
     get_resp = self.client.get('/api/individuals?format=fhir')
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     get_resp_obj = get_resp.json()
     self.assertEqual(get_resp_obj['patients'][0]['resourceType'], 'Patient')
     self.assertIsInstance(get_resp_obj['patients'][0]['extension'], list)
     self.assertEqual(get_resp_obj['patients'][1]['extension'][0]['url'],
                      'http://ga4gh.org/fhir/phenopackets/StructureDefinition/individual-age')
     self.assertIsInstance(get_resp_obj['patients'][1]['extension'][0]['valueAge'], dict)
Exemple #5
0
 def test_get_fhir(self):
     get_response('diseases-list', self.disease)
     get_resp = self.client.get('/api/diseases?format=fhir')
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     get_resp_obj = get_resp.json()
     self.assertEqual(get_resp_obj['conditions'][0]['resourceType'],
                      'Condition')
     self.assertIsNotNone(
         get_resp_obj['conditions'][0]['code']['coding'][0])
     self.assertIsInstance(get_resp_obj['conditions'][0]['extension'], list)
     self.assertEqual(
         get_resp_obj['conditions'][0]['extension'][0]['url'],
         'http://ga4gh.org/fhir/phenopackets/StructureDefinition/disease-tumor-stage'
     )
     self.assertEqual(get_resp_obj['conditions'][0]['subject']['reference'],
                      'unknown')
Exemple #6
0
    def test_create_invalid_biosample(self):
        """ POST a new biosample with invalid data. """

        invalid_response = get_response('biosample-list', self.invalid_payload)
        self.assertEqual(invalid_response.status_code,
                         status.HTTP_400_BAD_REQUEST)
        self.assertEqual(m.Biosample.objects.count(), 0)
Exemple #7
0
    def test_create_phenotypic_feature(self):
        """ POST a new phenotypic feature. """

        response = get_response('phenotypicfeatures-list',
                                self.valid_phenotypic_feature)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(m.PhenotypicFeature.objects.count(), 1)
Exemple #8
0
    def test_create_biosample(self):
        """ POST a new biosample. """

        response = get_response('biosamples-list', self.valid_payload)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(m.Biosample.objects.count(), 1)
        self.assertEqual(m.Biosample.objects.get().id, 'biosample_id:1')
Exemple #9
0
 def test_get_argo(self):
     create_object_response = get_response("individual-list", self.donor)
     self.assertEqual(create_object_response.status_code,
                      status.HTTP_201_CREATED)
     get_resp = self.client.get("/api/individuals?format=argo")
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     get_resp_obj = get_resp.json()
     for donor in get_resp_obj["donors"]:
         self.assertIsNotNone(donor["gender"])
         self.assertIsNotNone(donor["submitter_donor_id"])
         self.assertIsNotNone(donor["vital_status"])
Exemple #10
0
 def test_get_fhir(self):
     get_response('variants-list', self.variant)
     get_resp = self.client.get('/api/variants?format=fhir')
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     get_resp_obj = get_resp.json()
     self.assertIsInstance(get_resp_obj['observations'], list)
     self.assertIsInstance(
         get_resp_obj['observations'][0]['code']['coding'], list)
     self.assertEqual(
         get_resp_obj['observations'][0]['code']['coding'][0]['code'],
         '81300-6')
     self.assertEqual(
         get_resp_obj['observations'][0]['code']['coding'][0]['display'],
         'Structural variant [Length]')
     self.assertEqual(
         get_resp_obj['observations'][0]['code']['coding'][0]['system'],
         'https://loinc.org')
     self.assertEqual(
         get_resp_obj['observations'][0]['valueCodeableConcept']['coding']
         [0]['code'], get_resp_obj['observations'][0]
         ['valueCodeableConcept']['coding'][0]['display'])
Exemple #11
0
 def test_gender_condition_1(self):
     create_object_response = get_response("individual-list", self.donor_2)
     self.assertEqual(create_object_response.status_code,
                      status.HTTP_201_CREATED)
     get_resp = self.client.get("/api/individuals/patient:2?format=argo")
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     get_resp_obj = get_resp.json()
     self.assertIsNotNone(get_resp_obj["gender"])
     self.assertEqual(get_resp_obj["gender"], "Other")
     self.assertEqual(get_resp_obj["submitter_donor_id"], "patient:2")
     self.assertEqual(get_resp_obj["cause_of_death"], "Unknown")
     self.assertEqual(get_resp_obj["survival_time"], 2)
     self.assertEqual(get_resp_obj["primary_site"], "Breast")
Exemple #12
0
 def test_get_fhir(self):
     get_response('htsfiles-list', self.hts_file)
     get_resp = self.client.get('/api/htsfiles?format=fhir')
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     get_resp_obj = get_resp.json()
     self.assertEqual(
         get_resp_obj['document_references'][0]['resourceType'],
         'DocumentReference')
     self.assertIsInstance(
         get_resp_obj['document_references'][0]['content'], list)
     self.assertIsNotNone(get_resp_obj['document_references'][0]['content']
                          [0]['attachment']['url'])
     self.assertEqual(get_resp_obj['document_references'][0]['status'],
                      'current')
     self.assertEqual(
         get_resp_obj['document_references'][0]['type']['coding'][0]
         ['code'], get_resp_obj['document_references'][0]['type']['coding']
         [0]['display'])
     self.assertEqual(
         get_resp_obj['document_references'][0]['extension'][0]['url'],
         'http://ga4gh.org/fhir/phenopackets/StructureDefinition/htsfile-genome-assembly'
     )
Exemple #13
0
    def test_get_fhir(self):
        """ POST a new biosample. """

        get_response('biosamples-list', self.valid_payload)
        get_resp = self.client.get('/api/biosamples?format=fhir')
        self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
        get_resp_obj = get_resp.json()
        self.assertEqual(get_resp_obj['specimens'][0]['resourceType'],
                         'Specimen')
        self.assertIsNotNone(get_resp_obj['specimens'][0]['type']['coding'][0])
        self.assertIsNotNone(get_resp_obj['specimens'][0]['collection'])
        self.assertIsInstance(
            get_resp_obj['specimens'][0]['extension'][0]['valueRange'], dict)
        self.assertEqual(
            get_resp_obj['specimens'][0]['extension'][4]['url'],
            'http://ga4gh.org/fhir/phenopackets/StructureDefinition/biosample-diagnostic-markers'
        )
        self.assertIsInstance(
            get_resp_obj['specimens'][0]['extension'][4]
            ['valueCodeableConcept']['coding'], list)
        self.assertTrue(
            get_resp_obj['specimens'][0]['extension'][5]['valueBoolean'])
Exemple #14
0
 def test_get_fhir(self):
     response = get_response('gene-list', self.gene)
     get_resp = self.client.get('/api/genes?format=fhir')
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     get_resp_obj = get_resp.json()
     self.assertIsInstance(get_resp_obj['observations'], list)
     self.assertIsInstance(get_resp_obj['observations'][0]['code']['coding'], list)
     self.assertEqual(get_resp_obj['observations'][0]['code']['coding'][0]['code'], '48018-6')
     self.assertEqual(get_resp_obj['observations'][0]['code']['coding'][0]['display'], 'Gene studied [ID]')
     self.assertEqual(get_resp_obj['observations'][0]['code']['coding'][0]['system'], 'https://loinc.org')
     self.assertIsInstance(get_resp_obj['observations'][0]['valueCodeableConcept']['coding'], list)
     self.assertEqual(get_resp_obj['observations'][0]['valueCodeableConcept']['coding'][0]['system'],
                      'https://www.genenames.org/')
Exemple #15
0
 def test_get_argo(self):
     create_object_response = get_response("medicationstatement-list",
                                           self.therapy)
     self.assertEqual(create_object_response.status_code,
                      status.HTTP_201_CREATED)
     get_resp = self.client.get("/api/medicationstatements?format=argo")
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     results = get_resp.json(
     )["immunotherapies_chemotherapies_hormone_therapies"]
     self.assertIsNotNone(results[0]["submitter_treatment_id"])
     self.assertIsInstance(results[0]["submitter_treatment_id"], str)
     self.assertIsNotNone(results[0]["drug_rxnormcui"])
     self.assertIsInstance(results[0]["drug_rxnormcui"], dict)
     self.assertIn("label", results[0]["drug_rxnormcui"])
     self.assertIn("id", results[0]["drug_rxnormcui"])
Exemple #16
0
 def test_get_argo(self):
     create_object_response = get_response("cancercondition-list",
                                           self.primary_diagnosis)
     self.assertEqual(create_object_response.status_code,
                      status.HTTP_201_CREATED)
     get_resp = self.client.get("/api/cancerconditions?format=argo")
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     get_resp_obj = get_resp.json()
     self.assertIsNotNone(get_resp_obj["primary_diagnoses"][0]
                          ["submitter_primary_diagnosis_id"])
     self.assertIsInstance(
         get_resp_obj["primary_diagnoses"][0]
         ["submitter_primary_diagnosis_id"], str)
     self.assertIsNotNone(
         get_resp_obj["primary_diagnoses"][0]["cancer_type_code"])
     self.assertIsInstance(
         get_resp_obj["primary_diagnoses"][0]["cancer_type_code"], dict)
Exemple #17
0
 def test_get_argo(self):
     create_object_response = get_response("geneticspecimen-list",
                                           self.specimen)
     self.assertEqual(create_object_response.status_code,
                      status.HTTP_201_CREATED)
     get_resp = self.client.get("/api/geneticspecimens?format=argo")
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     get_resp_obj = get_resp.json()
     self.assertIsNotNone(
         get_resp_obj["specimens"][0]["submitter_specimen_id"])
     self.assertIsInstance(
         get_resp_obj["specimens"][0]["submitter_specimen_id"], str)
     self.assertIsNotNone(get_resp_obj["specimens"][0]["specimen_type"])
     self.assertIsInstance(get_resp_obj["specimens"][0]["specimen_type"],
                           dict)
     self.assertIsNotNone(
         get_resp_obj["specimens"][0]["specimen_tissue_source"])
     self.assertIsInstance(
         get_resp_obj["specimens"][0]["specimen_tissue_source"], dict)
     self.assertIsNotNone(
         get_resp_obj["specimens"][0]["specimen_laterality"])
     self.assertIsInstance(
         get_resp_obj["specimens"][0]["specimen_laterality"], dict)
Exemple #18
0
 def test_get_argo(self):
     create_object_response = get_response("cancerrelatedprocedure-list",
                                           self.treatment)
     self.assertEqual(create_object_response.status_code,
                      status.HTTP_201_CREATED)
     get_resp = self.client.get("/api/cancerrelatedprocedures?format=argo")
     self.assertEqual(get_resp.status_code, status.HTTP_200_OK)
     get_resp_obj = get_resp.json()
     self.assertIsNotNone(
         get_resp_obj["treatments"][0]["submitter_treatment_id"])
     self.assertIsInstance(
         get_resp_obj["treatments"][0]["submitter_treatment_id"], str)
     self.assertIsNotNone(get_resp_obj["treatments"][0]["treatment_type"])
     self.assertIsInstance(get_resp_obj["treatments"][0]["treatment_type"],
                           str)
     # radiation procedure only
     self.assertEqual(get_resp_obj["treatments"][0]["treatment_type"],
                      "Radiation therapy")
     self.assertIsNotNone(
         get_resp_obj["treatments"][0]["radiation_therapy_modality"])
     self.assertIsInstance(
         get_resp_obj["treatments"][0]["radiation_therapy_modality"], dict)
     self.assertIsNotNone(
         get_resp_obj["treatments"][0]["anatomical_site_irradiated"])
Exemple #19
0
 def test_diagnosis(self):
     response = get_response('diagnoses-list', self.diagnosis)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     serializer = s.DiagnosisSerializer(data=self.diagnosis)
     self.assertEqual(serializer.is_valid(), True)
Exemple #20
0
 def test_genomic_interpretation(self):
     response = get_response('genomicinterpretations-list',
                             self.genomic_interpretation)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(m.GenomicInterpretation.objects.count(), 1)
Exemple #21
0
 def test_phenopacket(self):
     response = get_response('phenopackets-list', self.phenopacket)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(m.Phenopacket.objects.count(), 1)
Exemple #22
0
 def test_metadata(self):
     response = get_response('metadata-list', self.metadata)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(m.MetaData.objects.count(), 1)
Exemple #23
0
 def test_disease(self):
     response = get_response('diseases-list', self.disease)
     serializer = s.DiseaseSerializer(data=self.disease)
     self.assertEqual(serializer.is_valid(), True)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(m.Disease.objects.count(), 1)
Exemple #24
0
 def test_to_represenation(self):
     response = get_response('variants-list', self.variant_2)
     serializer = s.VariantSerializer(data=self.variant)
     self.assertEqual(serializer.is_valid(), True)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(m.Variant.objects.count(), 1)
Exemple #25
0
 def test_hts_file(self):
     response = get_response('htsfiles-list', self.hts_file)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(m.HtsFile.objects.count(), 1)
Exemple #26
0
 def test_resource(self):
     response = get_response('resource-list', self.resource)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(Resource.objects.count(), 1)
Exemple #27
0
 def test_gender_condition_2(self):
     create_object_response = get_response("individual-list", self.donor_3)
     self.assertEqual(create_object_response.status_code,
                      status.HTTP_400_BAD_REQUEST)
Exemple #28
0
 def test_interpretation(self):
     response = get_response('interpretations-list', self.interpretation)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
 def test_variant(self):
     response = get_response('variant-list', self.variant)
     serializer = VariantSerializer(data=self.variant)
     self.assertEqual(serializer.is_valid(), True)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(Variant.objects.count(), 1)
Exemple #30
0
 def setUp(self) -> None:
     project = get_response('project-list', VALID_PROJECT_1)
     self.project = project.json()
     self.creators = VALID_DATS_CREATORS
     self.dataset = dats_dataset(self.project['identifier'], self.creators)
     resp = get_response('dataset-list', self.dataset)