def test__load_genomic_json_dir(self): self._reset(do_reset_patient=True) # load clinical docs args = Namespace(genomic=None, trial=None, db_name='integration_load', plugin_dir='plugins', patient_format='json', clinical='matchengine/tests/data/clinical_json/', upsert_fields='') load(args) # load genomic docs args = Namespace(genomic='matchengine/tests/data/genomic_json/', trial=None, db_name='integration_load', plugin_dir='plugins', patient_format='json', clinical=None, upsert_fields='') load(args) clinical = list(self.db_ro.clinical.find({})) genomic = list(self.db_ro.genomic.find({})) assert len(clinical) == 2 assert len(genomic) == 2 assert genomic[0]['CLINICAL_ID'] == clinical[0]['_id'] assert genomic[1]['CLINICAL_ID'] == clinical[1]['_id']
def test__load_genomic_csv(self): self._reset(do_reset_patient=True) # load clinical doc args = Namespace(genomic=None, trial=None, db_name='integration_load', plugin_dir='plugins', patient_format='json', clinical='matchengine/tests/data/clinical_json/', upsert_fields='') load(args) # load genomic doc args = Namespace( genomic='matchengine/tests/data/genomic_csv/test_patients.csv', trial=None, db_name='integration_load', plugin_dir='plugins', patient_format='csv', clinical=None, upsert_fields='') load(args) clinical = list(self.db_ro.clinical.find({})) genomic = list(self.db_ro.genomic.find({})) assert len(clinical) == 2 assert len(genomic) == 2 track = defaultdict(lambda: 1) for clinical_doc in clinical: track[clinical_doc['_id']] -= 1 for genomic_doc in genomic: assert track[genomic_doc['CLINICAL_ID']] == 0
def test__load_trial_single_yaml(self): self._reset(do_reset_trials=True) args = Namespace(clinical=None, genomic=None, db_name='integration_load', plugin_dir='plugins', trial_format='yaml', trial='matchengine/tests/data/yaml/11-111.yaml', upsert_fields='') load(args) assert len(list(self.db_ro.trial.find({}))) == 1
def test__load_clinical_single_csv_file(self): self._reset(do_reset_patient=True) args = Namespace(genomic=None, trial=None, db_name='integration_load', plugin_dir='plugins', patient_format='csv', clinical='matchengine/tests/data/clinical_csv/test_patients.csv', upsert_fields='') load(args) assert len(list(self.db_ro.clinical.find({}))) == 2
def test__load_trials_single_json_multiple_trials(self): """mongoexport by default creates 'json' objects separated by new lines.""" self._reset(do_reset_trials=True) args = Namespace(clinical=None, genomic=None, db_name='integration_load', plugin_dir='plugins', trial_format='json', trial='matchengine/tests/data/trials/two_trials_one_doc.json', upsert_fields='') load(args) assert len(list(self.db_ro.trial.find({}))) == 2
def test__load_trials_json_array(self): """mongoexport also allows exporting of trials as an array of json objects.""" self._reset(do_reset_trials=True) args = Namespace( clinical=None, genomic=None, db_name='integration_load', plugin_dir='plugins', trial_format='json', trial='matchengine/tests/data/trials/trials_json_array.json', upsert_fields='') load(args) assert len(list(self.db_ro.trial.find({}))) == 2
def test__load_clinical_json_dir(self): self._reset(do_reset_patient=True) args = Namespace(genomic=None, trial=None, db_name='integration_load', plugin_dir='plugins', patient_format='json', clinical='matchengine/tests/data/clinical_json/', upsert_fields='') load(args) assert len(list(self.db_ro.clinical.find({}))) == 2 assert isinstance( list(self.db_ro.clinical.find({}))[0]['BIRTH_DATE'], datetime.date)
def test__load_clinical_json_dir(self): self._reset(do_reset_patient=True) args = Namespace(genomic=None, trial=None, db_name='integration_load', plugin_dir='plugins', patient_format='json', clinical='matchengine/tests/data/clinical_json/', upsert_fields='') load(args) assert len(list(self.db_ro.clinical.find({}))) == 2 date_class = list(self.db_ro.clinical.find( {}))[0]['BIRTH_DATE'].__class__ assert date_class is _scope_handler[ 'datetime'] or date_class is _scope_handler['old_datetime']