Skip to content

Commit

Permalink
Rename error
Browse files Browse the repository at this point in the history
  • Loading branch information
seallard committed Jul 29, 2024
1 parent add63a6 commit fa171d8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cg/services/order_validation_service/models/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ class OccupiedWellError(CaseSampleError):
message: str = "Well is already occupied"


class ReusedSampleNameError(CaseSampleError):
class RepeatedSampleNameError(CaseSampleError):
field: str = "name"
message: str = "Sample name already used"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from cg.services.order_validation_service.models.errors import (
OccupiedWellError,
ReusedSampleNameError,
RepeatedSampleNameError,
)
from cg.services.order_validation_service.workflows.tomte.models.order import TomteOrder
from cg.services.order_validation_service.workflows.tomte.validation.inter_field.utils import (
Expand All @@ -17,8 +17,8 @@ def validate_wells_contain_at_most_one_sample(order: TomteOrder) -> list[Occupie
return _get_errors(samples)


def validate_unique_sample_names_in_cases(order: TomteOrder) -> list[ReusedSampleNameError]:
errors: list[ReusedSampleNameError] = []
def validate_unique_sample_names_in_cases(order: TomteOrder) -> list[RepeatedSampleNameError]:
errors: list[RepeatedSampleNameError] = []
for case in order.cases:
case_errors = get_duplicate_sample_name_errors(case)
errors.extend(case_errors)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from cg.models.orders.sample_base import ContainerEnum
from cg.services.order_validation_service.models.errors import (
OccupiedWellError,
ReusedSampleNameError,
RepeatedSampleNameError,
)
from cg.services.order_validation_service.workflows.tomte.models.case import TomteCase
from cg.services.order_validation_service.workflows.tomte.models.order import TomteOrder
Expand Down Expand Up @@ -59,6 +59,6 @@ def get_duplicate_sample_names(case: TomteCase) -> list[str]:
return [name for name, freq in count.items() if freq > 1]


def get_duplicate_sample_name_errors(case: TomteCase) -> list[ReusedSampleNameError]:
def get_duplicate_sample_name_errors(case: TomteCase) -> list[RepeatedSampleNameError]:
sample_names = get_duplicate_sample_names(case)
return [ReusedSampleNameError(sample_name=name, case_name=case.name) for name in sample_names]
return [RepeatedSampleNameError(sample_name=name, case_name=case.name) for name in sample_names]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from cg.services.order_validation_service.models.errors import (
OccupiedWellError,
ReusedSampleNameError,
RepeatedSampleNameError,
)
from cg.services.order_validation_service.workflows.tomte.models.order import TomteOrder
from cg.services.order_validation_service.workflows.tomte.validation.inter_field.rules import (
Expand Down Expand Up @@ -44,4 +44,4 @@ def test_duplicate_sample_names_not_allowed(order_with_duplicate_sample_names: T
assert errors

# THEN the errors are about the sample names
assert isinstance(errors[0], ReusedSampleNameError)
assert isinstance(errors[0], RepeatedSampleNameError)

0 comments on commit fa171d8

Please sign in to comment.