Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
Vince-janv committed Jul 20, 2023
2 parents 02ea7da + c22cf90 commit 18fa59c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 17 deletions.
19 changes: 17 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,21 @@ def fixture_populated_stats_api(
return stats_api


@pytest.fixture(name="novaseq6000_bcl_convert_sample_sheet_path")
def fixture_novaseq6000_sample_sheet_path() -> Path:
"""Return the path to a NovaSeq 6000 BCL convert sample sheet."""
return Path(
"tests",
"fixtures",
"apps",
"sequencing_metrics_parser",
"230622_A00621_0864_AHY7FFDRX2",
"Unaligned",
"Reports",
"SampleSheet.csv",
)


@pytest.fixture(name="demultiplex_fixtures", scope="session")
def fixture_demultiplex_fixtures(apps_dir: Path) -> Path:
"""Return the path to the demultiplex fixture directory."""
Expand Down Expand Up @@ -2688,8 +2703,8 @@ def fixture_store_with_sequencing_metrics(
yield store


@pytest.fixture
def demultiplexed_flow_cells_directory(tmp_path) -> Path:
@pytest.fixture(name="demultiplexed_flow_cells_tmp_directory")
def fixture_demultiplexed_flow_cells_tmp_directory(tmp_path) -> Path:
original_dir = Path(
Path(__file__).parent, "fixtures", "apps", "demultiplexing", "demultiplexed-runs"
)
Expand Down
56 changes: 41 additions & 15 deletions tests/meta/demultiplex/test_demux_post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ def test_update_sample_read_count(demultiplex_context: CGConfig):
"demux_type",
["BCL2FASTQ_TREE", "BCLCONVERT_TREE", "BCLCONVERT_FLAT"],
)
def test_post_processing_of_flow_cell_demultiplexed_with_bclconvert(
def test_post_processing_of_flow_cell(
demux_type: str,
demultiplex_context: CGConfig,
flow_cell_info_map: Dict[str, FlowCellInfo],
Expand Down Expand Up @@ -785,22 +785,48 @@ def test_post_processing_of_flow_cell_demultiplexed_with_bclconvert(
assert delivery_path.exists()


def test_copy_sample_sheet(demultiplex_context: CGConfig):
def test_add_demux_logs_to_housekeeper(
demultiplex_context: CGConfig, dragen_flow_cell: FlowCellDirectoryData
):
# GIVEN a DemuxPostProcessing API
demux_post_processing_api = DemuxPostProcessingAPI(demultiplex_context)

# GIVEN a sample sheet in the run directory
sample_sheet_path = Path(
demux_post_processing_api.demux_api.run_dir,
DemultiplexingDirsAndFiles.SAMPLE_SHEET_FILE_NAME,
)
sample_sheet_path.touch()
# GIVEN a bundle and flow cell version exists in housekeeper
demux_post_processing_api.add_bundle_and_version_if_non_existent(
bundle_name=dragen_flow_cell.id
)

# GIVEN a demux log in the run directory
demux_log_file_paths: List[Path] = [
Path(
demux_post_processing_api.demux_api.run_dir,
f"{dragen_flow_cell.full_name}",
f"{dragen_flow_cell.id}_demultiplex.stdout",
),
Path(
demux_post_processing_api.demux_api.run_dir,
f"{dragen_flow_cell.full_name}",
f"{dragen_flow_cell.id}_demultiplex.stderr",
),
]
for file_path in demux_log_file_paths:
file_path.parent.mkdir(parents=True, exist_ok=True)
file_path.touch()

# WHEN adding the demux logs to housekeeper
demux_post_processing_api.add_demux_logs_to_housekeeper(flow_cell=dragen_flow_cell)

# THEN the demux log was added to housekeeper
files = demux_post_processing_api.hk_api.get_files(
tags=[SequencingFileTag.DEMUX_LOG],
bundle=dragen_flow_cell.id,
).all()

# WHEN copying the sample sheet
demux_post_processing_api.copy_sample_sheet()
expected_file_names: List[str] = []
for file_path in demux_log_file_paths:
expected_file_names.append(file_path.name.split("/")[-1])

# THEN the sample sheet was copied to the out directory
assert Path(
demux_post_processing_api.demux_api.out_dir,
DemultiplexingDirsAndFiles.SAMPLE_SHEET_FILE_NAME,
).exists()
# THEN the demux logs were added to housekeeper with the correct names
assert len(files) == 2
for file in files:
assert file.path.split("/")[-1] in expected_file_names

0 comments on commit 18fa59c

Please sign in to comment.