more updates
This commit is contained in:
@@ -85,7 +85,7 @@ class TestWorkerRequests:
|
||||
force_as_block=False,
|
||||
),
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(InvalidShift):
|
||||
|
||||
Rota.add_grade_constraint_by_week([1], [1,2,3], ["b"])
|
||||
Rota.build_and_solve(options={"ratio": 0.000})
|
||||
|
||||
+106
-24
@@ -4,6 +4,7 @@ from rota.shifts import InvalidShift, NoWorkers, RotaBuilder, SingleShift, days
|
||||
|
||||
from rota.workers import Worker
|
||||
|
||||
|
||||
def generate_basic_rota(weeks_to_rota=10):
|
||||
start_date = datetime.date(2022, 3, 7)
|
||||
|
||||
@@ -38,18 +39,23 @@ class TestNightShifts:
|
||||
def test_nights(self):
|
||||
Rota = generate_basic_rota()
|
||||
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="n", length= 12.5, days=days[5:],
|
||||
sites=("group1", "group2"),
|
||||
name="n",
|
||||
length=12.5,
|
||||
days=days[5:],
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "night"}, {"name": "pre", "options": 2}],
|
||||
workers_required=2,
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="b", length= 12.5, days=days[:3],
|
||||
sites=("group1", "group2"),
|
||||
name="b",
|
||||
length=12.5,
|
||||
days=days[:3],
|
||||
force_as_block=False,
|
||||
#constraint=[{"name": "night"}],
|
||||
# constraint=[{"name": "night"}],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -62,18 +68,23 @@ class TestNightShifts:
|
||||
def test_nights_pre3(self):
|
||||
Rota = generate_basic_rota()
|
||||
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="n", length= 12.5, days=days[5:],
|
||||
sites=("group1", "group2"),
|
||||
name="n",
|
||||
length=12.5,
|
||||
days=days[5:],
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "night"}, {"name": "pre", "options": 3}],
|
||||
workers_required=2,
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="b", length= 12.5, days=days[:2],
|
||||
sites=("group1", "group2"),
|
||||
name="b",
|
||||
length=12.5,
|
||||
days=days[:2],
|
||||
force_as_block=False,
|
||||
#constraint=[{"name": "night"}],
|
||||
# constraint=[{"name": "night"}],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -85,18 +96,23 @@ class TestNightShifts:
|
||||
def test_nights_pre3_2(self):
|
||||
Rota = generate_basic_rota()
|
||||
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="n", length= 12.5, days=days[5:],
|
||||
sites=("group1", "group2"),
|
||||
name="n",
|
||||
length=12.5,
|
||||
days=days[5:],
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "night"}, {"name": "pre", "options": 3}],
|
||||
workers_required=1,
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="b", length= 12.5, days=days[:3],
|
||||
sites=("group1", "group2"),
|
||||
name="b",
|
||||
length=12.5,
|
||||
days=days[:3],
|
||||
force_as_block=False,
|
||||
#constraint=[{"name": "night"}],
|
||||
# constraint=[{"name": "night"}],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -108,18 +124,23 @@ class TestNightShifts:
|
||||
def test_nights_fail(self):
|
||||
Rota = generate_basic_rota()
|
||||
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="n", length= 12.5, days=days[5:],
|
||||
sites=("group1", "group2"),
|
||||
name="n",
|
||||
length=12.5,
|
||||
days=days[5:],
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "night"}, {"name": "pre", "options": 3}],
|
||||
workers_required=2,
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="b", length= 12.5, days=days[:3],
|
||||
sites=("group1", "group2"),
|
||||
name="b",
|
||||
length=12.5,
|
||||
days=days[:3],
|
||||
force_as_block=False,
|
||||
#constraint=[{"name": "night"}],
|
||||
# constraint=[{"name": "night"}],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -132,29 +153,90 @@ class TestNightShifts:
|
||||
|
||||
Rota.constraint_options["max_night_frequency"] = 0
|
||||
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="n", length= 12.5, days=days[5:],
|
||||
sites=("group1", "group2"),
|
||||
name="n",
|
||||
length=12.5,
|
||||
days=days[5:],
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "night"}],
|
||||
workers_required=2,
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="m", length= 12.5, days=days[:5],
|
||||
sites=("group1", "group2"),
|
||||
name="m",
|
||||
length=12.5,
|
||||
days=days[:5],
|
||||
force_as_block=True,
|
||||
#constraint=[{"name": "night"}, {"name": "pre", "options": 3}],
|
||||
#constraint=[{"name": "night"}],
|
||||
# constraint=[{"name": "night"}, {"name": "pre", "options": 3}],
|
||||
# constraint=[{"name": "night"}],
|
||||
workers_required=2,
|
||||
),
|
||||
#SingleShift(
|
||||
# SingleShift(
|
||||
# sites=("group1", "group2"), name="b", length= 12.5, days=days[:3],
|
||||
# force_as_block=False,
|
||||
# #constraint=[{"name": "night"}],
|
||||
#),
|
||||
# ),
|
||||
)
|
||||
|
||||
Rota.build_and_solve(options={"ratio": 0.000})
|
||||
Rota.export_rota_to_html("night")
|
||||
|
||||
assert Rota.results.solver.status == "ok"
|
||||
assert Rota.results.solver.status == "ok"
|
||||
|
||||
def test_nights_pre_wrap_around(self):
|
||||
Rota = generate_basic_rota(weeks_to_rota=8)
|
||||
|
||||
Rota.constraint_options["max_night_frequency"] = 0
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"),
|
||||
name="n",
|
||||
length=12.5,
|
||||
days=days[:2],
|
||||
force_as_block=True,
|
||||
constraint=[{"name": "night"},
|
||||
{"name": "pre", "options": 5},{"name": "post", "options": 5},
|
||||
],
|
||||
workers_required=3,
|
||||
),
|
||||
# SingleShift(
|
||||
# sites=("group1", "group2"), name="m", length= 12.5, days=days[:5],
|
||||
# force_as_block=True,
|
||||
# #constraint=[{"name": "night"}, {"name": "pre", "options": 3}],
|
||||
# #constraint=[{"name": "night"}],
|
||||
# workers_required=2,
|
||||
# ),
|
||||
# SingleShift(
|
||||
# sites=("group1", "group2"), name="b", length= 12.5, days=days[:3],
|
||||
# force_as_block=False,
|
||||
# #constraint=[{"name": "night"}],
|
||||
# ),
|
||||
)
|
||||
|
||||
Rota.add_workers(
|
||||
[
|
||||
Worker(
|
||||
name="worker3",
|
||||
site="group1",
|
||||
grade=1,
|
||||
not_available_to_work=[
|
||||
{
|
||||
"date": Rota.rota_end_date - datetime.timedelta(days=1),
|
||||
"reason": "no wanna",
|
||||
},
|
||||
#{
|
||||
# "date": Rota.rota_end_date - datetime.timedelta(days=5),
|
||||
# "reason": "no wanna",
|
||||
#},
|
||||
],
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
Rota.build_and_solve(options={"ratio": 0.000})
|
||||
Rota.export_rota_to_html("night")
|
||||
|
||||
assert Rota.results.solver.status == "ok"
|
||||
|
||||
Reference in New Issue
Block a user