From 653377f5a23ef43962e6b9cde3c0f0cb86ae265a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isak=20Ohlsson=20=C3=85ngnell?= <40887124+islean@users.noreply.github.com> Date: Fri, 10 Jan 2025 14:10:23 +0100 Subject: [PATCH] (Improve order flow) Remove submitters (#4062) (minor) ### Changed - The OrderSubmitterRegistry is a StoringServiceRegistry - The OrderSubmitters are removed - The OrdersAPI needs no Store in its init - The OrdersAPI needs a StoringServiceRegistry instead of a SubmitterRegistry - The OrdersAPI needs an OrderValidationService --- cg/meta/orders/api.py | 20 +-- cg/server/endpoints/orders.py | 6 +- cg/server/ext.py | 8 +- .../{orders/submitters => }/__init__.py | 0 .../orders/order_service/order_service.py | 19 +- .../orders/store_order_services/__init__.py | 0 .../implementations/__init__.py | 0 .../{ => implementations}/store_case_order.py | 2 +- .../store_fastq_order_service.py | 2 +- .../store_metagenome_order.py | 2 +- .../store_microbial_fastq_order_service.py | 2 +- .../store_microbial_order.py | 2 +- .../store_pacbio_order_service.py | 3 +- .../{ => implementations}/store_pool_order.py | 2 +- .../store_order_service.py} | 19 +- .../storing_service_registry.py | 134 ++++++++++++++ .../orders/submitters/case_order_submitter.py | 31 ---- .../submitters/fastq_order_submitter.py | 21 --- .../submitters/metagenome_order_submitter.py | 25 --- .../submitters/microbial_order_submitter.py | 35 ---- .../submitters/order_submitter_registry.py | 166 ------------------ .../submitters/pacbio_order_submitter.py | 25 --- .../orders/submitters/pool_order_submitter.py | 25 --- .../validate_case_order.py | 4 +- .../validate_fastq_order.py | 2 +- .../validate_metagenome_order.py | 2 +- .../validate_microbial_order.py | 2 +- .../validate_pacbio_order.py | 2 +- .../validate_pool_order.py | 2 +- .../orders_fixtures/store_service_fixtures.py | 22 ++- tests/meta/orders/conftest.py | 25 +-- tests/meta/orders/test_meta_orders_api.py | 22 +-- .../test_fastq_order_service.py | 4 +- .../test_generic_order_store_service.py | 4 +- .../test_metagenome_store_service.py | 2 +- ...est_microbial_fastq_order_store_service.py | 2 +- .../test_microbial_store_order_service.py | 4 +- .../test_pacbio_order_service.py | 2 +- .../test_pool_order_store_service.py | 4 +- tests/store/conftest.py | 15 +- 40 files changed, 235 insertions(+), 434 deletions(-) rename cg/services/{orders/submitters => }/__init__.py (100%) create mode 100644 cg/services/orders/store_order_services/__init__.py create mode 100644 cg/services/orders/store_order_services/implementations/__init__.py rename cg/services/orders/store_order_services/{ => implementations}/store_case_order.py (99%) rename cg/services/orders/store_order_services/{ => implementations}/store_fastq_order_service.py (98%) rename cg/services/orders/store_order_services/{ => implementations}/store_metagenome_order.py (98%) rename cg/services/orders/store_order_services/{ => implementations}/store_microbial_fastq_order_service.py (98%) rename cg/services/orders/store_order_services/{ => implementations}/store_microbial_order.py (98%) rename cg/services/orders/store_order_services/{ => implementations}/store_pacbio_order_service.py (97%) rename cg/services/orders/store_order_services/{ => implementations}/store_pool_order.py (98%) rename cg/services/orders/{submitters/order_submitter.py => store_order_services/store_order_service.py} (69%) create mode 100644 cg/services/orders/store_order_services/storing_service_registry.py delete mode 100644 cg/services/orders/submitters/case_order_submitter.py delete mode 100644 cg/services/orders/submitters/fastq_order_submitter.py delete mode 100644 cg/services/orders/submitters/metagenome_order_submitter.py delete mode 100644 cg/services/orders/submitters/microbial_order_submitter.py delete mode 100644 cg/services/orders/submitters/order_submitter_registry.py delete mode 100644 cg/services/orders/submitters/pacbio_order_submitter.py delete mode 100644 cg/services/orders/submitters/pool_order_submitter.py diff --git a/cg/meta/orders/api.py b/cg/meta/orders/api.py index 0352adafb9..37fbfb47f1 100644 --- a/cg/meta/orders/api.py +++ b/cg/meta/orders/api.py @@ -13,10 +13,10 @@ from cg.meta.orders.ticket_handler import TicketHandler from cg.models.orders.order import OrderType from cg.services.order_validation_service.models.order import Order -from cg.services.orders.submitters.order_submitter import OrderSubmitter -from cg.services.orders.submitters.order_submitter_registry import OrderSubmitterRegistry +from cg.services.order_validation_service.order_validation_service import OrderValidationService +from cg.services.orders.store_order_services.store_order_service import StoreOrderService +from cg.services.orders.store_order_services.storing_service_registry import StoringServiceRegistry from cg.store.models import User -from cg.store.store import Store LOG = logging.getLogger(__name__) @@ -27,27 +27,27 @@ class OrdersAPI: def __init__( self, lims: LimsAPI, - status: Store, ticket_handler: TicketHandler, - submitter_registry: OrderSubmitterRegistry, + storing_registry: StoringServiceRegistry, + validation_service: OrderValidationService, ): super().__init__() self.lims = lims - self.status = status self.ticket_handler = ticket_handler - self.submitter_registry = submitter_registry + self.storing_registry = storing_registry + self.validation_service = validation_service def submit(self, order_type: OrderType, raw_order: dict, user: User) -> dict: """Submit a batch of samples. Main entry point for the class towards interfaces that implements it. """ - submit_handler: OrderSubmitter = self.submitter_registry.get_order_submitter(order_type) - order: Order = submit_handler.order_validation_service.parse_and_validate( + storing_service: StoreOrderService = self.storing_registry.get_storing_service(order_type) + order: Order = self.validation_service.parse_and_validate( raw_order=raw_order, order_type=order_type ) ticket_number: int = self.ticket_handler.create_ticket( order=order, user_name=user.name, user_mail=user.email, order_type=order_type ) order._generated_ticket_id = ticket_number - return submit_handler.submit_order(order) + return storing_service.store_order(order) diff --git a/cg/server/endpoints/orders.py b/cg/server/endpoints/orders.py index 7f811f6241..e1d2a10f32 100644 --- a/cg/server/endpoints/orders.py +++ b/cg/server/endpoints/orders.py @@ -37,8 +37,8 @@ delivery_message_service, lims, order_service, - order_submitter_registry, order_validation_service, + storing_service_registry, ticket_handler, ) from cg.store.models import Application, Customer @@ -153,9 +153,9 @@ def submit_order(order_type: OrderType): """Submit an order for samples.""" api = OrdersAPI( lims=lims, - status=db, ticket_handler=ticket_handler, - submitter_registry=order_submitter_registry, + storing_registry=storing_service_registry, + validation_service=order_validation_service, ) error_message: str try: diff --git a/cg/server/ext.py b/cg/server/ext.py index c7b044ce85..82863ad0fb 100644 --- a/cg/server/ext.py +++ b/cg/server/ext.py @@ -15,9 +15,9 @@ from cg.services.order_validation_service.order_validation_service import OrderValidationService from cg.services.orders.order_service.order_service import OrderService from cg.services.orders.order_summary_service.order_summary_service import OrderSummaryService -from cg.services.orders.submitters.order_submitter_registry import ( - OrderSubmitterRegistry, - setup_order_submitter_registry, +from cg.services.orders.store_order_services.storing_service_registry import ( + StoringServiceRegistry, + setup_storing_service_registry, ) from cg.services.sample_run_metrics_service.sample_run_metrics_service import ( SampleRunMetricsService, @@ -95,7 +95,7 @@ def init_app(self, app): order_service = OrderService(store=db, status_service=summary_service) sample_service = SampleService(db) flow_cell_service = SampleRunMetricsService(db) -order_submitter_registry: OrderSubmitterRegistry = setup_order_submitter_registry( +storing_service_registry: StoringServiceRegistry = setup_storing_service_registry( lims=lims, status_db=db, ) diff --git a/cg/services/orders/submitters/__init__.py b/cg/services/__init__.py similarity index 100% rename from cg/services/orders/submitters/__init__.py rename to cg/services/__init__.py diff --git a/cg/services/orders/order_service/order_service.py b/cg/services/orders/order_service/order_service.py index 11d5ee9fa1..c6bd4caf45 100644 --- a/cg/services/orders/order_service/order_service.py +++ b/cg/services/orders/order_service/order_service.py @@ -1,13 +1,10 @@ from cg.server.dto.orders.orders_request import OrdersRequest -from cg.server.dto.orders.orders_response import Order as OrderResponse, Order -from cg.server.dto.orders.orders_response import OrdersResponse +from cg.server.dto.orders.orders_response import Order, OrdersResponse from cg.services.orders.order_service.models import OrderQueryParams from cg.services.orders.order_summary_service.dto.order_summary import OrderSummary -from cg.services.orders.order_summary_service.order_summary_service import ( - OrderSummaryService, -) -from cg.store.store import Store +from cg.services.orders.order_summary_service.order_summary_service import OrderSummaryService from cg.store.models import Order as DatabaseOrder +from cg.store.store import Store class OrderService: @@ -15,8 +12,8 @@ def __init__(self, store: Store, status_service: OrderSummaryService) -> None: self.store = store self.summary_service = status_service - def get_order(self, order_id: int) -> OrderResponse: - order: Order = self.store.get_order_by_id(order_id) + def get_order(self, order_id: int) -> Order: + order: DatabaseOrder = self.store.get_order_by_id(order_id) summary: OrderSummary = self.summary_service.get_summary(order_id) return self._create_order_response(order=order, summary=summary) @@ -29,13 +26,13 @@ def get_orders(self, orders_request: OrdersRequest) -> OrdersResponse: summaries: list[OrderSummary] = self.summary_service.get_summaries(order_ids) return self._create_orders_response(orders=orders, summaries=summaries, total=total_count) - def set_open(self, order_id: int, open: bool) -> OrderResponse: - order: Order = self.store.update_order_status(order_id=order_id, open=open) + def set_open(self, order_id: int, open: bool) -> Order: + order: DatabaseOrder = self.store.update_order_status(order_id=order_id, open=open) return self._create_order_response(order) def update_is_open(self, order_id: int, delivered_analyses: int) -> None: """Update the is_open parameter of an order based on the number of delivered analyses.""" - order: Order = self.store.get_order_by_id(order_id) + order: DatabaseOrder = self.store.get_order_by_id(order_id) case_count: int = len(order.cases) if self._is_order_closed(case_count=case_count, delivered_analyses=delivered_analyses): self.set_open(order_id=order_id, open=False) diff --git a/cg/services/orders/store_order_services/__init__.py b/cg/services/orders/store_order_services/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cg/services/orders/store_order_services/implementations/__init__.py b/cg/services/orders/store_order_services/implementations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cg/services/orders/store_order_services/store_case_order.py b/cg/services/orders/store_order_services/implementations/store_case_order.py similarity index 99% rename from cg/services/orders/store_order_services/store_case_order.py rename to cg/services/orders/store_order_services/implementations/store_case_order.py index 4ba0da6bb8..9f015e3307 100644 --- a/cg/services/orders/store_order_services/store_case_order.py +++ b/cg/services/orders/store_order_services/implementations/store_case_order.py @@ -9,7 +9,7 @@ from cg.services.order_validation_service.models.sample_aliases import SampleInCase from cg.services.orders.constants import ORDER_TYPE_WORKFLOW_MAP from cg.services.orders.order_lims_service.order_lims_service import OrderLimsService -from cg.services.orders.submitters.order_submitter import StoreOrderService +from cg.services.orders.store_order_services.store_order_service import StoreOrderService from cg.store.models import ApplicationVersion from cg.store.models import Case as DbCase from cg.store.models import CaseSample, Customer diff --git a/cg/services/orders/store_order_services/store_fastq_order_service.py b/cg/services/orders/store_order_services/implementations/store_fastq_order_service.py similarity index 98% rename from cg/services/orders/store_order_services/store_fastq_order_service.py rename to cg/services/orders/store_order_services/implementations/store_fastq_order_service.py index cf11b078bf..f18214c9fc 100644 --- a/cg/services/orders/store_order_services/store_fastq_order_service.py +++ b/cg/services/orders/store_order_services/implementations/store_fastq_order_service.py @@ -8,7 +8,7 @@ from cg.services.order_validation_service.workflows.fastq.models.order import FastqOrder from cg.services.order_validation_service.workflows.fastq.models.sample import FastqSample from cg.services.orders.order_lims_service.order_lims_service import OrderLimsService -from cg.services.orders.submitters.order_submitter import StoreOrderService +from cg.services.orders.store_order_services.store_order_service import StoreOrderService from cg.store.models import ApplicationVersion, Case, CaseSample, Customer, Order, Sample from cg.store.store import Store diff --git a/cg/services/orders/store_order_services/store_metagenome_order.py b/cg/services/orders/store_order_services/implementations/store_metagenome_order.py similarity index 98% rename from cg/services/orders/store_order_services/store_metagenome_order.py rename to cg/services/orders/store_order_services/implementations/store_metagenome_order.py index 029829cd39..3b0b4d13d0 100644 --- a/cg/services/orders/store_order_services/store_metagenome_order.py +++ b/cg/services/orders/store_order_services/implementations/store_metagenome_order.py @@ -11,7 +11,7 @@ ) from cg.services.orders.constants import ORDER_TYPE_WORKFLOW_MAP from cg.services.orders.order_lims_service.order_lims_service import OrderLimsService -from cg.services.orders.submitters.order_submitter import StoreOrderService +from cg.services.orders.store_order_services.store_order_service import StoreOrderService from cg.store.models import ApplicationVersion from cg.store.models import Case as DbCase from cg.store.models import CaseSample, Customer diff --git a/cg/services/orders/store_order_services/store_microbial_fastq_order_service.py b/cg/services/orders/store_order_services/implementations/store_microbial_fastq_order_service.py similarity index 98% rename from cg/services/orders/store_order_services/store_microbial_fastq_order_service.py rename to cg/services/orders/store_order_services/implementations/store_microbial_fastq_order_service.py index 965ff84590..0459593796 100644 --- a/cg/services/orders/store_order_services/store_microbial_fastq_order_service.py +++ b/cg/services/orders/store_order_services/implementations/store_microbial_fastq_order_service.py @@ -9,7 +9,7 @@ MicrobialFastqSample, ) from cg.services.orders.order_lims_service.order_lims_service import OrderLimsService -from cg.services.orders.submitters.order_submitter import StoreOrderService +from cg.services.orders.store_order_services.store_order_service import StoreOrderService from cg.store.models import ApplicationVersion, Case, CaseSample, Customer, Order, Sample from cg.store.store import Store diff --git a/cg/services/orders/store_order_services/store_microbial_order.py b/cg/services/orders/store_order_services/implementations/store_microbial_order.py similarity index 98% rename from cg/services/orders/store_order_services/store_microbial_order.py rename to cg/services/orders/store_order_services/implementations/store_microbial_order.py index 26e6f0ce7c..8a98609466 100644 --- a/cg/services/orders/store_order_services/store_microbial_order.py +++ b/cg/services/orders/store_order_services/implementations/store_microbial_order.py @@ -8,7 +8,7 @@ from cg.services.order_validation_service.workflows.mutant.models.sample import MutantSample from cg.services.orders.constants import ORDER_TYPE_WORKFLOW_MAP from cg.services.orders.order_lims_service.order_lims_service import OrderLimsService -from cg.services.orders.submitters.order_submitter import StoreOrderService +from cg.services.orders.store_order_services.store_order_service import StoreOrderService from cg.store.models import ApplicationVersion from cg.store.models import Case as DbCase from cg.store.models import CaseSample, Customer diff --git a/cg/services/orders/store_order_services/store_pacbio_order_service.py b/cg/services/orders/store_order_services/implementations/store_pacbio_order_service.py similarity index 97% rename from cg/services/orders/store_order_services/store_pacbio_order_service.py rename to cg/services/orders/store_order_services/implementations/store_pacbio_order_service.py index 488be019fc..c82e132a70 100644 --- a/cg/services/orders/store_order_services/store_pacbio_order_service.py +++ b/cg/services/orders/store_order_services/implementations/store_pacbio_order_service.py @@ -2,14 +2,13 @@ from datetime import datetime from cg.constants import DataDelivery, Workflow -from cg.models.orders.order import OrderIn from cg.models.orders.sample_base import StatusEnum from cg.services.order_validation_service.workflows.pacbio_long_read.models.order import PacbioOrder from cg.services.order_validation_service.workflows.pacbio_long_read.models.sample import ( PacbioSample, ) from cg.services.orders.order_lims_service.order_lims_service import OrderLimsService -from cg.services.orders.submitters.order_submitter import StoreOrderService +from cg.services.orders.store_order_services.store_order_service import StoreOrderService from cg.store.models import ApplicationVersion, Case, CaseSample, Customer, Order, Sample from cg.store.store import Store diff --git a/cg/services/orders/store_order_services/store_pool_order.py b/cg/services/orders/store_order_services/implementations/store_pool_order.py similarity index 98% rename from cg/services/orders/store_order_services/store_pool_order.py rename to cg/services/orders/store_order_services/implementations/store_pool_order.py index da96956d83..4bf7a5ede1 100644 --- a/cg/services/orders/store_order_services/store_pool_order.py +++ b/cg/services/orders/store_order_services/implementations/store_pool_order.py @@ -8,7 +8,7 @@ ) from cg.services.orders.constants import ORDER_TYPE_WORKFLOW_MAP from cg.services.orders.order_lims_service.order_lims_service import OrderLimsService -from cg.services.orders.submitters.order_submitter import StoreOrderService +from cg.services.orders.store_order_services.store_order_service import StoreOrderService from cg.store.models import ApplicationVersion, Case, CaseSample, Customer, Order, Pool, Sample from cg.store.store import Store diff --git a/cg/services/orders/submitters/order_submitter.py b/cg/services/orders/store_order_services/store_order_service.py similarity index 69% rename from cg/services/orders/submitters/order_submitter.py rename to cg/services/orders/store_order_services/store_order_service.py index ed48eee27a..4b63eadd1d 100644 --- a/cg/services/orders/submitters/order_submitter.py +++ b/cg/services/orders/store_order_services/store_order_service.py @@ -4,8 +4,8 @@ from abc import ABC, abstractmethod from cg.models.orders.order import OrderIn +from cg.services.order_validation_service.models.order import Order from cg.services.order_validation_service.models.sample import Sample -from cg.services.order_validation_service.order_validation_service import OrderValidationService from cg.services.orders.order_lims_service.order_lims_service import OrderLimsService from cg.store.store import Store @@ -29,7 +29,7 @@ def __init__(self, status_db: Store, lims_service: OrderLimsService): self.lims = lims_service @abstractmethod - def store_order(self, order_in: OrderIn): + def store_order(self, order: Order): pass @staticmethod @@ -40,18 +40,3 @@ def _fill_in_sample_ids(samples: list[Sample], lims_map: dict): internal_id = lims_map[sample.name] LOG.info(f"{sample.name} -> {internal_id}: connect sample to LIMS") sample._generated_lims_id = internal_id - - -class OrderSubmitter(ABC): - @abstractmethod - def __init__( - self, - validate_order_service: OrderValidationService, - store_order_service: StoreOrderService, - ): - self.order_validation_service = validate_order_service - self.order_store_service = store_order_service - - @abstractmethod - def submit_order(self, order_in: OrderIn) -> dict: - pass diff --git a/cg/services/orders/store_order_services/storing_service_registry.py b/cg/services/orders/store_order_services/storing_service_registry.py new file mode 100644 index 0000000000..5e4736d8d5 --- /dev/null +++ b/cg/services/orders/store_order_services/storing_service_registry.py @@ -0,0 +1,134 @@ +from cg.apps.lims import LimsAPI +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.implementations.store_case_order import ( + StoreCaseOrderService, +) +from cg.services.orders.store_order_services.implementations.store_fastq_order_service import ( + StoreFastqOrderService, +) +from cg.services.orders.store_order_services.implementations.store_metagenome_order import ( + StoreMetagenomeOrderService, +) +from cg.services.orders.store_order_services.implementations.store_microbial_fastq_order_service import ( + StoreMicrobialFastqOrderService, +) +from cg.services.orders.store_order_services.implementations.store_microbial_order import ( + StoreMicrobialOrderService, +) +from cg.services.orders.store_order_services.implementations.store_pacbio_order_service import ( + StorePacBioOrderService, +) +from cg.services.orders.store_order_services.implementations.store_pool_order import ( + StorePoolOrderService, +) +from cg.services.orders.store_order_services.store_order_service import StoreOrderService +from cg.store.store import Store + + +class StoringServiceRegistry: + """ + A registry for StoreOrderService instances, keyed by OrderType. + """ + + def __init__(self): + self._registry = {} + + def register(self, order_type: OrderType, storing_service: StoreOrderService): + """Register a StoreOrderService instance for a given OrderType.""" + self._registry[order_type] = storing_service + + def get_storing_service(self, order_type: OrderType) -> StoreOrderService: + """Fetch the registered StoreOrderService for the given OrderType.""" + if storing_service := self._registry.get(order_type): + return storing_service + raise ValueError(f"No StoreOrderService registered for order type: {order_type}") + + +order_service_mapping = { + OrderType.BALSAMIC: ( + OrderLimsService, + StoreCaseOrderService, + ), + OrderType.BALSAMIC_QC: ( + OrderLimsService, + StoreCaseOrderService, + ), + OrderType.BALSAMIC_UMI: ( + OrderLimsService, + StoreCaseOrderService, + ), + OrderType.FASTQ: ( + OrderLimsService, + StoreFastqOrderService, + ), + OrderType.FLUFFY: ( + OrderLimsService, + StorePoolOrderService, + ), + OrderType.METAGENOME: ( + OrderLimsService, + StoreMetagenomeOrderService, + ), + OrderType.MICROBIAL_FASTQ: ( + OrderLimsService, + StoreMicrobialFastqOrderService, + ), + OrderType.MICROSALT: ( + OrderLimsService, + StoreMicrobialOrderService, + ), + OrderType.MIP_DNA: ( + OrderLimsService, + StoreCaseOrderService, + ), + OrderType.MIP_RNA: ( + OrderLimsService, + StoreCaseOrderService, + ), + OrderType.PACBIO_LONG_READ: ( + OrderLimsService, + StorePacBioOrderService, + ), + OrderType.RML: ( + OrderLimsService, + StorePoolOrderService, + ), + OrderType.RNAFUSION: ( + OrderLimsService, + StoreCaseOrderService, + ), + OrderType.SARS_COV_2: ( + OrderLimsService, + StoreMicrobialOrderService, + ), + OrderType.TAXPROFILER: ( + OrderLimsService, + StoreMetagenomeOrderService, + ), + OrderType.TOMTE: ( + OrderLimsService, + StoreCaseOrderService, + ), +} + + +def build_storing_service( + lims: LimsAPI, status_db: Store, order_type: OrderType +) -> StoreOrderService: + """Build a StoreOrderService instance for the given OrderType.""" + lims_service, store_service = order_service_mapping[order_type] + return store_service(status_db, lims_service(lims)) + + +def setup_storing_service_registry(lims: LimsAPI, status_db: Store) -> StoringServiceRegistry: + """Set up the StoringServiceRegistry with all StoreOrderService instances.""" + registry = StoringServiceRegistry() + for order_type in order_service_mapping.keys(): + registry.register( + order_type=order_type, + storing_service=build_storing_service( + lims=lims, status_db=status_db, order_type=order_type + ), + ) + return registry diff --git a/cg/services/orders/submitters/case_order_submitter.py b/cg/services/orders/submitters/case_order_submitter.py deleted file mode 100644 index b00ca1a0dd..0000000000 --- a/cg/services/orders/submitters/case_order_submitter.py +++ /dev/null @@ -1,31 +0,0 @@ -"""Module for a generic order submitter.""" - -from cg.services.order_validation_service.models.order_with_cases import OrderWithCases -from cg.services.orders.store_order_services.store_case_order import StoreCaseOrderService -from cg.services.orders.submitters.order_submitter import OrderSubmitter -from cg.services.orders.validate_order_services.validate_case_order import ValidateCaseOrderService - - -class CaseOrderSubmitter(OrderSubmitter): - """ - Class for submitting generic orders. - This class is used to submit orders for the following workflows: - - Balsamic - - Balsamic QC - - Balsamic UMI - - MIP DNA - - MIP RNA - - Tomte - """ - - def __init__( - self, - order_validation_service: ValidateCaseOrderService, - order_store_service: StoreCaseOrderService, - ): - self.order_validation_service = order_validation_service - self.order_store_service = order_store_service - - def submit_order(self, order: OrderWithCases) -> dict: - """Submit a generic order.""" - return self.order_store_service.store_order(order) diff --git a/cg/services/orders/submitters/fastq_order_submitter.py b/cg/services/orders/submitters/fastq_order_submitter.py deleted file mode 100644 index 5f8f52e84e..0000000000 --- a/cg/services/orders/submitters/fastq_order_submitter.py +++ /dev/null @@ -1,21 +0,0 @@ -from cg.services.order_validation_service.order_validation_service import OrderValidationService -from cg.services.order_validation_service.workflows.fastq.models.order import FastqOrder -from cg.services.orders.store_order_services.store_fastq_order_service import StoreFastqOrderService -from cg.services.orders.submitters.order_submitter import OrderSubmitter - - -class FastqOrderSubmitter(OrderSubmitter): - """Submitter for fastq orders.""" - - def __init__( - self, - order_validation_service: OrderValidationService, - order_store_service: StoreFastqOrderService, - ): - self.order_validation_service = order_validation_service - self.order_store_service = order_store_service - - def submit_order(self, order: FastqOrder) -> dict: - """Submit a fastq order.""" - result: dict = self.order_store_service.store_order(order) - return result diff --git a/cg/services/orders/submitters/metagenome_order_submitter.py b/cg/services/orders/submitters/metagenome_order_submitter.py deleted file mode 100644 index 3cad7b546c..0000000000 --- a/cg/services/orders/submitters/metagenome_order_submitter.py +++ /dev/null @@ -1,25 +0,0 @@ -from cg.services.order_validation_service.workflows.metagenome.models.order import MetagenomeOrder -from cg.services.order_validation_service.workflows.taxprofiler.models.order import TaxprofilerOrder -from cg.services.orders.store_order_services.store_metagenome_order import ( - StoreMetagenomeOrderService, -) -from cg.services.orders.submitters.order_submitter import OrderSubmitter -from cg.services.orders.validate_order_services.validate_metagenome_order import ( - ValidateMetagenomeOrderService, -) - - -class MetagenomeOrderSubmitter(OrderSubmitter): - """Class for submitting metagenome and taxprofiler orders.""" - - def __init__( - self, - order_validation_service: ValidateMetagenomeOrderService, - order_store_service: StoreMetagenomeOrderService, - ): - self.order_validation_service = order_validation_service - self.order_store_service = order_store_service - - def submit_order(self, order: MetagenomeOrder | TaxprofilerOrder) -> dict: - """Submit a metagenome order.""" - return self.order_store_service.store_order(order) diff --git a/cg/services/orders/submitters/microbial_order_submitter.py b/cg/services/orders/submitters/microbial_order_submitter.py deleted file mode 100644 index 751d1ac591..0000000000 --- a/cg/services/orders/submitters/microbial_order_submitter.py +++ /dev/null @@ -1,35 +0,0 @@ -from cg.services.order_validation_service.workflows.microbial_fastq.models.order import ( - MicrobialFastqOrder, -) -from cg.services.order_validation_service.workflows.microsalt.models.order import MicrosaltOrder -from cg.services.order_validation_service.workflows.mutant.models.order import MutantOrder -from cg.services.orders.store_order_services.store_microbial_fastq_order_service import ( - StoreMicrobialFastqOrderService, -) -from cg.services.orders.store_order_services.store_microbial_order import StoreMicrobialOrderService -from cg.services.orders.submitters.order_submitter import OrderSubmitter -from cg.services.orders.validate_order_services.validate_microbial_order import ( - ValidateMicrobialOrderService, -) - - -class MicrobialOrderSubmitter(OrderSubmitter): - """ - Class for submitting microbial orders. - This class is used to submit orders for the following workflows: - - Microsalt - - Microbial fastq - - Mutant - """ - - def __init__( - self, - order_validation_service: ValidateMicrobialOrderService, - order_store_service: StoreMicrobialOrderService | StoreMicrobialFastqOrderService, - ): - self.order_validation_service = order_validation_service - self.order_store_service = order_store_service - - def submit_order(self, order: MutantOrder | MicrosaltOrder | MicrobialFastqOrder) -> dict: - """Submit a microbial order.""" - return self.order_store_service.store_order(order) diff --git a/cg/services/orders/submitters/order_submitter_registry.py b/cg/services/orders/submitters/order_submitter_registry.py deleted file mode 100644 index d0996c3311..0000000000 --- a/cg/services/orders/submitters/order_submitter_registry.py +++ /dev/null @@ -1,166 +0,0 @@ -from cg.apps.lims import LimsAPI -from cg.models.orders.constants import OrderType -from cg.services.order_validation_service.order_validation_service import OrderValidationService -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 -from cg.services.orders.store_order_services.store_metagenome_order import ( - StoreMetagenomeOrderService, -) -from cg.services.orders.store_order_services.store_microbial_fastq_order_service import ( - StoreMicrobialFastqOrderService, -) -from cg.services.orders.store_order_services.store_microbial_order import StoreMicrobialOrderService -from cg.services.orders.store_order_services.store_pacbio_order_service import ( - StorePacBioOrderService, -) -from cg.services.orders.store_order_services.store_pool_order import StorePoolOrderService -from cg.services.orders.submitters.case_order_submitter import CaseOrderSubmitter -from cg.services.orders.submitters.fastq_order_submitter import FastqOrderSubmitter -from cg.services.orders.submitters.metagenome_order_submitter import MetagenomeOrderSubmitter -from cg.services.orders.submitters.microbial_order_submitter import MicrobialOrderSubmitter -from cg.services.orders.submitters.order_submitter import OrderSubmitter -from cg.services.orders.submitters.pacbio_order_submitter import PacbioOrderSubmitter -from cg.services.orders.submitters.pool_order_submitter import PoolOrderSubmitter -from cg.store.store import Store - - -class OrderSubmitterRegistry: - """ - A registry for OrderSubmitter instances, keyed by OrderType. - """ - - def __init__(self): - self._registry = {} - - def register(self, order_type: OrderType, order_submitter: OrderSubmitter): - """Register an OrderSubmitter instance for a given OrderType.""" - self._registry[order_type] = order_submitter - - def get_order_submitter(self, order_type: OrderType) -> OrderSubmitter: - """Fetch the registered OrderSubmitter for the given OrderType.""" - if order_submitter := self._registry.get(order_type): - return order_submitter - raise ValueError(f"No OrderSubmitter registered for order type: {order_type}") - - -order_service_mapping = { - OrderType.BALSAMIC: ( - OrderLimsService, - OrderValidationService, - StoreCaseOrderService, - CaseOrderSubmitter, - ), - OrderType.BALSAMIC_QC: ( - OrderLimsService, - OrderValidationService, - StoreCaseOrderService, - CaseOrderSubmitter, - ), - OrderType.BALSAMIC_UMI: ( - OrderLimsService, - OrderValidationService, - StoreCaseOrderService, - CaseOrderSubmitter, - ), - OrderType.FASTQ: ( - OrderLimsService, - OrderValidationService, - StoreFastqOrderService, - FastqOrderSubmitter, - ), - OrderType.FLUFFY: ( - OrderLimsService, - OrderValidationService, - StorePoolOrderService, - PoolOrderSubmitter, - ), - OrderType.METAGENOME: ( - OrderLimsService, - OrderValidationService, - StoreMetagenomeOrderService, - MetagenomeOrderSubmitter, - ), - OrderType.MICROBIAL_FASTQ: ( - OrderLimsService, - OrderValidationService, - StoreMicrobialFastqOrderService, - MicrobialOrderSubmitter, - ), - OrderType.MICROSALT: ( - OrderLimsService, - OrderValidationService, - StoreMicrobialOrderService, - MicrobialOrderSubmitter, - ), - OrderType.MIP_DNA: ( - OrderLimsService, - OrderValidationService, - StoreCaseOrderService, - CaseOrderSubmitter, - ), - OrderType.MIP_RNA: ( - OrderLimsService, - OrderValidationService, - StoreCaseOrderService, - CaseOrderSubmitter, - ), - OrderType.PACBIO_LONG_READ: ( - OrderLimsService, - OrderValidationService, - StorePacBioOrderService, - PacbioOrderSubmitter, - ), - OrderType.RML: ( - OrderLimsService, - OrderValidationService, - StorePoolOrderService, - PoolOrderSubmitter, - ), - OrderType.RNAFUSION: ( - OrderLimsService, - OrderValidationService, - StoreCaseOrderService, - CaseOrderSubmitter, - ), - OrderType.SARS_COV_2: ( - OrderLimsService, - OrderValidationService, - StoreMicrobialOrderService, - MicrobialOrderSubmitter, - ), - OrderType.TAXPROFILER: ( - OrderLimsService, - OrderValidationService, - StoreMetagenomeOrderService, - MetagenomeOrderSubmitter, - ), - OrderType.TOMTE: ( - OrderLimsService, - OrderValidationService, - StoreCaseOrderService, - CaseOrderSubmitter, - ), -} - - -def build_submitter(lims: LimsAPI, status_db: Store, order_type: OrderType) -> OrderSubmitter: - """Build an OrderSubmitter instance for the given OrderType.""" - lims_service, validation_service, store_service, submitter_class = order_service_mapping[ - order_type - ] - return submitter_class( - order_validation_service=validation_service(status_db), - order_store_service=store_service(status_db, lims_service(lims)), - ) - - -def setup_order_submitter_registry(lims: LimsAPI, status_db: Store) -> OrderSubmitterRegistry: - """Set up the OrderSubmitterRegistry with all OrderSubmitter instances.""" - registry = OrderSubmitterRegistry() - for order_type in order_service_mapping.keys(): - registry.register( - order_type=order_type, - order_submitter=build_submitter(lims=lims, status_db=status_db, order_type=order_type), - ) - return registry diff --git a/cg/services/orders/submitters/pacbio_order_submitter.py b/cg/services/orders/submitters/pacbio_order_submitter.py deleted file mode 100644 index a3c432c28e..0000000000 --- a/cg/services/orders/submitters/pacbio_order_submitter.py +++ /dev/null @@ -1,25 +0,0 @@ -from cg.services.order_validation_service.workflows.pacbio_long_read.models.order import PacbioOrder -from cg.services.orders.store_order_services.store_pacbio_order_service import ( - StorePacBioOrderService, -) -from cg.services.orders.submitters.order_submitter import OrderSubmitter -from cg.services.orders.validate_order_services.validate_pacbio_order import ( - ValidatePacbioOrderService, -) - - -class PacbioOrderSubmitter(OrderSubmitter): - """Submitter for Pacbio orders.""" - - def __init__( - self, - order_validation_service: ValidatePacbioOrderService, - order_store_service: StorePacBioOrderService, - ): - self.order_validation_service = order_validation_service - self.order_store_service = order_store_service - - def submit_order(self, order: PacbioOrder) -> dict: - """Submit a fastq order.""" - result: dict = self.order_store_service.store_order(order=order) - return result diff --git a/cg/services/orders/submitters/pool_order_submitter.py b/cg/services/orders/submitters/pool_order_submitter.py deleted file mode 100644 index b4116d8091..0000000000 --- a/cg/services/orders/submitters/pool_order_submitter.py +++ /dev/null @@ -1,25 +0,0 @@ -from cg.services.order_validation_service.models.sample_aliases import OrderWithIndexedSamples -from cg.services.orders.store_order_services.store_pool_order import StorePoolOrderService -from cg.services.orders.submitters.order_submitter import OrderSubmitter -from cg.services.orders.validate_order_services.validate_pool_order import ValidatePoolOrderService - - -class PoolOrderSubmitter(OrderSubmitter): - """ - Class for submitting pool orders. - This class is used to submit orders for the following workflows: - - Fluffy - - RML (Ready made libraries) - - """ - - def __init__( - self, - order_validation_service: ValidatePoolOrderService, - order_store_service: StorePoolOrderService, - ): - self.order_validation_service = order_validation_service - self.order_store_service = order_store_service - - def submit_order(self, order: OrderWithIndexedSamples) -> dict: - return self.order_store_service.store_order(order) diff --git a/cg/services/orders/validate_order_services/validate_case_order.py b/cg/services/orders/validate_order_services/validate_case_order.py index 01dc68a184..24fe4a5376 100644 --- a/cg/services/orders/validate_order_services/validate_case_order.py +++ b/cg/services/orders/validate_order_services/validate_case_order.py @@ -2,8 +2,8 @@ from cg.models.orders.constants import OrderType from cg.models.orders.order import OrderIn from cg.models.orders.samples import Of1508Sample, OrderInSample -from cg.services.orders.submitters.order_submitter import ValidateOrderService -from cg.store.models import Sample, Customer +from cg.services.orders.store_order_services.store_order_service import ValidateOrderService +from cg.store.models import Customer, Sample from cg.store.store import Store diff --git a/cg/services/orders/validate_order_services/validate_fastq_order.py b/cg/services/orders/validate_order_services/validate_fastq_order.py index cbfe5728a7..0fe66d458a 100644 --- a/cg/services/orders/validate_order_services/validate_fastq_order.py +++ b/cg/services/orders/validate_order_services/validate_fastq_order.py @@ -1,5 +1,5 @@ from cg.models.orders.order import OrderIn -from cg.services.orders.submitters.order_submitter import ValidateOrderService +from cg.services.orders.store_order_services.store_order_service import ValidateOrderService from cg.store.store import Store diff --git a/cg/services/orders/validate_order_services/validate_metagenome_order.py b/cg/services/orders/validate_order_services/validate_metagenome_order.py index 330abc985e..2a171d2fa6 100644 --- a/cg/services/orders/validate_order_services/validate_metagenome_order.py +++ b/cg/services/orders/validate_order_services/validate_metagenome_order.py @@ -1,7 +1,7 @@ from cg.exc import OrderError from cg.models.orders.order import OrderIn from cg.models.orders.samples import MetagenomeSample -from cg.services.orders.submitters.order_submitter import ValidateOrderService +from cg.services.orders.store_order_services.store_order_service import ValidateOrderService from cg.store.models import Customer from cg.store.store import Store diff --git a/cg/services/orders/validate_order_services/validate_microbial_order.py b/cg/services/orders/validate_order_services/validate_microbial_order.py index 1590e6b984..9a6f76b8de 100644 --- a/cg/services/orders/validate_order_services/validate_microbial_order.py +++ b/cg/services/orders/validate_order_services/validate_microbial_order.py @@ -2,7 +2,7 @@ from cg.models.orders.constants import OrderType from cg.models.orders.order import OrderIn from cg.models.orders.samples import MicrobialFastqSample, SarsCov2Sample -from cg.services.orders.submitters.order_submitter import ValidateOrderService +from cg.services.orders.store_order_services.store_order_service import ValidateOrderService from cg.store.models import Customer from cg.store.store import Store diff --git a/cg/services/orders/validate_order_services/validate_pacbio_order.py b/cg/services/orders/validate_order_services/validate_pacbio_order.py index 30af38e669..f9da34fad3 100644 --- a/cg/services/orders/validate_order_services/validate_pacbio_order.py +++ b/cg/services/orders/validate_order_services/validate_pacbio_order.py @@ -1,7 +1,7 @@ from cg.exc import OrderError from cg.models.orders.order import OrderIn from cg.models.orders.samples import PacBioSample -from cg.services.orders.submitters.order_submitter import ValidateOrderService +from cg.services.orders.store_order_services.store_order_service import ValidateOrderService from cg.store.models import ApplicationVersion, Customer from cg.store.store import Store diff --git a/cg/services/orders/validate_order_services/validate_pool_order.py b/cg/services/orders/validate_order_services/validate_pool_order.py index 4206a16e29..58cae8846f 100644 --- a/cg/services/orders/validate_order_services/validate_pool_order.py +++ b/cg/services/orders/validate_order_services/validate_pool_order.py @@ -1,7 +1,7 @@ from cg.exc import OrderError from cg.models.orders.order import OrderIn from cg.models.orders.samples import RmlSample -from cg.services.orders.submitters.order_submitter import ValidateOrderService +from cg.services.orders.store_order_services.store_order_service import ValidateOrderService from cg.store.models import Customer from cg.store.store import Store diff --git a/tests/fixture_plugins/orders_fixtures/store_service_fixtures.py b/tests/fixture_plugins/orders_fixtures/store_service_fixtures.py index ce4f3216de..3257541ba9 100644 --- a/tests/fixture_plugins/orders_fixtures/store_service_fixtures.py +++ b/tests/fixture_plugins/orders_fixtures/store_service_fixtures.py @@ -1,19 +1,27 @@ import pytest 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 -from cg.services.orders.store_order_services.store_metagenome_order import ( +from cg.services.orders.store_order_services.implementations.store_case_order import ( + StoreCaseOrderService, +) +from cg.services.orders.store_order_services.implementations.store_fastq_order_service import ( + StoreFastqOrderService, +) +from cg.services.orders.store_order_services.implementations.store_metagenome_order import ( StoreMetagenomeOrderService, ) -from cg.services.orders.store_order_services.store_microbial_fastq_order_service import ( +from cg.services.orders.store_order_services.implementations.store_microbial_fastq_order_service import ( StoreMicrobialFastqOrderService, ) -from cg.services.orders.store_order_services.store_microbial_order import StoreMicrobialOrderService -from cg.services.orders.store_order_services.store_pacbio_order_service import ( +from cg.services.orders.store_order_services.implementations.store_microbial_order import ( + StoreMicrobialOrderService, +) +from cg.services.orders.store_order_services.implementations.store_pacbio_order_service import ( StorePacBioOrderService, ) -from cg.services.orders.store_order_services.store_pool_order import StorePoolOrderService +from cg.services.orders.store_order_services.implementations.store_pool_order import ( + StorePoolOrderService, +) from cg.store.store import Store from tests.mocks.limsmock import MockLimsAPI from tests.store_helpers import StoreHelpers diff --git a/tests/meta/orders/conftest.py b/tests/meta/orders/conftest.py index 5857e67a8a..d3a088e3a9 100644 --- a/tests/meta/orders/conftest.py +++ b/tests/meta/orders/conftest.py @@ -1,13 +1,12 @@ -from pathlib import Path - import pytest from cg.clients.freshdesk.freshdesk_client import FreshdeskClient from cg.meta.orders import OrdersAPI from cg.meta.orders.ticket_handler import TicketHandler -from cg.services.orders.submitters.order_submitter_registry import ( - OrderSubmitterRegistry, - setup_order_submitter_registry, +from cg.services.order_validation_service.order_validation_service import OrderValidationService +from cg.services.orders.store_order_services.storing_service_registry import ( + StoringServiceRegistry, + setup_storing_service_registry, ) from cg.store.store import Store from tests.mocks.limsmock import MockLimsAPI @@ -18,18 +17,24 @@ def freshdesk_client(): return FreshdeskClient(base_url="https://mock.freshdesk.com", api_key="mock_api_key") +@pytest.fixture +def order_validation_service(base_store: Store) -> OrderValidationService: + return OrderValidationService(base_store) + + @pytest.fixture(scope="function") def orders_api( base_store: Store, ticket_handler: TicketHandler, lims_api: MockLimsAPI, - order_submitter_registry: OrderSubmitterRegistry, + storing_service_registry: StoringServiceRegistry, + order_validation_service: OrderValidationService, ) -> OrdersAPI: return OrdersAPI( lims=lims_api, - status=base_store, ticket_handler=ticket_handler, - submitter_registry=order_submitter_registry, + storing_registry=storing_service_registry, + validation_service=order_validation_service, ) @@ -39,5 +44,5 @@ def ticket_handler(store: Store, freshdesk_client: FreshdeskClient) -> TicketHan @pytest.fixture -def order_submitter_registry(base_store: Store, lims_api: MockLimsAPI) -> OrderSubmitterRegistry: - return setup_order_submitter_registry(lims=lims_api, status_db=base_store) +def storing_service_registry(base_store: Store, lims_api: MockLimsAPI) -> StoringServiceRegistry: + return setup_storing_service_registry(lims=lims_api, status_db=base_store) diff --git a/tests/meta/orders/test_meta_orders_api.py b/tests/meta/orders/test_meta_orders_api.py index 58054bc2af..ddd6e2b44b 100644 --- a/tests/meta/orders/test_meta_orders_api.py +++ b/tests/meta/orders/test_meta_orders_api.py @@ -150,8 +150,8 @@ def test_submit_ticketexception( raw_order = order.model_dump() raw_order["ticket_number"] = "#123456" raw_order["project_type"] = order_type - customer = helpers.ensure_customer(store=orders_api.status) - user = helpers.ensure_user(store=orders_api.status, customer=customer) + customer = helpers.ensure_customer(store=orders_api.validation_service.store) + user = helpers.ensure_user(store=orders_api.validation_service.store, customer=customer) # GIVEN a mock Freshdesk ticket creation that raises TicketCreationError with patch( @@ -421,7 +421,7 @@ def test_validate_sex_inconsistent_sex( ): # GIVEN we have an order with a sample that is already in the database but with different sex order_data = MipDnaOrder.model_validate(mip_dna_order_to_submit) - store = orders_api.status + store = orders_api.validation_service.store customer: Customer = store.get_customer_by_internal_id(customer_internal_id=order_data.customer) # add sample with different sex than in order @@ -438,7 +438,7 @@ def test_validate_sex_inconsistent_sex( store.session.commit() assert sample_obj.sex != sample.sex - validator = ValidateCaseOrderService(status_db=orders_api.status) + validator = ValidateCaseOrderService(status_db=store) # WHEN calling _validate_sex # THEN an OrderError should be raised on non-matching sex @@ -451,7 +451,7 @@ def test_validate_sex_consistent_sex( ): # GIVEN we have an order with a sample that is already in the database and with same gender order_data = MipDnaOrder.model_validate(mip_dna_order_to_submit) - store = orders_api.status + store = orders_api.validation_service.store customer: Customer = store.get_customer_by_internal_id(customer_internal_id=order_data.customer) # add sample with different sex than in order @@ -468,7 +468,7 @@ def test_validate_sex_consistent_sex( store.session.commit() assert sample_obj.sex == sample.sex - validator = ValidateCaseOrderService(status_db=orders_api.status) + validator = ValidateCaseOrderService(status_db=store) # WHEN calling _validate_sex validator._validate_subject_sex(samples=samples, customer_id=order_data.customer) @@ -482,7 +482,7 @@ def test_validate_sex_unknown_existing_sex( # GIVEN we have an order with a sample that is already in the database and with different gender but the existing is # of type "unknown" order_data = MipDnaOrder.model_validate(mip_dna_order_to_submit) - store = orders_api.status + store = orders_api.validation_service.store customer: Customer = store.get_customer_by_internal_id(customer_internal_id=order_data.customer) # add sample with different sex than in order @@ -499,7 +499,7 @@ def test_validate_sex_unknown_existing_sex( store.session.commit() assert sample_obj.sex != sample.sex - validator = ValidateCaseOrderService(status_db=orders_api.status) + validator = ValidateCaseOrderService(store) # WHEN calling _validate_sex validator._validate_subject_sex(samples=samples, customer_id=order_data.customer) @@ -513,7 +513,7 @@ def test_validate_sex_unknown_new_sex( # GIVEN we have an order with a sample that is already in the database and with different gender but the new is of # type "unknown" order_data = MipDnaOrder.model_validate(mip_dna_order_to_submit) - store = orders_api.status + store = orders_api.validation_service.store customer: Customer = store.get_customer_by_internal_id(customer_internal_id=order_data.customer) # add sample with different sex than in order @@ -533,7 +533,7 @@ def test_validate_sex_unknown_new_sex( for sample in samples: assert sample_obj.sex != sample.sex - validator = ValidateCaseOrderService(status_db=orders_api.status) + validator = ValidateCaseOrderService(store) # WHEN calling _validate_sex validator._validate_subject_sex(samples=samples, customer_id=order_data.customer) @@ -574,7 +574,7 @@ def test_submit_unique_sample_name( mock_freshdesk_reply_to_ticket(mock_reply_to_ticket) # GIVEN we have an order with a sample that is not existing in the database order_data = OrderIn.parse_obj(obj=all_orders_to_submit[order_type], project=order_type) - store = orders_api.status + store = orders_api.validation_service.store assert not store._get_query(table=Sample).first() monkeypatch_process_lims(monkeypatch, order_data) diff --git a/tests/services/orders/order_store_service/test_fastq_order_service.py b/tests/services/orders/order_store_service/test_fastq_order_service.py index fd3d61c5ab..9dcb497999 100644 --- a/tests/services/orders/order_store_service/test_fastq_order_service.py +++ b/tests/services/orders/order_store_service/test_fastq_order_service.py @@ -1,7 +1,9 @@ from cg.constants import DataDelivery, Workflow from cg.constants.sequencing import SeqLibraryPrepCategory from cg.services.order_validation_service.workflows.fastq.models.order import FastqOrder -from cg.services.orders.store_order_services.store_fastq_order_service import StoreFastqOrderService +from cg.services.orders.store_order_services.implementations.store_fastq_order_service import ( + StoreFastqOrderService, +) from cg.store.models import Application, Case, Sample from cg.store.store import Store diff --git a/tests/services/orders/order_store_service/test_generic_order_store_service.py b/tests/services/orders/order_store_service/test_generic_order_store_service.py index 6ed9d6ff61..cc9cc5ac78 100644 --- a/tests/services/orders/order_store_service/test_generic_order_store_service.py +++ b/tests/services/orders/order_store_service/test_generic_order_store_service.py @@ -4,7 +4,9 @@ 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.services.order_validation_service.workflows.mip_rna.models.order import MipRnaOrder -from cg.services.orders.store_order_services.store_case_order import StoreCaseOrderService +from cg.services.orders.store_order_services.implementations.store_case_order import ( + StoreCaseOrderService, +) from cg.store.models import Sample from cg.store.store import Store diff --git a/tests/services/orders/order_store_service/test_metagenome_store_service.py b/tests/services/orders/order_store_service/test_metagenome_store_service.py index 02f91f9b80..b388984f1c 100644 --- a/tests/services/orders/order_store_service/test_metagenome_store_service.py +++ b/tests/services/orders/order_store_service/test_metagenome_store_service.py @@ -1,5 +1,5 @@ from cg.services.order_validation_service.workflows.metagenome.models.order import MetagenomeOrder -from cg.services.orders.store_order_services.store_metagenome_order import ( +from cg.services.orders.store_order_services.implementations.store_metagenome_order import ( StoreMetagenomeOrderService, ) from cg.store.models import Sample diff --git a/tests/services/orders/order_store_service/test_microbial_fastq_order_store_service.py b/tests/services/orders/order_store_service/test_microbial_fastq_order_store_service.py index 8017fafe34..96a81e50c6 100644 --- a/tests/services/orders/order_store_service/test_microbial_fastq_order_store_service.py +++ b/tests/services/orders/order_store_service/test_microbial_fastq_order_store_service.py @@ -2,7 +2,7 @@ from cg.services.order_validation_service.workflows.microbial_fastq.models.order import ( MicrobialFastqOrder, ) -from cg.services.orders.store_order_services.store_microbial_fastq_order_service import ( +from cg.services.orders.store_order_services.implementations.store_microbial_fastq_order_service import ( StoreMicrobialFastqOrderService, ) from cg.store.models import Case, Sample diff --git a/tests/services/orders/order_store_service/test_microbial_store_order_service.py b/tests/services/orders/order_store_service/test_microbial_store_order_service.py index 7f9d780188..64bf6d7ba1 100644 --- a/tests/services/orders/order_store_service/test_microbial_store_order_service.py +++ b/tests/services/orders/order_store_service/test_microbial_store_order_service.py @@ -4,7 +4,9 @@ from cg.models.orders.samples import SarsCov2Sample from cg.services.order_validation_service.workflows.microsalt.models.order import MicrosaltOrder from cg.services.order_validation_service.workflows.mutant.models.order import MutantOrder -from cg.services.orders.store_order_services.store_microbial_order import StoreMicrobialOrderService +from cg.services.orders.store_order_services.implementations.store_microbial_order import ( + StoreMicrobialOrderService, +) from cg.store.models import Case, Customer, Sample from cg.store.store import Store diff --git a/tests/services/orders/order_store_service/test_pacbio_order_service.py b/tests/services/orders/order_store_service/test_pacbio_order_service.py index b2c48b5a3d..04304b9d3b 100644 --- a/tests/services/orders/order_store_service/test_pacbio_order_service.py +++ b/tests/services/orders/order_store_service/test_pacbio_order_service.py @@ -2,7 +2,7 @@ from cg.constants.sequencing import SeqLibraryPrepCategory from cg.models.orders.sample_base import SexEnum from cg.services.order_validation_service.workflows.pacbio_long_read.models.order import PacbioOrder -from cg.services.orders.store_order_services.store_pacbio_order_service import ( +from cg.services.orders.store_order_services.implementations.store_pacbio_order_service import ( StorePacBioOrderService, ) from cg.store.models import Case, Order, Sample diff --git a/tests/services/orders/order_store_service/test_pool_order_store_service.py b/tests/services/orders/order_store_service/test_pool_order_store_service.py index 490e3aadf0..0873afa431 100644 --- a/tests/services/orders/order_store_service/test_pool_order_store_service.py +++ b/tests/services/orders/order_store_service/test_pool_order_store_service.py @@ -3,7 +3,9 @@ from cg.constants import Workflow from cg.constants.sequencing import SeqLibraryPrepCategory from cg.services.order_validation_service.models.sample_aliases import OrderWithIndexedSamples -from cg.services.orders.store_order_services.store_pool_order import StorePoolOrderService +from cg.services.orders.store_order_services.implementations.store_pool_order import ( + StorePoolOrderService, +) from cg.store.models import ApplicationVersion, Case, CaseSample, Order, Pool, Sample from cg.store.store import Store from tests.store_helpers import StoreHelpers diff --git a/tests/store/conftest.py b/tests/store/conftest.py index 0c6c679dc1..9a503fd2fc 100644 --- a/tests/store/conftest.py +++ b/tests/store/conftest.py @@ -10,19 +10,12 @@ from cg.constants import Workflow from cg.constants.devices import DeviceType from cg.constants.priority import PriorityTerms -from cg.constants.subject import PhenotypeStatus, Sex +from cg.constants.subject import PhenotypeStatus from cg.services.illumina.data_transfer.models import IlluminaFlowCellDTO -from cg.services.orders.store_order_services.store_pool_order import StorePoolOrderService -from cg.store.models import ( - Analysis, - Application, - Case, - CaseSample, - Customer, - IlluminaFlowCell, - Organism, - Sample, +from cg.services.orders.store_order_services.implementations.store_pool_order import ( + StorePoolOrderService, ) +from cg.store.models import Analysis, Application, Case, CaseSample, IlluminaFlowCell, Sample from cg.store.store import Store from tests.store_helpers import StoreHelpers