Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat - use fixture plugins instead of conftest files #2816

Merged
merged 7 commits into from
Jan 11, 2024
Merged
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
1,601 changes: 311 additions & 1,290 deletions tests/conftest.py

Large diffs are not rendered by default.

Empty file.
Empty file.
172 changes: 172 additions & 0 deletions tests/fixture_plugins/demultiplex_fixtures/flow_cell_fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
"""Fixtures for flow cell objects."""
from pathlib import Path

import pytest

from cg.constants.demultiplexing import BclConverter, DemultiplexingDirsAndFiles
from cg.models.flow_cell.flow_cell import FlowCellDirectoryData

# Functional flow cells


@pytest.fixture(scope="module")
def hiseq_x_single_index_flow_cell(
hiseq_x_single_index_flow_cell_dir: Path,
diitaz93 marked this conversation as resolved.
Show resolved Hide resolved
) -> FlowCellDirectoryData:
"""Return a single-index HiSeqX flow cell."""
return FlowCellDirectoryData(flow_cell_path=hiseq_x_single_index_flow_cell_dir)


@pytest.fixture(scope="module")
def hiseq_x_dual_index_flow_cell(
hiseq_x_dual_index_flow_cell_dir: Path,
) -> FlowCellDirectoryData:
"""Return a dual-index HiSeqX flow cell."""
return FlowCellDirectoryData(flow_cell_path=hiseq_x_dual_index_flow_cell_dir)


@pytest.fixture(scope="module")
def hiseq_2500_dual_index_flow_cell(
hiseq_2500_dual_index_flow_cell_dir: Path,
) -> FlowCellDirectoryData:
"""Return a dual-index HiSeq2500 flow cell."""
return FlowCellDirectoryData(flow_cell_path=hiseq_2500_dual_index_flow_cell_dir)


@pytest.fixture(scope="module")
def hiseq_2500_custom_index_flow_cell(
hiseq_2500_custom_index_flow_cell_dir: Path,
) -> FlowCellDirectoryData:
"""Return a custom-index HiSeq2500 flow cell."""
return FlowCellDirectoryData(flow_cell_path=hiseq_2500_custom_index_flow_cell_dir)


@pytest.fixture()
def novaseq_6000_post_1_5_kits_flow_cell_data(flow_cells_dir: Path) -> FlowCellDirectoryData:
return FlowCellDirectoryData(Path(flow_cells_dir, "230912_A00187_1009_AHK33MDRX3"))


@pytest.fixture()
def novaseq_6000_pre_1_5_kits_flow_cell_data(flow_cells_dir: Path) -> FlowCellDirectoryData:
return FlowCellDirectoryData(Path(flow_cells_dir, "190927_A00689_0069_BHLYWYDSXX"))


@pytest.fixture()
def novaseq_x_flow_cell_data(flow_cells_dir: Path) -> FlowCellDirectoryData:
return FlowCellDirectoryData(Path(flow_cells_dir, "20231108_LH00188_0028_B22F52TLT3"))


# Broken flow cells
diitaz93 marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture(scope="session")
def bcl2fastq_flow_cell(bcl2fastq_flow_cell_dir: Path) -> FlowCellDirectoryData:
"""Create a flow cell object with flow cell that is demultiplexed."""
return FlowCellDirectoryData(
flow_cell_path=bcl2fastq_flow_cell_dir, bcl_converter=BclConverter.BCL2FASTQ
)


@pytest.fixture(scope="session")
def novaseq_flow_cell_demultiplexed_with_bcl2fastq(
bcl_convert_flow_cell_dir: Path,
) -> FlowCellDirectoryData:
"""Return a Novaseq6000 flow cell object demultiplexed using Bcl2fastq."""
return FlowCellDirectoryData(
flow_cell_path=bcl_convert_flow_cell_dir, bcl_converter=BclConverter.BCL2FASTQ
)


@pytest.fixture(scope="module")
def bcl_convert_flow_cell(bcl_convert_flow_cell_dir: Path) -> FlowCellDirectoryData:
"""Create a bcl_convert flow cell object with flow cell that is demultiplexed."""
return FlowCellDirectoryData(
flow_cell_path=bcl_convert_flow_cell_dir, bcl_converter=BclConverter.DRAGEN
)


@pytest.fixture(scope="function")
def novaseq_6000_flow_cell(bcl_convert_flow_cell: FlowCellDirectoryData) -> FlowCellDirectoryData:
"""Return a NovaSeq6000 flow cell object."""
return bcl_convert_flow_cell


@pytest.fixture(scope="function")
def novaseq_x_flow_cell(novaseq_x_flow_cell_dir: Path) -> FlowCellDirectoryData:
"""Create a NovaSeqX flow cell object with flow cell that is demultiplexed."""
return FlowCellDirectoryData(
flow_cell_path=novaseq_x_flow_cell_dir, bcl_converter=BclConverter.DRAGEN
)


@pytest.fixture()
def novaseqx_flow_cell_with_sample_sheet_no_fastq(
novaseqx_flow_cell_directory: Path, novaseqx_demultiplexed_flow_cell: Path
) -> FlowCellDirectoryData:
"""Return a flow cell from a tmp dir with a sample sheet and no sample fastq files."""
novaseqx_flow_cell_directory.mkdir(parents=True, exist_ok=True)
flow_cell = FlowCellDirectoryData(novaseqx_flow_cell_directory)
sample_sheet_path = Path(
novaseqx_demultiplexed_flow_cell, DemultiplexingDirsAndFiles.SAMPLE_SHEET_FILE_NAME
)
flow_cell._sample_sheet_path_hk = sample_sheet_path
return flow_cell


@pytest.fixture(name="tmp_bcl2fastq_flow_cell")
def tmp_bcl2fastq_flow_cell(
tmp_demultiplexed_runs_bcl2fastq_directory: Path,
) -> FlowCellDirectoryData:
"""Create a flow cell object with flow cell that is demultiplexed."""
return FlowCellDirectoryData(
flow_cell_path=tmp_demultiplexed_runs_bcl2fastq_directory,
bcl_converter=BclConverter.BCL2FASTQ,
)


@pytest.fixture
def novaseq6000_flow_cell(
tmp_flow_cells_directory_malformed_sample_sheet: Path,
) -> FlowCellDirectoryData:
"""Return a NovaSeq6000 flow cell."""
return FlowCellDirectoryData(
flow_cell_path=tmp_flow_cells_directory_malformed_sample_sheet,
bcl_converter=BclConverter.BCLCONVERT,
)


@pytest.fixture(name="tmp_bcl_convert_flow_cell")
def tmp_bcl_convert_flow_cell(
tmp_flow_cell_directory_bclconvert: Path,
) -> FlowCellDirectoryData:
"""Create a flow cell object with flow cell that is demultiplexed."""
return FlowCellDirectoryData(
flow_cell_path=tmp_flow_cell_directory_bclconvert,
bcl_converter=BclConverter.DRAGEN,
)


@pytest.fixture(name="tmp_unfinished_bcl2fastq_flow_cell")
def unfinished_bcl2fastq_flow_cell(
demultiplexed_runs_unfinished_bcl2fastq_flow_cell_directory: Path,
) -> FlowCellDirectoryData:
"""Copy the content of a demultiplexed but not finished directory to a temporary location."""
return FlowCellDirectoryData(
flow_cell_path=demultiplexed_runs_unfinished_bcl2fastq_flow_cell_directory,
bcl_converter=BclConverter.BCL2FASTQ,
)


# Flow cell attributes


@pytest.fixture(scope="session")
def bcl2fastq_flow_cell_id(bcl2fastq_flow_cell: FlowCellDirectoryData) -> str:
"""Return flow cell id from bcl2fastq flow cell object."""
return bcl2fastq_flow_cell.id


@pytest.fixture(scope="module")
def bcl_convert_flow_cell_id(bcl_convert_flow_cell: FlowCellDirectoryData) -> str:
"""Return flow cell id from bcl_convert flow cell object."""
return bcl_convert_flow_cell.id
116 changes: 116 additions & 0 deletions tests/fixture_plugins/demultiplex_fixtures/name_fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import pytest


@pytest.fixture
def tmp_flow_cell_name_no_run_parameters() -> str:
"""This is the name of a flow cell directory with the run parameters missing."""
return "180522_A00689_0200_BHLCKNCCXY"


@pytest.fixture
def tmp_flow_cell_name_malformed_sample_sheet() -> str:
""" "Returns the name of a flow cell directory ready for demultiplexing with BCL convert.
Contains a sample sheet with malformed headers.
"""
return "201203_A00689_0200_AHVKJCDRXY"


@pytest.fixture
def tmp_flow_cell_name_no_sample_sheet() -> str:
"""Return the name of a flow cell directory with the run parameters and sample sheet missing."""
return "170407_A00689_0209_BHHKVCALXX"


@pytest.fixture(name="tmp_flow_cell_name_ready_for_demultiplexing_bcl2fastq")
def tmp_flow_cell_name_ready_for_demultiplexing_bcl2fastq() -> str:
"""Returns the name of a flow cell directory ready for demultiplexing with bcl2fastq."""
return "211101_D00483_0615_AHLG5GDRXY"


@pytest.fixture(scope="session")
def flow_cell_name_demultiplexed_with_bcl2fastq() -> str:
"""Return the name of a flow cell that has been demultiplexed with BCL2Fastq."""
return "HHKVCALXX"


@pytest.fixture(scope="session")
def flow_cell_directory_name_demultiplexed_with_bcl2fastq(
flow_cell_name_demultiplexed_with_bcl2fastq: str,
) -> str:
"""Return the name of a flow cell directory that has been demultiplexed with BCL2Fastq."""
return f"170407_ST-E00198_0209_B{flow_cell_name_demultiplexed_with_bcl2fastq}"


@pytest.fixture(scope="session")
def flow_cell_name_demultiplexed_with_bcl_convert() -> str:
return "HY7FFDRX2"


@pytest.fixture(scope="session")
def flow_cell_directory_name_demultiplexed_with_bcl_convert(
flow_cell_name_demultiplexed_with_bcl_convert: str,
) -> str:
return f"230504_A00689_0804_B{flow_cell_name_demultiplexed_with_bcl_convert}"


@pytest.fixture(scope="session")
def hiseq_x_single_index_flow_cell_name() -> str:
"""Return the full name of a HiSeqX flow cell with only one index."""
return "170517_ST-E00266_0210_BHJCFFALXX"


@pytest.fixture(scope="session")
def hiseq_x_dual_index_flow_cell_name() -> str:
"""Return the full name of a HiSeqX flow cell with two indexes."""
return "180508_ST-E00269_0269_AHL32LCCXY"


@pytest.fixture(scope="session")
def hiseq_2500_dual_index_flow_cell_name() -> str:
"""Return the full name of a HiSeq2500 flow cell with double indexes."""
return "181005_D00410_0735_BHM2LNBCX2"


@pytest.fixture(scope="session")
def hiseq_2500_custom_index_flow_cell_name() -> str:
"""Return the full name of a HiSeq2500 flow cell with double indexes."""
return "180509_D00450_0598_BHGYFNBCX2"


@pytest.fixture(scope="session")
def bcl2fastq_flow_cell_full_name() -> str:
"""Return full flow cell name."""
return "201203_D00483_0200_AHVKJCDRXX"


@pytest.fixture(scope="session")
def bcl_convert_flow_cell_full_name() -> str:
"""Return the full name of a bcl_convert flow cell."""
return "211101_A00187_0615_AHLG5GDRZZ"


@pytest.fixture(scope="session")
def novaseq_x_flow_cell_full_name() -> str:
"""Return the full name of a NovaSeqX flow cell."""
return "20230508_LH00188_0003_A22522YLT3"


# Lists


@pytest.fixture(scope="session")
def bcl_convert_demultiplexed_flow_cell_sample_internal_ids() -> list[str]:
diitaz93 marked this conversation as resolved.
Show resolved Hide resolved
"""
Sample id:s present in sample sheet for dummy flow cell demultiplexed with BCL Convert in
cg/tests/fixtures/apps/demultiplexing/demultiplexed-runs/230504_A00689_0804_BHY7FFDRX2.
"""
return ["ACC11927A2", "ACC11927A5"]


@pytest.fixture(scope="session")
def bcl2fastq_demultiplexed_flow_cell_sample_internal_ids() -> list[str]:
"""
Sample id:s present in sample sheet for dummy flow cell demultiplexed with BCL Convert in
cg/tests/fixtures/apps/demultiplexing/demultiplexed-runs/170407_A00689_0209_BHHKVCALXX.
"""
return ["SVE2528A1"]
Loading
Loading