@@ -61,11 +61,7 @@ pub enum RollingStockError {
61
61
pub fn routes ( ) -> impl HttpServiceFactory {
62
62
scope ( "/rolling_stock" )
63
63
. service ( ( get_power_restrictions, get, create, update, delete) )
64
- . service ( scope ( "/{rolling_stock_id}" ) . service ( (
65
- create_livery,
66
- update_locked,
67
- check_rolling_stock_usage,
68
- ) ) )
64
+ . service ( scope ( "/{rolling_stock_id}" ) . service ( ( create_livery, update_locked) ) )
69
65
}
70
66
71
67
#[ get( "/{rolling_stock_id}" ) ]
@@ -306,22 +302,6 @@ pub struct TrainScheduleScenarioStudyProject {
306
302
pub scenario_name : String ,
307
303
}
308
304
309
- #[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
310
- struct UsageResponse {
311
- usage : Vec < TrainScheduleScenarioStudyProject > ,
312
- }
313
-
314
- #[ get( "/check_usage" ) ]
315
- async fn check_rolling_stock_usage (
316
- db_pool : Data < DbPool > ,
317
- rolling_stock_id : Path < i64 > ,
318
- ) -> Result < Json < UsageResponse > > {
319
- let rolling_stock_id = rolling_stock_id. into_inner ( ) ;
320
- get_rolling_stock_usage ( db_pool, rolling_stock_id)
321
- . await
322
- . map ( |trains| Json ( UsageResponse { usage : trains } ) )
323
- }
324
-
325
305
async fn get_rolling_stock_usage (
326
306
db_pool : Data < DbPool > ,
327
307
rolling_stock_id : i64 ,
@@ -482,10 +462,7 @@ pub mod tests {
482
462
use std:: vec;
483
463
484
464
use super :: RollingStockError ;
485
- use super :: {
486
- retrieve_existing_rolling_stock, RollingStock , TrainScheduleScenarioStudyProject ,
487
- UsageResponse ,
488
- } ;
465
+ use super :: { retrieve_existing_rolling_stock, RollingStock , TrainScheduleScenarioStudyProject } ;
489
466
use crate :: fixtures:: tests:: {
490
467
db_pool, get_fast_rolling_stock, get_other_rolling_stock, named_fast_rolling_stock,
491
468
named_other_rolling_stock, train_schedule_with_scenario,
@@ -853,103 +830,6 @@ pub mod tests {
853
830
call_service ( & app, rolling_stock_delete_request ( rolling_stock_id) ) . await ;
854
831
}
855
832
856
- #[ rstest]
857
- async fn check_usage_rolling_stock_not_found ( ) {
858
- let app = create_test_service ( ) . await ;
859
- let rolling_stock_id = 314159 ;
860
- let response = call_service (
861
- & app,
862
- TestRequest :: get ( )
863
- . uri ( format ! ( "/rolling_stock/{}/check_usage" , rolling_stock_id) . as_str ( ) )
864
- . to_request ( ) ,
865
- )
866
- . await ;
867
- assert_eq ! ( response. status( ) , StatusCode :: NOT_FOUND ) ;
868
- assert_editoast_error_type ! ( response, RollingStockError :: NotFound { rolling_stock_id } ) ;
869
- }
870
-
871
- #[ rstest]
872
- async fn check_usage_no_train_schedule_for_this_rolling_stock ( db_pool : Data < DbPool > ) {
873
- // GIVEN
874
- let rolling_stock = named_fast_rolling_stock (
875
- "fast_rolling_stock_check_usage_no_train_schedule_for_this_rolling_stock" ,
876
- db_pool,
877
- )
878
- . await ;
879
- let app = create_test_service ( ) . await ;
880
- let rolling_stock_id = rolling_stock. id ( ) ;
881
-
882
- // WHEN
883
- let response = call_service (
884
- & app,
885
- TestRequest :: get ( )
886
- . uri ( format ! ( "/rolling_stock/{}/check_usage" , rolling_stock_id) . as_str ( ) )
887
- . to_request ( ) ,
888
- )
889
- . await ;
890
-
891
- // THEN
892
- let response_body: UsageResponse = assert_status_and_read ! ( response, StatusCode :: OK ) ;
893
- let expected_body = UsageResponse { usage : Vec :: new ( ) } ;
894
- assert_eq ! ( response_body, expected_body) ;
895
- }
896
-
897
- /// Tests`/rolling_stock/{rolling_stock_id}/check_usage` endpoint.
898
- /// Initial conditions: one `TrainSchedule` using the given `rolling_stock_id`.
899
- /// It should return the `TrainSchedule`, `project`/`study`/`scenario` ids/names
900
- #[ rstest]
901
- async fn check_usage_one_train_schedule ( ) {
902
- // GIVEN
903
- let app = create_test_service ( ) . await ;
904
- let train_schedule_with_scenario =
905
- train_schedule_with_scenario ( "test_single_simulation_bare_minimum_payload" ) . await ;
906
- let rolling_stock_id = train_schedule_with_scenario. rolling_stock . id ( ) ;
907
-
908
- // WHEN
909
- let response = call_service (
910
- & app,
911
- TestRequest :: get ( )
912
- . uri ( format ! ( "/rolling_stock/{}/check_usage" , rolling_stock_id) . as_str ( ) )
913
- . to_request ( ) ,
914
- )
915
- . await ;
916
-
917
- // THEN
918
- let response_body: UsageResponse = assert_status_and_read ! ( response, StatusCode :: OK ) ;
919
- let expected_body = UsageResponse {
920
- usage : vec ! [ TrainScheduleScenarioStudyProject {
921
- train_schedule_id: train_schedule_with_scenario. train_schedule. id( ) ,
922
- train_name: train_schedule_with_scenario
923
- . train_schedule
924
- . model
925
- . train_name
926
- . clone( ) ,
927
- scenario_id: train_schedule_with_scenario. scenario. id( ) ,
928
- scenario_name: train_schedule_with_scenario
929
- . scenario
930
- . model
931
- . name
932
- . clone( )
933
- . unwrap( ) ,
934
- study_id: train_schedule_with_scenario. study. id( ) ,
935
- study_name: train_schedule_with_scenario
936
- . study
937
- . model
938
- . name
939
- . clone( )
940
- . unwrap( ) ,
941
- project_id: train_schedule_with_scenario. project. id( ) ,
942
- project_name: train_schedule_with_scenario
943
- . project
944
- . model
945
- . name
946
- . clone( )
947
- . unwrap( ) ,
948
- } ] ,
949
- } ;
950
- assert_eq ! ( response_body, expected_body) ;
951
- }
952
-
953
833
#[ rstest]
954
834
async fn delete_used_rolling_stock_should_fail ( ) {
955
835
// GIVEN
0 commit comments