Skip to content

Commit

Permalink
Fix in SlotModificationService: ParameterSet.target_weekdays must be …
Browse files Browse the repository at this point in the history
…a frozenset so that ParameterSet can be used as key in build_changes().
  • Loading branch information
Theophile-Madet committed Jun 25, 2024
1 parent 75be98e commit d7f84e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tapir/shifts/services/slot_modification_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SlotModificationService:

@dataclass(frozen=True)
class ParameterSet:
target_weekdays: list[int]
target_weekdays: frozenset[int]
time: datetime.time
origin_slot_name: str
target_slot_name: str | None # if None, the slot will be deleted
Expand Down
26 changes: 13 additions & 13 deletions tapir/shifts/tests/test_SlotModificationService.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_pickShiftTemplate_default_includesShiftsWithTheCorrectTime(self):
)
parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name=None,
target_capabilities=None,
Expand All @@ -47,7 +47,7 @@ def test_pickShiftTemplate_hasExcludedShiftId_doesNotIncludeExcludedShift(
)
parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name=None,
target_capabilities=None,
Expand All @@ -70,7 +70,7 @@ def test_pickShiftTemplate_default_doesNotIncludeShiftsOutsideOfTargetWorkdays(
)
parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name=None,
target_capabilities=None,
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_pickSlotTemplateFromShift_default_returnsSlotWithCorrectName(self):

parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="yes",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name=None,
target_capabilities=None,
Expand All @@ -123,7 +123,7 @@ def test_pickSlotTemplateFromShift_lookForSlotThatDoesntExist_raisesError(self):

parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="does_not_exist",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name=None,
target_capabilities=None,
Expand Down Expand Up @@ -152,7 +152,7 @@ def test_pickSlotTemplateFromShift_onlyOneSlotWithName_returnsTheSlotEvenIfItIsO

parameter_set = SlotModificationService.ParameterSet(
origin_slot_name=slot_template.name,
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name=None,
target_capabilities=None,
Expand Down Expand Up @@ -192,7 +192,7 @@ def test_pickSlotTemplateFromShift_someSlotsOccupied_returnsANotOccupiedSlot(

parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="yes",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name=None,
target_capabilities=None,
Expand Down Expand Up @@ -225,7 +225,7 @@ def test_pickSlotTemplateFromShift_allSlotsOccupied_returnsAnOccupiedSlot(

parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="yes",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name=None,
target_capabilities=None,
Expand All @@ -249,7 +249,7 @@ def test_applyChange_targetNameIsNone_slotTemplateAndGeneratedSlotsGetDeleted(se

parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name=None,
target_capabilities=None,
Expand All @@ -268,7 +268,7 @@ def test_applyChange_targetNameIsSet_slotTemplateAndGeneratedSlotsGetRenamed(sel

parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name="new_name",
target_capabilities=None,
Expand All @@ -292,7 +292,7 @@ def test_applyChange_targetCapabilitiesIsNone_capabilitiesNotAffected(self):

parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name="new_name",
target_capabilities=None,
Expand All @@ -318,7 +318,7 @@ def test_applyChange_targetCapabilitiesIsEmpty_capabilitiesNotRequiredAnymore(se

parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name="new_name",
target_capabilities=frozenset([]),
Expand Down Expand Up @@ -346,7 +346,7 @@ def test_applyChange_targetCapabilitiesIsNotEmpty_capabilitiesUpdated(self):
]
parameter_set = SlotModificationService.ParameterSet(
origin_slot_name="",
target_weekdays=[0],
target_weekdays=frozenset([0]),
time=targeted_time,
target_slot_name="new_name",
target_capabilities=frozenset(capabilities_after),
Expand Down

0 comments on commit d7f84e8

Please sign in to comment.