From f0a2ca8462c418043e5529c45eba31bc17cc9457 Mon Sep 17 00:00:00 2001 From: Sebastian Diaz Date: Wed, 15 Jan 2025 10:11:24 +0100 Subject: [PATCH] remove metagenome old validation --- .../validate_metagenome_order.py | 30 ------------------- .../order_to_submit_fixtures.py | 9 +++--- 2 files changed, 4 insertions(+), 35 deletions(-) delete mode 100644 cg/services/orders/validate_order_services/validate_metagenome_order.py diff --git a/cg/services/orders/validate_order_services/validate_metagenome_order.py b/cg/services/orders/validate_order_services/validate_metagenome_order.py deleted file mode 100644 index 2a171d2fa6..0000000000 --- a/cg/services/orders/validate_order_services/validate_metagenome_order.py +++ /dev/null @@ -1,30 +0,0 @@ -from cg.exc import OrderError -from cg.models.orders.order import OrderIn -from cg.models.orders.samples import MetagenomeSample -from cg.services.orders.store_order_services.store_order_service import ValidateOrderService -from cg.store.models import Customer -from cg.store.store import Store - - -class ValidateMetagenomeOrderService(ValidateOrderService): - - def __init__(self, status_db: Store): - self.status_db = status_db - - def validate_order(self, order: OrderIn) -> None: - self._validate_sample_names_are_unique(samples=order.samples, customer_id=order.customer) - - def _validate_sample_names_are_unique( - self, samples: list[MetagenomeSample], customer_id: str - ) -> None: - """Validate that the names of all samples are unused.""" - customer: Customer = self.status_db.get_customer_by_internal_id( - customer_internal_id=customer_id - ) - for sample in samples: - if sample.control: - continue - if self.status_db.get_sample_by_customer_and_name( - customer_entry_id=[customer.id], sample_name=sample.name - ): - raise OrderError(f"Sample name {sample.name} already in use") diff --git a/tests/fixture_plugins/orders_fixtures/order_to_submit_fixtures.py b/tests/fixture_plugins/orders_fixtures/order_to_submit_fixtures.py index ee006f2ff9..950b375983 100644 --- a/tests/fixture_plugins/orders_fixtures/order_to_submit_fixtures.py +++ b/tests/fixture_plugins/orders_fixtures/order_to_submit_fixtures.py @@ -7,9 +7,10 @@ from cg.constants.constants import FileFormat from cg.io.controller import ReadFile from cg.models.orders.constants import OrderType -from cg.models.orders.order import OrderIn +from cg.services.order_validation_service.models.order import Order from cg.services.order_validation_service.workflows.balsamic.models.order import BalsamicOrder from cg.services.order_validation_service.workflows.fastq.models.order import FastqOrder +from cg.services.order_validation_service.workflows.metagenome.models.order import MetagenomeOrder from cg.services.order_validation_service.workflows.mip_dna.models.order import MipDnaOrder from cg.services.order_validation_service.workflows.mip_rna.models.order import MipRnaOrder from cg.services.order_validation_service.workflows.pacbio_long_read.models.order import PacbioOrder @@ -132,15 +133,13 @@ def all_orders_to_submit( rml_order_to_submit: dict, rnafusion_order_to_submit: dict, sarscov2_order_to_submit: dict, -) -> dict[str, OrderIn]: +) -> dict[OrderType, Order]: """Returns a dict of parsed order for each order type.""" return { OrderType.BALSAMIC: BalsamicOrder.model_validate(balsamic_order_to_submit), OrderType.FASTQ: FastqOrder.model_validate(fastq_order_to_submit), # OrderType.FLUFFY: FluffyOrder.model_validate(rml_order_to_submit), - OrderType.METAGENOME: OrderIn.parse_obj( - metagenome_order_to_submit, project=OrderType.METAGENOME - ), + OrderType.METAGENOME: MetagenomeOrder.model_validate(metagenome_order_to_submit), # OrderType.MICROSALT: OrderIn.parse_obj( # microbial_order_to_submit, project=OrderType.MICROSALT # ),