Skip to content

Commit

Permalink
renamed fixture files and sort them alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
diitaz93 committed Jan 10, 2025
1 parent bedb7d1 commit 6014245
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 76 deletions.
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@
"tests.fixture_plugins.observations_fixtures.observations_api_fixtures",
"tests.fixture_plugins.observations_fixtures.observations_input_files_fixtures",
"tests.fixture_plugins.orders_fixtures.order_form_fixtures",
"tests.fixture_plugins.orders_fixtures.order_store_service_fixtures",
"tests.fixture_plugins.orders_fixtures.order_to_submit_fixtures",
"tests.fixture_plugins.orders_fixtures.order_fixtures",
"tests.fixture_plugins.orders_fixtures.store_fixtures",
"tests.fixture_plugins.orders_fixtures.store_service_fixtures",
"tests.fixture_plugins.pacbio_fixtures.context_fixtures",
"tests.fixture_plugins.pacbio_fixtures.dto_fixtures",
"tests.fixture_plugins.pacbio_fixtures.file_data_fixtures",
Expand Down
90 changes: 46 additions & 44 deletions tests/fixture_plugins/orders_fixtures/order_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Fixtures for orders parsed into their respective models."""

import pytest

from cg.services.order_validation_service.workflows.balsamic.models.order import BalsamicOrder
Expand All @@ -15,47 +17,55 @@


@pytest.fixture
def metagenome_order(
metagenome_order_to_submit: dict,
ticket_id_as_int: int,
) -> MetagenomeOrder:
"""Parse metagenome order example."""
order = MetagenomeOrder.model_validate(metagenome_order_to_submit)
order._generated_ticket_id = ticket_id_as_int
return order
def balsamic_order(balsamic_order_to_submit: dict) -> BalsamicOrder:
balsamic_order_to_submit["user_id"] = 1
balsamic_order = BalsamicOrder.model_validate(balsamic_order_to_submit)
balsamic_order._generated_ticket_id = 123456
for case_index, sample_index, sample in balsamic_order.enumerated_new_samples:
sample._generated_lims_id = f"ACC{case_index}-{sample_index}"
return balsamic_order


@pytest.fixture
def valid_rml_order(rml_order_to_submit: dict, ticket_id_as_int: int) -> RmlOrder:
"""Parse rml order example."""
rml_order = RmlOrder.model_validate(rml_order_to_submit)
rml_order._generated_ticket_id = ticket_id_as_int
return rml_order
def fastq_order(fastq_order_to_submit: dict) -> FastqOrder:
fastq_order = FastqOrder.model_validate(fastq_order_to_submit)
fastq_order._generated_ticket_id = 123456
return fastq_order


@pytest.fixture
def valid_fluffy_order(fluffy_order_to_submit: dict, ticket_id_as_int: int) -> FluffyOrder:
def fluffy_order(fluffy_order_to_submit: dict, ticket_id_as_int: int) -> FluffyOrder:
"""Parse Fluffy order example."""
fluffy_order = FluffyOrder.model_validate(fluffy_order_to_submit)
fluffy_order._generated_ticket_id = ticket_id_as_int
return fluffy_order


@pytest.fixture
def fastq_order(fastq_order_to_submit: dict) -> FastqOrder:
fastq_order = FastqOrder.model_validate(fastq_order_to_submit)
fastq_order._generated_ticket_id = 123456
return fastq_order
def metagenome_order(
metagenome_order_to_submit: dict,
ticket_id_as_int: int,
) -> MetagenomeOrder:
"""Parse metagenome order example."""
order = MetagenomeOrder.model_validate(metagenome_order_to_submit)
order._generated_ticket_id = ticket_id_as_int
return order


@pytest.fixture
def mip_rna_order(mip_rna_order_to_submit: dict) -> MipRnaOrder:
mip_rna_order_to_submit["user_id"] = 1
mip_rna_order = MipRnaOrder.model_validate(mip_rna_order_to_submit)
for case_index, sample_index, sample in mip_rna_order.enumerated_new_samples:
sample._generated_lims_id = f"ACC{case_index}-{sample_index}"
mip_rna_order._generated_ticket_id = 123456
return mip_rna_order
def microbial_fastq_order(
microbial_fastq_order_to_submit: dict, ticket_id_as_int: int
) -> MicrobialFastqOrder:
order = MicrobialFastqOrder.model_validate(microbial_fastq_order_to_submit)
order._generated_ticket_id = ticket_id_as_int
return order


@pytest.fixture
def microsalt_order(microbial_order_to_submit: dict) -> MicrosaltOrder:
order = MicrosaltOrder.model_validate(microbial_order_to_submit)
order._generated_ticket_id = 123456
return order


@pytest.fixture
Expand All @@ -69,20 +79,13 @@ def mip_dna_order(mip_dna_order_to_submit: dict) -> MipDnaOrder:


@pytest.fixture
def balsamic_order(balsamic_order_to_submit: dict) -> BalsamicOrder:
balsamic_order_to_submit["user_id"] = 1
balsamic_order = BalsamicOrder.model_validate(balsamic_order_to_submit)
balsamic_order._generated_ticket_id = 123456
for case_index, sample_index, sample in balsamic_order.enumerated_new_samples:
def mip_rna_order(mip_rna_order_to_submit: dict) -> MipRnaOrder:
mip_rna_order_to_submit["user_id"] = 1
mip_rna_order = MipRnaOrder.model_validate(mip_rna_order_to_submit)
for case_index, sample_index, sample in mip_rna_order.enumerated_new_samples:
sample._generated_lims_id = f"ACC{case_index}-{sample_index}"
return balsamic_order


@pytest.fixture
def microsalt_order(microbial_order_to_submit: dict) -> MicrosaltOrder:
order = MicrosaltOrder.model_validate(microbial_order_to_submit)
order._generated_ticket_id = 123456
return order
mip_rna_order._generated_ticket_id = 123456
return mip_rna_order


@pytest.fixture
Expand All @@ -93,9 +96,8 @@ def pacbio_order(pacbio_order_to_submit: dict, ticket_id_as_int: int) -> PacbioO


@pytest.fixture
def microbial_fastq_order(
microbial_fastq_order_to_submit: dict, ticket_id_as_int: int
) -> MicrobialFastqOrder:
order = MicrobialFastqOrder.model_validate(microbial_fastq_order_to_submit)
order._generated_ticket_id = ticket_id_as_int
return order
def rml_order(rml_order_to_submit: dict, ticket_id_as_int: int) -> RmlOrder:
"""Parse rml order example."""
rml_order = RmlOrder.model_validate(rml_order_to_submit)
rml_order._generated_ticket_id = ticket_id_as_int
return rml_order
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Fixtures for orders parsed from JSON files into dictionaries."""

from pathlib import Path

import pytest
Expand Down
45 changes: 32 additions & 13 deletions tests/fixture_plugins/orders_fixtures/store_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
"""Store fixtures for the order services tests."""

import pytest

from cg.constants.sequencing import SeqLibraryPrepCategory
from cg.models.orders.constants import OrderType
from cg.services.order_validation_service.workflows.balsamic.models.order import BalsamicOrder
from cg.services.order_validation_service.workflows.mip_dna.models.order import MipDnaOrder
from cg.store.models import Application
from cg.store.store import Store
from tests.store_helpers import StoreHelpers


@pytest.fixture
def balsamic_submit_store(
base_store: Store, balsamic_order: BalsamicOrder, helpers: StoreHelpers
) -> Store:
for _, _, sample in balsamic_order.enumerated_new_samples:
if not base_store.get_application_by_tag(sample.application):
application_version = helpers.ensure_application_version(
store=base_store, application_tag=sample.application
)
base_store.session.add(application_version)
base_store.session.commit()
return base_store


@pytest.fixture
def store_with_rml_applications(store: Store, helpers: StoreHelpers) -> Store:
app_tags: list[str] = ["RMLP15R100", "RMLP15R200", "RMLP15R400", "RMLP15R500"]
Expand All @@ -21,24 +39,25 @@ def store_with_rml_applications(store: Store, helpers: StoreHelpers) -> Store:


@pytest.fixture
def mip_dna_submit_store(
base_store: Store, mip_dna_order: MipDnaOrder, helpers: StoreHelpers
) -> Store:
for _, _, sample in mip_dna_order.enumerated_new_samples:
if not base_store.get_application_by_tag(sample.application):
application_version = helpers.ensure_application_version(
store=base_store, application_tag=sample.application
)
base_store.session.add(application_version)
base_store.session.commit()
def metagenome_storing_store(base_store: Store, helpers: StoreHelpers) -> Store:
metagenome_application: Application = helpers.ensure_application_version(
store=base_store, application_tag="METPCFR030"
).application
metagenome_application.order_types = [OrderType.METAGENOME]
metagenome_application: Application = helpers.ensure_application_version(
store=base_store, application_tag="METWPFR030"
).application
metagenome_application.order_types = [OrderType.METAGENOME]
customer = base_store.get_customer_by_internal_id("cust000")
helpers.ensure_user(store=base_store, customer=customer)
return base_store


@pytest.fixture
def balsamic_submit_store(
base_store: Store, balsamic_order: BalsamicOrder, helpers: StoreHelpers
def mip_dna_submit_store(
base_store: Store, mip_dna_order: MipDnaOrder, helpers: StoreHelpers
) -> Store:
for _, _, sample in balsamic_order.enumerated_new_samples:
for _, _, sample in mip_dna_order.enumerated_new_samples:
if not base_store.get_application_by_tag(sample.application):
application_version = helpers.ensure_application_version(
store=base_store, application_tag=sample.application
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest

from cg.models.orders.constants import OrderType
from cg.services.orders.order_lims_service.order_lims_service import OrderLimsService
from cg.services.orders.store_order_services.store_case_order import StoreCaseOrderService
from cg.services.orders.store_order_services.store_fastq_order_service import StoreFastqOrderService
Expand All @@ -15,7 +14,6 @@
StorePacBioOrderService,
)
from cg.services.orders.store_order_services.store_pool_order import StorePoolOrderService
from cg.store.models import Application
from cg.store.store import Store
from tests.mocks.limsmock import MockLimsAPI
from tests.store_helpers import StoreHelpers
Expand Down Expand Up @@ -45,21 +43,6 @@ def store_pacbio_order_service(base_store: Store, lims_api: MockLimsAPI) -> Stor
return StorePacBioOrderService(status_db=base_store, lims_service=OrderLimsService(lims_api))


@pytest.fixture
def metagenome_storing_store(base_store: Store, helpers: StoreHelpers):
metagenome_application: Application = helpers.ensure_application_version(
store=base_store, application_tag="METPCFR030"
).application
metagenome_application.order_types = [OrderType.METAGENOME]
metagenome_application: Application = helpers.ensure_application_version(
store=base_store, application_tag="METWPFR030"
).application
metagenome_application.order_types = [OrderType.METAGENOME]
customer = base_store.get_customer_by_internal_id("cust000")
helpers.ensure_user(store=base_store, customer=customer)
return base_store


@pytest.fixture
def store_metagenome_order_service(
metagenome_storing_store: Store, lims_api: MockLimsAPI, helpers: StoreHelpers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@pytest.mark.parametrize(
"order_fixture, workflow",
[("valid_rml_order", Workflow.RAW_DATA), ("valid_fluffy_order", Workflow.FLUFFY)],
[("rml_order", Workflow.RAW_DATA), ("fluffy_order", Workflow.FLUFFY)],
ids=["RML", "Fluffy"],
)
def test_store_order_data_in_status_db(
Expand Down

0 comments on commit 6014245

Please sign in to comment.