Add option to manually swap shifts after the schedule has been generated
This commit is contained in:
@@ -126,6 +126,36 @@ mod integration_tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_swap_preserves_constraints(
|
||||
#[values(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)] month_idx: u8,
|
||||
mut minimal_config: UserConfig,
|
||||
) -> anyhow::Result<()> {
|
||||
minimal_config.update_month(month_idx);
|
||||
let scheduler = Scheduler::new_with_config(minimal_config.clone());
|
||||
let mut schedule = MonthlySchedule::new();
|
||||
let mut tracker = WorkloadTracker::default();
|
||||
assert!(scheduler.run(&mut schedule, &mut tracker)?);
|
||||
|
||||
let slots: Vec<_> = schedule.0.keys().copied().collect();
|
||||
let mut swapped = false;
|
||||
for slot in slots {
|
||||
let candidates = schedule.possible_swaps(slot, &minimal_config);
|
||||
if let Some(&(swap_target, _)) = candidates.first() {
|
||||
schedule
|
||||
.apply_swap(slot, swap_target, &minimal_config, &mut tracker)
|
||||
.expect("apply_swap failed for a candidate returned by possible_swaps");
|
||||
swapped = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert!(swapped, "No valid swap found in generated schedule");
|
||||
validate_all_constraints(&schedule, &tracker, &minimal_config);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn test_export_pipeline(minimal_config: UserConfig) -> anyhow::Result<()> {
|
||||
let scheduler = Scheduler::new_with_config(minimal_config.clone());
|
||||
|
||||
Reference in New Issue
Block a user