From d7f84e8439694e18f38594d1aedf4fd1e5b45760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Madet?= Date: Tue, 25 Jun 2024 21:06:28 +0200 Subject: [PATCH] Fix in SlotModificationService: ParameterSet.target_weekdays must be a frozenset so that ParameterSet can be used as key in build_changes(). --- .../services/slot_modification_service.py | 2 +- .../tests/test_SlotModificationService.py | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tapir/shifts/services/slot_modification_service.py b/tapir/shifts/services/slot_modification_service.py index d3c94f425..72c4cb2dd 100644 --- a/tapir/shifts/services/slot_modification_service.py +++ b/tapir/shifts/services/slot_modification_service.py @@ -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 diff --git a/tapir/shifts/tests/test_SlotModificationService.py b/tapir/shifts/tests/test_SlotModificationService.py index 08d24addf..4fb528dfe 100644 --- a/tapir/shifts/tests/test_SlotModificationService.py +++ b/tapir/shifts/tests/test_SlotModificationService.py @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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([]), @@ -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),