Skip to content

Commit

Permalink
fix(relax clean flow cell criteria) (#2677) (patch)
Browse files Browse the repository at this point in the history
# Description

relaxes criteria required to pass for deletion of a flow cell. Now either fastq files or spring files have to be present in housekeeper.
  • Loading branch information
ChrOertlin authored Nov 10, 2023
1 parent b7e4076 commit c5cae35
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cg/meta/clean/clean_flow_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ def can_flow_cell_directory_be_deleted(self) -> bool:
self.is_flow_cell_in_statusdb(),
self.is_flow_cell_backed_up(),
self.has_sequencing_metrics_in_statusdb(),
self.has_fastq_files_for_samples_in_housekeeper(),
self.has_spring_meta_data_files_for_samples_in_housekeeper(),
self.has_spring_files_for_samples_in_housekeeper(),
self.has_fastq_files_for_samples_in_housekeeper()
or (
self.has_spring_meta_data_files_for_samples_in_housekeeper()
and self.has_spring_files_for_samples_in_housekeeper()
),
self.has_sample_sheet_in_housekeeper(),
]
)
Expand Down
73 changes: 73 additions & 0 deletions tests/meta/clean/test_clean_flow_cells_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,79 @@ def test_can_flow_cell_be_deleted(flow_cell_clean_api_can_be_removed: CleanFlowC
assert can_be_deleted


def test_can_flow_cell_be_deleted_no_spring_with_fastq(
flow_cell_clean_api_can_be_removed: CleanFlowCellAPI,
):
"""Test that a flow cell can be deleted when it has fastq files but no spring files."""
# GIVEN a flow cell that can be deleted

with mock.patch(
"cg.meta.clean.clean_flow_cells.CleanFlowCellAPI.is_directory_older_than_21_days",
return_value=True,
):
with mock.patch(
"cg.meta.clean.clean_flow_cells.CleanFlowCellAPI.has_spring_meta_data_files_for_samples_in_housekeeper",
return_value=False,
):
# WHEN checking that the flow cell can be deleted
can_be_deleted: bool = (
flow_cell_clean_api_can_be_removed.can_flow_cell_directory_be_deleted()
)

# THEN the check whether the flow cell can be deleted returns True
assert can_be_deleted


def test_can_flow_cell_be_deleted_spring_no_fastq(
flow_cell_clean_api_can_be_removed: CleanFlowCellAPI,
):
"""Test that a flow cell can be deleted when it has spring files but no fastq files."""
# GIVEN a flow cell that can be deleted

with mock.patch(
"cg.meta.clean.clean_flow_cells.CleanFlowCellAPI.is_directory_older_than_21_days",
return_value=True,
):
with mock.patch(
"cg.meta.clean.clean_flow_cells.CleanFlowCellAPI.has_fastq_files_for_samples_in_housekeeper",
return_value=False,
):
# WHEN checking that the flow cell can be deleted
can_be_deleted: bool = (
flow_cell_clean_api_can_be_removed.can_flow_cell_directory_be_deleted()
)

# THEN the check whether the flow cell can be deleted returns True
assert can_be_deleted


def test_can_flow_cell_be_deleted_no_spring_no_fastq(
flow_cell_clean_api_can_be_removed: CleanFlowCellAPI,
):
"""Test that a flow cell can not be deleted when it has no spring files and no fastq files."""
# GIVEN a flow cell that can be deleted

with mock.patch(
"cg.meta.clean.clean_flow_cells.CleanFlowCellAPI.is_directory_older_than_21_days",
return_value=True,
):
with mock.patch(
"cg.meta.clean.clean_flow_cells.CleanFlowCellAPI.has_fastq_files_for_samples_in_housekeeper",
return_value=False,
):
with mock.patch(
"cg.meta.clean.clean_flow_cells.CleanFlowCellAPI.has_spring_meta_data_files_for_samples_in_housekeeper",
return_value=False,
):
# WHEN checking that the flow cell can be deleted
can_be_deleted: bool = (
flow_cell_clean_api_can_be_removed.can_flow_cell_directory_be_deleted()
)

# THEN the check whether the flow cell can be deleted returns True
assert not can_be_deleted


def test_delete_flow_cell_directory(flow_cell_clean_api_can_be_removed: CleanFlowCellAPI):
"""Test that a flow cell directory is removed."""
# GIVEN a flow cell that can be removed
Expand Down

0 comments on commit c5cae35

Please sign in to comment.