@@ -538,8 +538,6 @@ mod tests {
538538 use std:: str:: FromStr ;
539539
540540 use crate :: models:: TrainSchedule ;
541- use crate :: models:: fixtures:: create_created_exception_with_change_groups;
542- use crate :: models:: fixtures:: create_modified_exception_with_change_groups;
543541 use crate :: models:: fixtures:: create_timetable;
544542 use crate :: models:: fixtures:: simple_paced_train_changeset;
545543 use crate :: models:: fixtures:: simple_sub_category;
@@ -554,15 +552,14 @@ mod tests {
554552 use pretty_assertions:: assert_eq;
555553 use rstest:: rstest;
556554 use schemas:: TrainScheduleExceptionChangeGroups ;
557- use schemas:: paced_train:: PacedTrainException ;
558555 use schemas:: paced_train:: RollingStockCategoryChangeGroup ;
559556 use schemas:: paced_train:: StartTimeChangeGroup ;
560557 use schemas:: train_schedule:: Comfort ;
561558 use schemas:: train_schedule:: Distribution ;
562559 use schemas:: train_schedule:: Margins ;
563560 use schemas:: train_schedule:: TrainScheduleOptions ;
564561
565- pub fn create_paced_train ( exceptions : Vec < PacedTrainException > ) -> TrainSchedule {
562+ pub fn create_paced_train ( ) -> TrainSchedule {
566563 TrainSchedule {
567564 id : 1 ,
568565 train_schedule_set_id : 1 ,
@@ -588,23 +585,26 @@ mod tests {
588585 time_window : chrono:: Duration :: try_hours ( 2 ) ,
589586 interval : chrono:: Duration :: try_minutes ( 30 ) ,
590587 sub_category : None ,
591- exceptions,
588+ exceptions : vec ! [ ] ,
592589 }
593590 }
594591
595592 #[ tokio:: test]
596593 async fn paced_train_main_category_apply_exception ( ) {
597- let mut exception = create_created_exception_with_change_groups ( "key_1" ) ;
598-
599- exception. change_groups . rolling_stock_category = Some ( RollingStockCategoryChangeGroup {
600- value : Some ( schemas:: rolling_stock:: TrainCategory :: Main {
601- main_category : schemas:: rolling_stock:: TrainMainCategory :: FastFreightTrain ,
594+ let mut exception = TrainScheduleException :: fixture_created ( "key_1" , None ) ;
595+ exception. change_groups = TrainScheduleExceptionChangeGroups {
596+ rolling_stock_category : Some ( RollingStockCategoryChangeGroup {
597+ value : Some ( schemas:: rolling_stock:: TrainCategory :: Main {
598+ main_category : schemas:: rolling_stock:: TrainMainCategory :: FastFreightTrain ,
599+ } ) ,
602600 } ) ,
603- } ) ;
601+ ..Default :: default ( )
602+ } ;
604603
605604 // The paced train has HighSpeedTrain
606- let paced_train = create_paced_train ( vec ! [ exception. clone( ) ] ) ;
607- let paced_train_exception = paced_train. apply_exception ( & exception) ;
605+ let paced_train = create_paced_train ( ) ;
606+
607+ let paced_train_exception = paced_train. apply_train_schedule_exception ( & exception. into ( ) ) ;
608608
609609 // Check if it get replaced by exception category
610610 assert_eq ! (
@@ -617,12 +617,13 @@ mod tests {
617617
618618 #[ rstest]
619619 #[ tokio:: test]
620- #[ case:: created( create_created_exception_with_change_groups ( "key_1" ) ) ]
620+ #[ case:: created( TrainScheduleException :: fixture_created ( "key_1" , None ) ) ]
621621 #[ tokio:: test]
622- #[ case:: modified( create_modified_exception_with_change_groups( "key_2" , 0 ) ) ]
623- async fn paced_train_apply_exception ( #[ case] exception : PacedTrainException ) {
624- let paced_train = create_paced_train ( vec ! [ exception. clone( ) ] ) ;
625- let paced_train_exception = paced_train. apply_exception ( & exception) ;
622+ #[ case:: modified( TrainScheduleException :: fixture_created( "key_2" , Some ( 0 ) ) ) ]
623+ async fn paced_train_apply_exception ( #[ case] exception : TrainScheduleException ) {
624+ let exception: schemas:: TrainScheduleException = exception. into ( ) ;
625+ let paced_train = create_paced_train ( ) ;
626+ let paced_train_exception = paced_train. apply_train_schedule_exception ( & exception) ;
626627
627628 assert_eq ! (
628629 paced_train_exception. train_name,
@@ -707,16 +708,13 @@ mod tests {
707708
708709 #[ tokio:: test]
709710 async fn num_base_occurrences_without_exceptions ( ) {
710- let paced_train = create_paced_train ( vec ! [ ] ) ;
711+ let paced_train = create_paced_train ( ) ;
711712 assert_eq ! ( paced_train. num_base_occurrences( ) , 4 ) ;
712713 }
713714
714715 #[ tokio:: test]
715716 async fn num_base_occurrences_with_exceptions ( ) {
716- let paced_train = create_paced_train ( vec ! [
717- create_created_exception_with_change_groups( "key_2" ) ,
718- create_modified_exception_with_change_groups( "key_1" , 0 ) ,
719- ] ) ;
717+ let paced_train = create_paced_train ( ) ;
720718 assert_eq ! ( paced_train. num_base_occurrences( ) , 4 ) ;
721719 }
722720
@@ -729,7 +727,7 @@ mod tests {
729727 key : Some ( "key_1" . into ( ) ) ,
730728 occurrence_index : Some ( 1 ) ,
731729 disabled : false ,
732- change_groups : TrainScheduleExceptionChangeGroups :: fake_modified ( ) ,
730+ change_groups : TrainScheduleExceptionChangeGroups :: fixture_modified ( ) ,
733731 }
734732 . into ( ) ;
735733
@@ -740,7 +738,7 @@ mod tests {
740738 key : Some ( "key_2" . into ( ) ) ,
741739 occurrence_index : None ,
742740 disabled : false ,
743- change_groups : TrainScheduleExceptionChangeGroups :: fake_created ( ) ,
741+ change_groups : TrainScheduleExceptionChangeGroups :: fixture_created ( ) ,
744742 }
745743 . into ( ) ;
746744 let exception_3: schemas:: TrainScheduleException = TrainScheduleException {
@@ -750,11 +748,11 @@ mod tests {
750748 key : Some ( "key_3" . into ( ) ) ,
751749 occurrence_index : Some ( 0 ) ,
752750 disabled : true ,
753- change_groups : TrainScheduleExceptionChangeGroups :: fake_modified ( ) ,
751+ change_groups : TrainScheduleExceptionChangeGroups :: fixture_modified ( ) ,
754752 }
755753 . into ( ) ;
756754
757- let paced_train = create_paced_train ( vec ! [ ] ) ;
755+ let paced_train = create_paced_train ( ) ;
758756 let exceptions: Vec < schemas:: TrainScheduleException > = vec ! [
759757 exception_1. clone( ) ,
760758 exception_2. clone( ) ,
@@ -806,7 +804,7 @@ mod tests {
806804
807805 #[ tokio:: test]
808806 async fn iter_occurrences_with_modified_start_time_exception ( ) {
809- let mut exception_1 = create_modified_exception_with_change_groups ( "key_1" , 1 ) ;
807+ let mut exception_1 = TrainScheduleException :: fixture_modified ( "key_1" , 1 ) ;
810808 exception_1. change_groups . start_time = Some ( StartTimeChangeGroup {
811809 value : DateTime :: < Utc > :: from_str ( "2025-05-15T14:31:00+02:00" ) . unwrap ( ) ,
812810 } ) ;
@@ -821,7 +819,7 @@ mod tests {
821819 }
822820 . into ( ) ;
823821
824- let paced_train = create_paced_train ( vec ! [ ] ) ;
822+ let paced_train = create_paced_train ( ) ;
825823 let occurrences: Vec < _ > = paced_train
826824 . iter_occurrences_v2 ( std:: slice:: from_ref ( & exception_1) )
827825 . collect ( ) ;
0 commit comments