diff --git a/cg/apps/tb/dto/summary_response.py b/cg/apps/tb/dto/summary_response.py index f2bb4a202e..1c2cc80781 100644 --- a/cg/apps/tb/dto/summary_response.py +++ b/cg/apps/tb/dto/summary_response.py @@ -3,10 +3,11 @@ class AnalysisSummary(BaseModel): order_id: int - delivered: int | None = None - running: int | None = None - cancelled: int | None = None - failed: int | None = None + cancelled: int + completed: int + delivered: int + failed: int + running: int class SummariesResponse(BaseModel): diff --git a/cg/services/orders/order_status_service/dto/order_summary.py b/cg/services/orders/order_status_service/dto/order_summary.py index b944d41839..6eb6ae996e 100644 --- a/cg/services/orders/order_status_service/dto/order_summary.py +++ b/cg/services/orders/order_status_service/dto/order_summary.py @@ -4,10 +4,11 @@ class OrderSummary(BaseModel): order_id: int = Field(exclude=True) total: int - delivered: int | None = None - running: int | None = None - cancelled: int | None = None - failed: int | None = None - in_sequencing: int | None = None - in_lab_preparation: int | None = None - not_received: int | None = None + cancelled: int + completed: int + delivered: int + failed: int + in_lab_preparation: int + in_sequencing: int + not_received: int + running: int diff --git a/cg/services/orders/order_status_service/utils.py b/cg/services/orders/order_status_service/utils.py index 1117ccfb36..663297e6f8 100644 --- a/cg/services/orders/order_status_service/utils.py +++ b/cg/services/orders/order_status_service/utils.py @@ -36,6 +36,7 @@ def create_order_summary( delivered=analysis_summary.delivered, cancelled=analysis_summary.cancelled, failed=analysis_summary.failed, + completed=analysis_summary.completed, ) diff --git a/tests/server/conftest.py b/tests/server/conftest.py index af35833fda..8d251a6c3e 100644 --- a/tests/server/conftest.py +++ b/tests/server/conftest.py @@ -156,7 +156,9 @@ def client(app: Flask) -> Generator[FlaskClient, None, None]: def analysis_summary(): return AnalysisSummary( order_id=1, - total=2, + cancelled=0, + completed=1, + running=0, delivered=1, failed=1, ) diff --git a/tests/server/endpoints/test_orders_endpoint.py b/tests/server/endpoints/test_orders_endpoint.py index 6fa546f2ba..6153872418 100644 --- a/tests/server/endpoints/test_orders_endpoint.py +++ b/tests/server/endpoints/test_orders_endpoint.py @@ -1,8 +1,8 @@ from http import HTTPStatus import mock.mock -from flask.testing import FlaskClient import pytest +from flask.testing import FlaskClient from cg.apps.tb import TrailblazerAPI from cg.apps.tb.dto.summary_response import AnalysisSummary @@ -29,7 +29,6 @@ def test_orders_endpoint( limit: int | None, workflow: str, expected_orders: int, - analysis_summary, ): """Tests that orders are returned from the orders endpoint""" # GIVEN a store with three orders, two of which are MIP-DNA and the last is BALSAMIC @@ -40,9 +39,25 @@ def test_orders_endpoint( TrailblazerAPI, "get_summaries", return_value=[ - AnalysisSummary(order_id=order.id), - AnalysisSummary(order_id=order_another.id), - AnalysisSummary(order_id=order_balsamic.id), + AnalysisSummary( + order_id=order.id, cancelled=0, completed=1, delivered=0, failed=0, running=0 + ), + AnalysisSummary( + order_id=order_another.id, + cancelled=0, + completed=1, + delivered=0, + failed=0, + running=0, + ), + AnalysisSummary( + order_id=order_balsamic.id, + cancelled=0, + completed=1, + delivered=0, + failed=0, + running=0, + ), ], ): response = client.get(endpoint, query_string={"pageSize": limit, "workflow": workflow}) diff --git a/tests/services/orders/order_status_service/conftest.py b/tests/services/orders/order_status_service/conftest.py index cc2e725ef9..e6d411a639 100644 --- a/tests/services/orders/order_status_service/conftest.py +++ b/tests/services/orders/order_status_service/conftest.py @@ -1,9 +1,12 @@ from datetime import datetime -from mock import Mock + import pytest -from cg.apps.tb.dto.summary_response import AnalysisSummary +from mock import Mock -from cg.services.orders.order_status_service.order_summary_service import OrderSummaryService +from cg.apps.tb.dto.summary_response import AnalysisSummary +from cg.services.orders.order_status_service.order_summary_service import ( + OrderSummaryService, +) from cg.store.models import Case, Customer, Order, Sample from cg.store.store import Store from tests.store_helpers import StoreHelpers @@ -12,7 +15,11 @@ @pytest.fixture def summary_service(store: Store, order: Order): service = OrderSummaryService(analysis_client=Mock(), store=store) - service.analysis_client.get_summaries.return_value = [AnalysisSummary(order_id=order.id)] + service.analysis_client.get_summaries.return_value = [ + AnalysisSummary( + order_id=order.id, cancelled=0, completed=1, delivered=0, failed=0, running=0 + ) + ] return service