예제 #1
0
def fixture_real_populated_compress_fastq_api(
        real_compress_api: CompressAPI, compress_hk_fastq_bundle: dict,
        helpers: StoreHelpers) -> CompressAPI:
    """Populated compress api fixture"""
    helpers.ensure_hk_bundle(real_compress_api.hk_api,
                             compress_hk_fastq_bundle)

    return real_compress_api
예제 #2
0
def test_clean_hk_bundle_files_dry_run(
    caplog,
    case_id: str,
    cg_context: CGConfig,
    cli_runner: CliRunner,
    helpers: StoreHelpers,
    mocker,
    timestamp: datetime,
):
    # GIVEN a housekeeper api with some alignment files
    file_path = "path/to_file.cram"
    tag = "cram"
    hk_bundle_data = {
        "name": case_id,
        "created": timestamp,
        "expires": timestamp,
        "files": [
            {
                "path": file_path,
                "archive": False,
                "tags": [case_id, tag]
            },
        ],
    }
    store = cg_context.status_db
    case = helpers.ensure_case(store=store, case_id=case_id)
    helpers.add_analysis(store=store,
                         case=case,
                         started_at=timestamp,
                         completed_at=timestamp)
    helpers.ensure_hk_bundle(cg_context.housekeeper_api,
                             bundle_data=hk_bundle_data)

    # WHEN running the clean command in dry run mode
    caplog.set_level(logging.INFO)
    result = cli_runner.invoke(hk_bundle_files,
                               ["-c", case_id, "--dry-run", "--tags", tag],
                               obj=cg_context)

    # THEN assert it exits with success
    assert result.exit_code == 0
    # THEN assert that the files where removed
    assert f"{file_path} not on disk" in caplog.text
예제 #3
0
def fixture_mip_dna_housekeeper(
    real_housekeeper_api: HousekeeperAPI,
    mip_delivery_bundle: dict,
    fastq_delivery_bundle: dict,
    helpers: StoreHelpers,
) -> HousekeeperAPI:
    helpers.ensure_hk_bundle(real_housekeeper_api,
                             bundle_data=mip_delivery_bundle)
    helpers.ensure_hk_bundle(real_housekeeper_api,
                             bundle_data=fastq_delivery_bundle)
    # assert that the files exists
    version_obj_mip: hk_models.Version = real_housekeeper_api.last_version(
        mip_delivery_bundle["name"])
    version_obj_fastq: hk_models.Version = real_housekeeper_api.last_version(
        fastq_delivery_bundle["name"])
    real_housekeeper_api.include(version_obj=version_obj_mip)
    real_housekeeper_api.include(version_obj=version_obj_fastq)

    return real_housekeeper_api
def test_clean_hk_alignment_files_dry_run(
    cli_runner: CliRunner,
    cg_context: CGConfig,
    helpers: StoreHelpers,
    case_id: str,
    timestamp: datetime,
    caplog,
):
    # GIVEN a housekeeper api with some alignment files
    file_path = "path/to_file.cram"
    hk_bundle_data = {
        "name":
        case_id,
        "created":
        timestamp,
        "expires":
        timestamp,
        "files": [
            {
                "path": file_path,
                "archive": False,
                "tags": [case_id, "cram"]
            },
        ],
    }
    helpers.ensure_hk_bundle(cg_context.housekeeper_api,
                             bundle_data=hk_bundle_data)

    # WHEN running the clean command in dry run mode
    caplog.set_level(logging.INFO)
    result = cli_runner.invoke(hk_alignment_files,
                               [case_id, "--yes", "--dry-run"],
                               obj=cg_context)

    # THEN assert it exits with success
    assert result.exit_code == 0
    # THEN assert that the files where removed
    assert f"Deleting {file_path} from database" in caplog.text
예제 #5
0
def fixture_mip_hk_store(
    helpers: StoreHelpers,
    real_housekeeper_api: HousekeeperAPI,
    timestamp: datetime,
    case_id: str,
) -> HousekeeperAPI:
    deliver_hk_bundle_data = {
        "name":
        case_id,
        "created":
        timestamp,
        "expires":
        timestamp,
        "files": [
            {
                "path": "tests/fixtures/apps/mip/dna/store/case_config.yaml",
                "archive": False,
                "tags": ["mip-config"],
            },
            {
                "path":
                "tests/fixtures/apps/mip/dna/store/case_qc_sample_info.yaml",
                "archive": False,
                "tags": ["sampleinfo"],
            },
            {
                "path":
                "tests/fixtures/apps/mip/case_metrics_deliverables.yaml",
                "archive": False,
                "tags": [HkMipAnalysisTag.QC_METRICS],
            },
            {
                "path": "tests/fixtures/apps/mip/case_file.txt",
                "archive": False,
                "tags": ["case-tag"],
            },
            {
                "path": "tests/fixtures/apps/mip/sample_file.txt",
                "archive": False,
                "tags": ["sample-tag", "ADM1"],
            },
        ],
    }
    helpers.ensure_hk_bundle(real_housekeeper_api,
                             deliver_hk_bundle_data,
                             include=True)

    empty_deliver_hk_bundle_data = {
        "name":
        "case_missing_data",
        "created":
        timestamp,
        "expires":
        timestamp,
        "files": [
            {
                "path":
                "tests/fixtures/apps/mip/dna/store/empty_case_config.yaml",
                "archive": False,
                "tags": ["mip-config"],
            },
            {
                "path":
                "tests/fixtures/apps/mip/dna/store/empty_case_qc_sample_info.yaml",
                "archive": False,
                "tags": ["sampleinfo"],
            },
            {
                "path":
                "tests/fixtures/apps/mip/dna/store/empty_case_metrics_deliverables.yaml",
                "archive": False,
                "tags": [HkMipAnalysisTag.QC_METRICS],
            },
            {
                "path": "tests/fixtures/apps/mip/case_file.txt",
                "archive": False,
                "tags": ["case-tag"],
            },
            {
                "path": "tests/fixtures/apps/mip/sample_file.txt",
                "archive": False,
                "tags": ["sample-tag", "ADM1"],
            },
        ],
    }
    helpers.ensure_hk_bundle(real_housekeeper_api,
                             empty_deliver_hk_bundle_data,
                             include=True)

    return real_housekeeper_api