.
This commit is contained in:
@@ -172,4 +172,143 @@ class TestShiftConstraints:
|
||||
Rota.build_and_solve(options={"ratio": 0.000})
|
||||
Rota.export_rota_to_html("max_shifts_per_week_block")
|
||||
|
||||
assert Rota.results.solver.status == "warning"
|
||||
|
||||
def test_pre_shift_constraint(self):
|
||||
Rota = generate_basic_rota()
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="a", length= 12.5, days=days[0],
|
||||
constraint=[{"name": "pre", "options": 1}],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="b", length= 12.5, days=days[1],
|
||||
constraint=[{"name": "pre", "options": 1}],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="c", length= 12.5, days=days[2],
|
||||
constraint=[{"name": "pre", "options": 1}],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="d", length= 12.5, days=days[3],
|
||||
constraint=[{"name": "pre", "options": 1}],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="e", length= 12.5, days=days[4],
|
||||
constraint=[{"name": "pre", "options": 1}],
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="f", length= 12.5, days=days[5],
|
||||
constraint=[{"name": "pre", "options": 1}],
|
||||
),
|
||||
)
|
||||
|
||||
Rota.build_and_solve(options={"ratio": 0.000})
|
||||
Rota.export_rota_to_html("pre")
|
||||
|
||||
assert Rota.results.solver.status == "ok"
|
||||
|
||||
for worker in Rota.get_workers():
|
||||
shift_string = Rota.get_worker_shift_list_string(worker)
|
||||
|
||||
print(shift_string)
|
||||
for s in ["ab", "bc", "cd", "de", "ef", "fg"]:
|
||||
assert s not in shift_string
|
||||
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="g", length= 12.5, days=days[6],
|
||||
constraint=[{"name": "pre", "options": 2}],
|
||||
),
|
||||
)
|
||||
|
||||
Rota.build_and_solve(options={"ratio": 0.000})
|
||||
|
||||
assert Rota.results.solver.status == "warning"
|
||||
|
||||
def test_pre_shift_constraint2(self):
|
||||
Rota = generate_basic_rota()
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="a", length= 12.5, days=days[0],
|
||||
constraint=[{"name": "pre", "options": 2}],
|
||||
workers_required=2
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="b", length= 12.5, days=days[4],
|
||||
constraint=[{"name": "pre", "options": 3}],
|
||||
workers_required=2
|
||||
),
|
||||
|
||||
)
|
||||
|
||||
Rota.build_and_solve(options={"ratio": 0.000})
|
||||
Rota.export_rota_to_html("pre")
|
||||
|
||||
assert Rota.results.solver.status == "ok"
|
||||
|
||||
def test_pre_shift_constraint3(self):
|
||||
Rota = generate_basic_rota()
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="a", length= 12.5, days=days[0],
|
||||
constraint=[{"name": "pre", "options": 3}],
|
||||
workers_required=2
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="b", length= 12.5, days=days[4],
|
||||
constraint=[{"name": "pre", "options": 3}],
|
||||
workers_required=2
|
||||
),
|
||||
)
|
||||
|
||||
Rota.build_and_solve(options={"ratio": 0.000})
|
||||
Rota.export_rota_to_html("pre")
|
||||
|
||||
assert Rota.results.solver.status == "warning"
|
||||
|
||||
def test_post_shift_constraint(self):
|
||||
Rota = generate_basic_rota()
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="a", length= 12.5, days=days[0],
|
||||
constraint=[{"name": "post", "options": 3}],
|
||||
workers_required=2
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="b", length= 12.5, days=days[4],
|
||||
constraint=[{"name": "post", "options": 2}],
|
||||
workers_required=2
|
||||
),
|
||||
)
|
||||
|
||||
Rota.build_and_solve(options={"ratio": 0.000})
|
||||
Rota.export_rota_to_html("post")
|
||||
|
||||
assert Rota.results.solver.status == "ok"
|
||||
|
||||
def test_post_shift_constraint2(self):
|
||||
Rota = generate_basic_rota()
|
||||
|
||||
Rota.add_shifts(
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="a", length= 12.5, days=days[0],
|
||||
constraint=[{"name": "post", "options": 3}],
|
||||
workers_required=2
|
||||
),
|
||||
SingleShift(
|
||||
sites=("group1", "group2"), name="b", length= 12.5, days=days[4],
|
||||
constraint=[{"name": "post", "options": 3}],
|
||||
workers_required=2
|
||||
),
|
||||
)
|
||||
|
||||
Rota.build_and_solve(options={"ratio": 0.000})
|
||||
Rota.export_rota_to_html("post")
|
||||
|
||||
assert Rota.results.solver.status == "warning"
|
||||
Reference in New Issue
Block a user