def coverage(context, re_upload, family_id): """Upload coverage from an analysis to Chanjo.""" chanjo_api = coverage_app.ChanjoAPI(context.obj) family_obj = context.obj['status'].family(family_id) api = UploadCoverageApi(context.obj['status'], context.obj['housekeeper_api'], chanjo_api) coverage_data = api.data(family_obj.analyses[0]) api.upload(coverage_data, replace=re_upload)
def coverage(context, re_upload, family_id): """Upload coverage from an analysis to Chanjo.""" click.echo(click.style("----------------- COVERAGE --------------------")) if not family_id: _suggest_cases_to_upload(context) context.abort() chanjo_api = coverage_app.ChanjoAPI(context.obj) family_obj = context.obj["status"].family(family_id) api = UploadCoverageApi(context.obj["status"], context.obj["housekeeper_api"], chanjo_api) coverage_data = api.data(family_obj.analyses[0]) api.upload(coverage_data, replace=re_upload)
def coverage_upload_api(chanjo_config_dict, populated_housekeeper_api): """Fixture for coverage upload API""" hk_api = populated_housekeeper_api status_api = None coverage_api = MockCoverage(chanjo_config_dict) _api = UploadCoverageApi(status_api=status_api, hk_api=hk_api, chanjo_api=coverage_api) return _api
def coverage(context: CGConfig, re_upload, family_id): """Upload coverage from an analysis to Chanjo.""" click.echo(click.style("----------------- COVERAGE --------------------")) status_db: Store = context.status_db if not family_id: suggest_cases_to_upload(status_db=status_db) raise click.Abort case_obj: models.Family = status_db.family(family_id) upload_coverage_api = UploadCoverageApi( status_api=status_db, hk_api=context.housekeeper_api, chanjo_api=context.chanjo_api, ) coverage_data = upload_coverage_api.data(case_obj.analyses[0]) upload_coverage_api.upload(coverage_data, replace=re_upload)
def test_upload(chanjo_config_dict, populated_housekeeper_api, analysis_store, mocker, case_id): """test uploading with chanjo""" # GIVEN a coverage api and a data dictionary mock_upload = mocker.patch.object(ChanjoAPI, "upload") mock_sample = mocker.patch.object(ChanjoAPI, "sample") mock_remove = mocker.patch.object(ChanjoAPI, "delete_sample") hk_api = populated_housekeeper_api chanjo_api = ChanjoAPI(config=chanjo_config_dict) coverage_api = UploadCoverageApi(status_api=None, hk_api=hk_api, chanjo_api=chanjo_api) family_name = case_id family_obj = analysis_store.family(family_name) analysis_obj = MockAnalysis(family_obj=family_obj) data = coverage_api.data(analysis_obj=analysis_obj) # WHEN uploading samples in data dictionary coverage_api.upload(data=data, replace=True) # THEN methods sample, and upload should each have been called three times assert mock_upload.call_count == len(data["samples"]) assert mock_sample.call_count == len(data["samples"])