Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ def _get_manifest_file(run_path) -> Path:
return file_list[0]

def _get_zipped_reports_file(self, run_path) -> Path:
return get_files_matching_pattern(
file_list: list[Path] = get_files_matching_pattern(
directory=self._get_statistics_dir(run_path),
pattern=ZIPPED_REPORTS_PATTERN,
)[0]
)
if not file_list:
raise FileNotFoundError(f"No Zipped reports file found in {run_path}")
return file_list[0]
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
from unittest import mock

import pytest
from pytest_mock import MockerFixture

from cg.services.run_devices.exc import PostProcessingRunFileManagerError
from cg.services.run_devices.pacbio.run_data_generator.run_data import PacBioRunData
from cg.services.run_devices.pacbio.run_file_manager import run_file_manager
from cg.services.run_devices.pacbio.run_file_manager.models import PacBioRunValidatorFiles
from cg.services.run_devices.pacbio.run_file_manager.run_file_manager import PacBioRunFileManager

Expand Down Expand Up @@ -77,7 +79,7 @@ def test_get_files_to_parse_error(
pac_bio_run_file_manager.get_files_to_parse(pacbio_barcoded_run_data)


def test_get_run_validator_files(
def test_get_run_validator_files_success(
expected_pac_bio_run_data_1_b01, pac_bio_run_file_manager, expected_1_b01_run_validation_files
):
# GIVEN a run data object
Expand All @@ -89,3 +91,28 @@ def test_get_run_validator_files(

# THEN the correct paths are returned
assert validation_file_paths == expected_1_b01_run_validation_files


def test_get_run_validator_files_fail(
tmp_path: Path,
pac_bio_run_file_manager: PacBioRunFileManager,
expected_1_b01_run_validation_files: PacBioRunValidatorFiles,
mocker: MockerFixture,
):
# GIVEN a run data object with a missing zipped reports
pacbio_run_data = PacBioRunData(
full_path=tmp_path / "run_name" / "1_B01",
sequencing_run_name="run_name",
well_name="1_B01",
plate=1,
)

# GIVEN that no zipped nor unzipped reports file is found
mocker.patch.object(
run_file_manager, "get_files_matching_pattern", side_effect=[[Path("some", "file")], [], []]
)

# WHEN getting the run validation file paths
# THEN a file not found exception is raised
with pytest.raises(PostProcessingRunFileManagerError):
pac_bio_run_file_manager.get_run_validation_files(pacbio_run_data)
Loading