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:
@@ -1,8 +1,9 @@
|
||||
import datetime
|
||||
import pytest
|
||||
from pytest import approx
|
||||
from rota.shifts import RotaBuilder, SingleShift, days
|
||||
from rota.shifts import PostShiftConstraint, RotaBuilder, SingleShift, days
|
||||
from rota.workers import Worker
|
||||
from web.rota.shifts import PreShiftConstraint
|
||||
|
||||
@pytest.fixture
|
||||
def demo_rota_nights():
|
||||
@@ -48,7 +49,10 @@ def demo_rota_nights():
|
||||
length=12.5,
|
||||
days=days[:4],
|
||||
workers_required=1,
|
||||
constraint=[{"name": "pre", "options": 1}, {"name": "post", "options": 2}],
|
||||
constraints=[
|
||||
PreShiftConstraint(days=1),
|
||||
PostShiftConstraint(days=2),
|
||||
],
|
||||
force_as_block=True
|
||||
),
|
||||
SingleShift(
|
||||
@@ -56,7 +60,10 @@ def demo_rota_nights():
|
||||
name="night_weekend",
|
||||
length=12.5,
|
||||
days=days[4:],
|
||||
constraint=[{"name": "pre", "options": 1}, {"name": "post", "options": 2}],
|
||||
constraints=[
|
||||
PreShiftConstraint(days=1),
|
||||
PostShiftConstraint(days=2),
|
||||
],
|
||||
force_as_block=True,
|
||||
),
|
||||
SingleShift(
|
||||
|
||||
Reference in New Issue
Block a user