Refactor shift constraints in tests to use new constraint classes
- Updated test cases in `test_workers.py` to replace dictionary-based constraints with instances of `PreShiftConstraint`, `PostShiftConstraint`, and `MaxShiftsPerWeekConstraint`. - Added a new test `test_worker_assign_as_block_preference2` to verify worker preferences for block assignments. - Marked tests as slow where appropriate to improve test suite performance.
This commit is contained in:
+7
-5
@@ -3,7 +3,7 @@ import datetime
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from rota.shifts import NoWorkers, RotaBuilder, SingleShift, WorkerRequirement, days
|
||||
from rota.shifts import NoWorkers, PostShiftConstraint, PreShiftConstraint, RotaBuilder, SingleShift, WorkerRequirement, days
|
||||
import typer
|
||||
import subprocess
|
||||
import pandas as pd
|
||||
@@ -335,7 +335,7 @@ def main(
|
||||
days=days,
|
||||
balance_offset=2,
|
||||
assign_as_block=False,
|
||||
constraint=[
|
||||
constraints=[
|
||||
#{
|
||||
# "name": "max_shifts_per_week",
|
||||
# "options": 3,
|
||||
@@ -349,9 +349,11 @@ def main(
|
||||
length=12.5,
|
||||
days=days[5:],
|
||||
balance_offset=1,
|
||||
constraint=[
|
||||
constraints=[
|
||||
#{"name": "pre", "options": 2},
|
||||
{"name": "post", "options": 1},
|
||||
|
||||
#{"name": "post", "options": 1},
|
||||
PostShiftConstraint(days=1, start_date="2025-11-24"),
|
||||
],
|
||||
display_char="a",
|
||||
#force_assign_with=["oncall"]
|
||||
@@ -380,7 +382,7 @@ def main(
|
||||
length=12.5,
|
||||
days=days[:5],
|
||||
balance_offset=1,
|
||||
constraint=[
|
||||
constraints=[
|
||||
#{"name": "pre", "options": 1},
|
||||
#{"name": "post", "options": 1},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user