From 98c105b362f5116e4f5674a8d69162031dbaa6bf Mon Sep 17 00:00:00 2001 From: SarahBellaha Date: Tue, 17 Dec 2024 18:00:20 +0100 Subject: [PATCH] fixup! editoast: change stdcm environment date type --- .../src/models/stdcm_search_environment.rs | 75 +++---------------- 1 file changed, 12 insertions(+), 63 deletions(-) diff --git a/editoast/src/models/stdcm_search_environment.rs b/editoast/src/models/stdcm_search_environment.rs index e44c0724773..1729d1e73ce 100644 --- a/editoast/src/models/stdcm_search_environment.rs +++ b/editoast/src/models/stdcm_search_environment.rs @@ -66,7 +66,8 @@ impl StdcmSearchEnvironmentChangeset { #[cfg(test)] pub mod tests { - use chrono::NaiveDate; + use chrono::TimeZone; + use chrono::Utc; use pretty_assertions::assert_eq; use rstest::rstest; @@ -128,31 +129,11 @@ pub mod tests { .work_schedule_group_id(Some(work_schedule_group.id)) .temporary_speed_limit_group_id(Some(temporary_speed_limit_group.id)) .timetable_id(timetable.id) - .search_window_begin( - NaiveDate::from_ymd_opt(2024, 1, 1) - .unwrap() - .and_hms_opt(0, 0, 0) - .unwrap() - .and_utc(), - ) - .search_window_end( - NaiveDate::from_ymd_opt(2024, 1, 15) - .unwrap() - .and_hms_opt(0, 0, 0) - .unwrap() - .and_utc(), - ); + .search_window_begin(Utc.with_ymd_and_hms(2024, 1, 1, 0, 0, 0).unwrap()) + .search_window_end(Utc.with_ymd_and_hms(2024, 1, 15, 0, 0, 0).unwrap()); - let begin = NaiveDate::from_ymd_opt(2024, 1, 16) - .unwrap() - .and_hms_opt(0, 0, 0) - .unwrap() - .and_utc(); - let end = NaiveDate::from_ymd_opt(2024, 1, 31) - .unwrap() - .and_hms_opt(0, 0, 0) - .unwrap() - .and_utc(); + let begin = Utc.with_ymd_and_hms(2024, 1, 16, 0, 0, 0).unwrap(); + let end = Utc.with_ymd_and_hms(2024, 1, 13, 0, 0, 0).unwrap(); let changeset_2 = changeset_1 .clone() @@ -211,48 +192,16 @@ pub mod tests { .work_schedule_group_id(Some(work_schedule_group.id)) .temporary_speed_limit_group_id(Some(temporary_speed_limit_group.id)) .timetable_id(timetable.id) - .search_window_begin( - NaiveDate::from_ymd_opt(2024, 1, 1) - .unwrap() - .and_hms_opt(0, 0, 0) - .unwrap() - .and_utc(), - ) - .search_window_end( - NaiveDate::from_ymd_opt(2024, 1, 15) - .unwrap() - .and_hms_opt(0, 0, 0) - .unwrap() - .and_utc(), - ); + .search_window_begin(Utc.with_ymd_and_hms(2024, 1, 1, 0, 0, 0).unwrap()) + .search_window_end(Utc.with_ymd_and_hms(2024, 1, 15, 0, 0, 0).unwrap()); let too_young = too_old .clone() - .search_window_begin( - NaiveDate::from_ymd_opt(2024, 1, 16) - .unwrap() - .and_hms_opt(0, 0, 0) - .unwrap() - .and_utc(), - ) - .search_window_end( - NaiveDate::from_ymd_opt(2024, 1, 31) - .unwrap() - .and_hms_opt(0, 0, 0) - .unwrap() - .and_utc(), - ); + .search_window_begin(Utc.with_ymd_and_hms(2024, 1, 16, 0, 0, 0).unwrap()) + .search_window_end(Utc.with_ymd_and_hms(2024, 1, 31, 0, 0, 0).unwrap()); - let begin = NaiveDate::from_ymd_opt(2024, 1, 7) - .unwrap() - .and_hms_opt(0, 0, 0) - .unwrap() - .and_utc(); - let end = NaiveDate::from_ymd_opt(2024, 1, 31) - .unwrap() - .and_hms_opt(0, 0, 0) - .unwrap() - .and_utc(); + let begin = Utc.with_ymd_and_hms(2024, 1, 7, 0, 0, 0).unwrap(); + let end = Utc.with_ymd_and_hms(2024, 1, 31, 0, 0, 0).unwrap(); let the_best = too_old .clone()