• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Clinical-Genomics / cg / 12350691447

16 Dec 2024 10:27AM UTC coverage: 80.864%. First build
12350691447

Pull #3976

github

web-flow
Merge f0a779aa9 into e88e10d97
Pull Request #3976: Improve order flow storing main

114 of 185 new or added lines in 42 files covered. (61.62%)

13611 of 16832 relevant lines covered (80.86%)

1.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.27
/cg/meta/orders/api.py
1
"""Unified interface to handle sample submissions.
2

3
This interface will update information in Status and/or LIMS as required.
4

5
The normal entry for information is through the REST API which will pass a JSON
6
document with all information about samples in the submission. The input will
7
be validated and if passing all checks be accepted as new samples.
8
"""
9

10
import logging
1✔
11

12
from cg.apps.lims import LimsAPI
1✔
13
from cg.meta.orders.ticket_handler import TicketHandler
1✔
14
from cg.models.orders.order import OrderType
1✔
15
from cg.services.order_validation_service.models.order import Order
1✔
16
from cg.services.orders.submitters.order_submitter import OrderSubmitter
1✔
17
from cg.services.orders.submitters.order_submitter_registry import OrderSubmitterRegistry
1✔
18
from cg.store.store import Store
1✔
19

20
LOG = logging.getLogger(__name__)
1✔
21

22

23
class OrdersAPI:
1✔
24
    """Orders API for accepting new samples into the system."""
25

26
    def __init__(
1✔
27
        self,
28
        lims: LimsAPI,
29
        status: Store,
30
        ticket_handler: TicketHandler,
31
        submitter_registry: OrderSubmitterRegistry,
32
    ):
33
        super().__init__()
1✔
34
        self.lims = lims
1✔
35
        self.status = status
1✔
36
        self.ticket_handler = ticket_handler
1✔
37
        self.submitter_registry = submitter_registry
1✔
38

39
    def submit(
1✔
40
        self,
41
        order_type: OrderType,
42
        raw_order: dict,
43
    ) -> dict:
44
        """Submit a batch of samples.
45

46
        Main entry point for the class towards interfaces that implements it.
47
        """
NEW
48
        submit_handler: OrderSubmitter = self.submitter_registry.get_order_submitter(order_type)
×
NEW
49
        order: Order = submit_handler.order_validation_service.parse_and_validate(raw_order)
×
NEW
50
        ticket_number: str | None = self.ticket_handler.parse_ticket_number(order.name)
×
NEW
51
        order.ticket_number = ticket_number
×
NEW
52
        return submit_handler.submit_order(order)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc