Пример #1
0
def test_add_sample_required(cli_runner: CliRunner, base_context: CGConfig,
                             helpers: StoreHelpers):
    # GIVEN a database with a customer and an application
    disk_store: Store = base_context.status_db
    sex = "male"
    application_tag = "dummy_tag"
    helpers.ensure_application(store=disk_store, tag=application_tag)
    helpers.ensure_application_version(store=disk_store,
                                       application_tag=application_tag)
    customer: models.Customer = helpers.ensure_customer(store=disk_store)
    customer_id = customer.internal_id
    name = "sample_name"

    # WHEN adding a sample
    result = cli_runner.invoke(
        add,
        [
            "sample",
            "--sex",
            sex,
            "--application",
            application_tag,
            customer_id,
            name,
        ],
        obj=base_context,
    )

    # THEN it should be added
    assert result.exit_code == 0
    assert disk_store.Sample.query.count() == 1
    assert disk_store.Sample.query.first().name == name
    assert disk_store.Sample.query.first().sex == sex
Пример #2
0
def fixture_microbial_store_dummy_tag(microbial_store: Store,
                                      helpers: StoreHelpers) -> Store:
    """Populate a microbial store with a extra dummy app tag"""
    helpers.ensure_application(store=microbial_store,
                               tag="dummy_tag",
                               application_type="mic",
                               is_archived=False)
    return microbial_store
Пример #3
0
def fixture_applications_store(store: Store, application_versions_file: str,
                               helpers: StoreHelpers) -> Store:
    """Return a store populated with applications from excel file"""
    versions: Iterable[ApplicationVersionSchema] = parse_application_versions(
        excel_path=application_versions_file)

    for version in versions:
        helpers.ensure_application(store=store, tag=version.app_tag)

    return store
Пример #4
0
def fixture_rml_store(store: Store, helpers: StoreHelpers) -> Store:
    """Populate a store with microbial application tags"""
    active_apptags = [
        "RMLP10R300",
        "RMLP10S130",
        "RMLP15R100",
        "RMLP15R200",
        "RMLP15R400",
        "RMLP15R500",
        "RMLP15R750",
        "RMLP15R825",
        "RMLP15S100",
        "RMLP15S125",
        "RMLP15S150",
        "RMLP15S175",
        "RMLP15S200",
        "RMLP15S225",
        "RMLP15S425",
    ]
    inactive_apptags = [
        "RMLP05R800",
        "RMLP15S250",
        "RMLP15S275",
        "RMLP15S300",
        "RMLP15S325",
        "RMLP15S350",
        "RMLP15S375",
        "RMLP15S400",
        "RMLP15S450",
        "RMLP15S475",
        "RMLP15S500",
        "RMLS05R200",
        "RMLCUSR800",
        "RMLCUSS160",
    ]

    for app_tag in active_apptags:
        helpers.ensure_application(store=store,
                                   tag=app_tag,
                                   application_type="rml",
                                   is_archived=False)

    for app_tag in inactive_apptags:
        helpers.ensure_application(store=store,
                                   tag=app_tag,
                                   application_type="rml",
                                   is_archived=True)

    return store
Пример #5
0
def fixture_microbial_store(store: Store, helpers: StoreHelpers) -> Store:
    """Populate a store with microbial application tags"""
    microbial_active_apptags = [
        "MWRNXTR003", "MWGNXTR003", "MWMNXTR003", "MWLNXTR003"
    ]
    microbial_inactive_apptags = ["MWXNXTR003", "VWGNXTR001", "VWLNXTR001"]

    for app_tag in microbial_active_apptags:
        helpers.ensure_application(store=store,
                                   tag=app_tag,
                                   application_type="mic",
                                   is_archived=False)

    for app_tag in microbial_inactive_apptags:
        helpers.ensure_application(store=store,
                                   tag=app_tag,
                                   application_type="mic",
                                   is_archived=True)

    return store
Пример #6
0
def test_add_sample_downsampled(
    cli_runner,
    base_context: CGConfig,
    disk_store: Store,
    application_tag: str,
    helpers: StoreHelpers,
):
    # GIVEN a database with a customer and an application
    helpers.ensure_application(store=disk_store, tag=application_tag)
    helpers.ensure_application_version(store=disk_store,
                                       application_tag=application_tag)
    customer: models.Customer = helpers.ensure_customer(store=disk_store)
    customer_id = customer.internal_id
    sex = "male"
    name = "sample_name"
    downsampled_to = "123"

    # WHEN adding a sample
    result = cli_runner.invoke(
        add,
        [
            "sample",
            "--sex",
            sex,
            "--application",
            application_tag,
            "--downsampled",
            downsampled_to,
            customer_id,
            name,
        ],
        obj=base_context,
    )

    # THEN it should be added
    assert result.exit_code == 0
    assert disk_store.Sample.query.count() == 1
    assert str(
        disk_store.Sample.query.first().downsampled_to) == downsampled_to