def test_get_presence_status_status_db( caplog, helpers: StoreHelpers, wipe_demultiplex_api: DeleteDemuxAPI, flowcell_name: str, ): """Test to see if the presence of a flowcell is detected in status-db""" caplog.set_level(logging.INFO) # GIVEN DeleteDemuxAPI objects, one with amd one without a flowcell in status-db wipe_demux_api: DeleteDemuxAPI = wipe_demultiplex_api # WHEN the flowcell name is parsed and fetched fetching the presence of a flowcell in either context empty_presence: bool = wipe_demux_api.status_db_presence # THEN there should be an appropriate presence in both cases assert not empty_presence # WHEN adding a flowcell into the statusdb and checking its updated presence helpers.add_flowcell(store=wipe_demux_api.status_db, flowcell_id=flowcell_name, sequencer_type="novaseq") populated_presence: bool = wipe_demux_api.status_db_presence # THEN the presence should be updated assert populated_presence
def fluffy_context( cg_context: CGConfig, helpers: StoreHelpers, real_housekeeper_api: HousekeeperAPI, fluffy_samplesheet_bundle_data, fluffy_fastq_hk_bundle_data, fluffy_case_id_existing, fluffy_sample_lims_id, ) -> CGConfig: cg_context.housekeeper_api_ = real_housekeeper_api fluffy_analysis_api = FluffyAnalysisAPI(config=cg_context) helpers.ensure_hk_version(fluffy_analysis_api.housekeeper_api, bundle_data=fluffy_samplesheet_bundle_data) helpers.ensure_hk_version(fluffy_analysis_api.housekeeper_api, fluffy_fastq_hk_bundle_data) example_fluffy_case = helpers.add_case( fluffy_analysis_api.status_db, internal_id=fluffy_case_id_existing, name=fluffy_case_id_existing, data_analysis=Pipeline.FLUFFY, ) example_fluffy_sample = helpers.add_sample( fluffy_analysis_api.status_db, internal_id=fluffy_sample_lims_id, is_tumour=False, application_type="tgs", reads=100, sequenced_at=dt.datetime.now(), ) helpers.add_flowcell(fluffy_analysis_api.status_db, flowcell_id="flowcell", samples=[example_fluffy_sample]) helpers.add_relationship(fluffy_analysis_api.status_db, case=example_fluffy_case, sample=example_fluffy_sample) cg_context.meta_apis["analysis_api"] = fluffy_analysis_api return cg_context
def test_get_sample_flowcells_with_flowcell(cli_runner: CliRunner, base_context: CGConfig, disk_store: Store, helpers: StoreHelpers): """Test that we can query samples and hide flowcell, ensuring that no flowcell name is in the output""" # GIVEN a database with a sample and a related flowcell flowcell = helpers.add_flowcell(disk_store) sample = helpers.add_sample(disk_store, flowcell=flowcell) assert flowcell in disk_store.Sample.query.first().flowcells sample_id = sample.internal_id # WHEN getting a sample with the --flowcells flag result = cli_runner.invoke(get, ["sample", sample_id, "--hide-flowcell"], obj=base_context) # THEN the related flowcell should be listed in the output assert result.exit_code == 0 for flowcell in disk_store.Sample.query.first().flowcells: assert flowcell.name not in result.output