Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
islean committed Jan 16, 2025
1 parent db91b6b commit 800c7e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cg/services/order_validation_service/errors/case_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ class CaseDoesNotExistError(CaseError):
message: str = "The case does not exist"


class MultipleSamplesError(CaseError):
field: str = "samples"
class MultipleSamplesInCaseError(CaseError):
field: str = "sample_errors"
message: str = "Multiple samples in the same case not allowed"
10 changes: 3 additions & 7 deletions cg/services/order_validation_service/response_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,9 @@ def map_sample_errors(order: dict, errors: list[SampleError]) -> None:


def add_error(entity: dict, field: str, message: str) -> None:
if field == "samples":
entity["sample_errors"]["value"] = True
entity["sample_errors"]["errors"].append(message)
else:
if not entity.get(field):
set_field(entity=entity, field=field, value=None)
entity[field]["errors"].append(message)
if not entity.get(field):
set_field(entity=entity, field=field, value=None)
entity[field]["errors"].append(message)


def get_case(order: dict, index: int) -> dict:
Expand Down
12 changes: 8 additions & 4 deletions cg/services/order_validation_service/rules/case/rules.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from cg.services.order_validation_service.errors.case_errors import (
CaseDoesNotExistError,
CaseNameNotAvailableError,
MultipleSamplesError,
MultipleSamplesInCaseError,
RepeatedCaseNameError,
RepeatedGenePanelsError,
)
Expand Down Expand Up @@ -58,10 +58,14 @@ def validate_case_names_not_repeated(
return get_repeated_case_name_errors(order)


def validate_one_sample_per_case(order: OrderWithCases, **kwargs) -> list[MultipleSamplesError]:
errors: list[MultipleSamplesError] = []
def validate_one_sample_per_case(
order: OrderWithCases, **kwargs
) -> list[MultipleSamplesInCaseError]:
"""Validates that there is only one sample in each case.
Only applicable to RNAFusion."""
errors: list[MultipleSamplesInCaseError] = []
for case_index, case in order.enumerated_new_cases:
if len(case.samples) > 1:
error = MultipleSamplesError(case_index=case_index)
error = MultipleSamplesInCaseError(case_index=case_index)
errors.append(error)
return errors

0 comments on commit 800c7e4

Please sign in to comment.