From 562b6303c4220da4379ac4e5d5ee5435eef53a06 Mon Sep 17 00:00:00 2001 From: patoche Date: Mon, 7 Oct 2019 09:29:18 +0200 Subject: [PATCH] add test --- src/gtfs/read.rs | 84 ++++++++++++++++++- src/ntfs/mod.rs | 2 +- .../levels_and_pathways/input/agency.txt | 2 + .../input/calendar_dates.txt | 6 ++ .../levels_and_pathways/input/levels.txt | 4 + .../levels_and_pathways/input/pathways.txt | 4 + .../levels_and_pathways/input/routes.txt | 5 ++ .../levels_and_pathways/input/stop_times.txt | 12 +++ .../levels_and_pathways/input/stops.txt | 19 +++++ .../levels_and_pathways/input/trips.txt | 6 ++ .../levels_and_pathways/output/calendar.txt | 3 + .../output/commercial_modes.txt | 2 + .../levels_and_pathways/output/companies.txt | 2 + .../output/contributors.txt | 2 + .../levels_and_pathways/output/datasets.txt | 2 + .../levels_and_pathways/output/feed_infos.txt | 6 ++ .../levels_and_pathways/output/levels.txt | 3 + .../levels_and_pathways/output/lines.txt | 3 + .../levels_and_pathways/output/networks.txt | 2 + .../levels_and_pathways/output/pathways.txt | 3 + .../output/physical_modes.txt | 2 + .../levels_and_pathways/output/routes.txt | 3 + .../levels_and_pathways/output/stop_times.txt | 12 +++ .../levels_and_pathways/output/stops.txt | 14 ++++ .../levels_and_pathways/output/trips.txt | 6 ++ tests/gtfs2ntfs.rs | 14 ++++ 26 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/input/agency.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/input/calendar_dates.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/input/levels.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/input/pathways.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/input/routes.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/input/stop_times.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/input/stops.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/input/trips.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/calendar.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/commercial_modes.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/companies.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/contributors.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/datasets.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/feed_infos.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/levels.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/lines.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/networks.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/pathways.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/physical_modes.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/routes.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/stop_times.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/stops.txt create mode 100644 tests/fixtures/gtfs2ntfs/levels_and_pathways/output/trips.txt diff --git a/src/gtfs/read.rs b/src/gtfs/read.rs index 42bbd11ec..ea5e980c6 100644 --- a/src/gtfs/read.rs +++ b/src/gtfs/read.rs @@ -1240,7 +1240,7 @@ mod tests { gtfs::read::EquipmentList, model::Collections, objects::*, - read_utils::{self, PathFileHandler}, + read_utils::{self, PathFileHandler, read_opt_collection}, test_utils::*, AddPrefix, }; @@ -3012,4 +3012,86 @@ mod tests { assert_eq!(format!("{}", err), "the first stop time of the vj '1' has no departure/arrival, the stop_times.txt file is not valid"); }); } + #[test] + fn stop_location_on_stops() { + let stops_content = + "stop_id,stop_code,stop_name,stop_lat,stop_lon,location_type,parent_station\n\ + stoppoint_id,1234,my stop name,0.1,1.2,0,stop_area_id\n\ + stoparea_id,5678,stop area name,0.1,1.2,1,\n\ + entrance_id,,entrance name,0.1,1.2,2,stop_area_id\n\ + node_id,,node name,0.1,1.2,3,stop_area_id\n\ + boarding_id,,boarding name,0.1,1.2,4,stoppoint_id"; + test_in_tmp_dir(|path| { + let mut handler = PathFileHandler::new(path.to_path_buf()); + create_file_with_content(path, "stops.txt", stops_content); + let mut equipments = EquipmentList::default(); + let mut comments: CollectionWithId = CollectionWithId::default(); + let (_, _, mut stop_locations) = + super::manage_stops(&mut handler, &mut comments, &mut equipments).unwrap(); + let stop_entrance = stop_locations + .clone() + .take() + .into_iter() + .filter(|sl| sl.stop_type == StopType::StopEntrance) + .collect::>(); + assert_eq!(1, stop_entrance.len()); + let stop_node = stop_locations + .clone() + .take() + .into_iter() + .filter(|sl| sl.stop_type == StopType::GenericNode) + .collect::>(); + assert_eq!(1, stop_node.len()); + let stop_boarding = stop_locations + .take() + .into_iter() + .filter(|sl| sl.stop_type == StopType::GenericNode) + .collect::>(); + assert_eq!(1, stop_boarding.len()); + }); + } + #[test] + fn filter_pathway() { + let stops_content = + "stop_id,stop_code,stop_name,stop_lat,stop_lon,location_type,parent_station,level_id\n\ + stoppoint_id,1234,my stop name,0.1,1.2,0,stop_area_id,2\n\ + stoparea_id,5678,stop area name,0.1,1.2,1,,\n\ + entrance_id,,entrance name,0.1,1.2,2,stop_area_id,1\n\ + node_id,,node name,0.1,1.2,3,stop_area_id,2\n\ + boarding_id,,boarding name,0.1,1.2,4,stoppoint_id,"; + let pathway_content = "pathway_id,from_stop_id,to_stop_id,pathway_mode,is_bidirectional\n\ + 1;stoppoint_id,stoparea_id,8,0\n\ + 2,stoppoint_id,stoparea_id,1,3\n\ + 3,stoppoint_id,stoparea_id_0,2,0\n\ + 4,stoppoint_id,stoparea_id,1,0"; + test_in_tmp_dir(|path| { + let mut handler = PathFileHandler::new(path.to_path_buf()); + create_file_with_content(path, "stops.txt", stops_content); + create_file_with_content(path, "pathways.txt", pathway_content); + let pathways = super::read_pathways(&mut handler).unwrap(); + assert_eq!(1, pathways.len()); + }) + } + #[test] + fn read_levels() { + let stops_content = + "stop_id,stop_code,stop_name,stop_lat,stop_lon,location_type,parent_station,level_id\n\ + stoppoint_id,1234,my stop name,0.1,1.2,0,stop_area_id,2\n\ + stoparea_id,5678,stop area name,0.1,1.2,1,,\n\ + entrance_id,,entrance name,0.1,1.2,2,stop_area_id,1\n\ + node_id,,node name,0.1,1.2,3,stop_area_id,2\n\ + boarding_id,,boarding name,0.1,1.2,4,stoppoint_id,"; + let level_content = "level_id,level_index\n\ + 1,0\n\ + 2,2\n\ + 3,1\n\ + 4,4"; + test_in_tmp_dir(|path| { + let mut handler = PathFileHandler::new(path.to_path_buf()); + create_file_with_content(path, "stops.txt", stops_content); + create_file_with_content(path, "levels.txt", level_content); + let levels : CollectionWithId = read_opt_collection(&mut handler, "levels.txt").unwrap(); + assert_eq!(4, levels.len()); + }) + } } diff --git a/src/ntfs/mod.rs b/src/ntfs/mod.rs index 8de7f723c..219f5045d 100644 --- a/src/ntfs/mod.rs +++ b/src/ntfs/mod.rs @@ -264,7 +264,7 @@ pub fn write>( &model.stop_time_headsigns, &model.stop_time_ids, )?; - write::write_collection(path, "frequencies.txt", &model.frequencies)?; + write_collection(path, "frequencies.txt", &model.frequencies)?; write_calendar_dates(path, &model.calendars)?; write::write_stops( path, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/agency.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/agency.txt new file mode 100644 index 000000000..962681ae4 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/agency.txt @@ -0,0 +1,2 @@ +agency_name,agency_url,agency_timezone +mon agence,http://kisio.org,Europe/Paris diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/calendar_dates.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/calendar_dates.txt new file mode 100644 index 000000000..b251745b3 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/calendar_dates.txt @@ -0,0 +1,6 @@ +service_id,date,exception_type +service:1,20180101,1 +service:1,20180102,1 +service:1,20180103,1 +service:2,20180105,1 +service:2,20180106,1 \ No newline at end of file diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/levels.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/levels.txt new file mode 100644 index 000000000..2fbd225b4 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/levels.txt @@ -0,0 +1,4 @@ +level_id,level_index +0,0 +1,-1 +2,1 diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/pathways.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/pathways.txt new file mode 100644 index 000000000..955605431 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/pathways.txt @@ -0,0 +1,4 @@ +pathway_id,from_stop_id,to_stop_id,pathway_mode,is_bidirectional +1,entrance:1,node:1,1,0 +2,node:1,boarding:1,2,1 + diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/routes.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/routes.txt new file mode 100644 index 000000000..d57344bf8 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/routes.txt @@ -0,0 +1,5 @@ +route_id,route_short_name,route_long_name,line_id,route_type +route_not_in_trip:1,ma route 1,,line:1,1 +route:2,ma route 1,,line:1,1 +route:3,ma route 2,,line:2,1 +route_not_in_trip:4,ma route 3,,line:2,1 \ No newline at end of file diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/stop_times.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/stop_times.txt new file mode 100644 index 000000000..327d5c4cf --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/stop_times.txt @@ -0,0 +1,12 @@ +trip_id,stop_sequence,stop_id,arrival_time,departure_time +trip:3,0,stop:31,23:50:00,23:50:00 +trip:3,1,stop:32,24:03:00,24:05:00 +trip:3,2,stop:33,24:10:00,24:15:00 +trip:4,0,stop:11,07:23:00,07:23:00 +trip:4,1,stop:22,07:32:00,07:32:00 +trip:4,2,stop:33,07:40:00,07:42:00 +trip:5,0,stop:51,13:23:00,13:23:00 +trip:5,1,stop:52,14:10:00,14:10:00 +trip:5,2,stop:53,14:40:00,14:40:00 +trip:6,0,stop:61,14:40:00,14:40:00 +trip:6,1,stop:61,15:20:00,15:20:00 \ No newline at end of file diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/stops.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/stops.txt new file mode 100644 index 000000000..f75e28fe5 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/stops.txt @@ -0,0 +1,19 @@ +stop_id,stop_name,stop_lat,stop_lon,location_type,parent_station,level_id +stoparea:1,plop,48.844746,2.372987,1,, +stop:11,pouet,48.844746,2.372987,0,stoparea:1,1 +stop:12,pouet,48.844746,2.372987,0,stoparea:1, +stop:13,pouet,48.844746,2.372987,0,stoparea:1, +stop:14,pouet,48.844746,2.372987,0,stoparea:1, +stop:21,pouet,48.844746,2.372987,0,stoparea:1, +stop:22,pouet,48.844746,2.372987,0,stoparea:1, +stop:31,pouet,48.844746,2.372987,0,stoparea:1, +stop:32,pouet,48.844746,2.372987,0,stoparea:1, +stop:33,pouet,48.844746,2.372987,0,stoparea:1, +stop:51,pouet,48.844746,2.372987,0,stoparea:1, +stop:52,pouet,48.844746,2.372987,0,stoparea:1, +stop:53,pouet,48.844746,2.372987,0,stoparea:1, +stop:61,pouet,48.844746,2.372987,0,stoparea:1, +stop:62,pouet,48.844746,2.372987,0,stoparea:1, +entrance:1,Entrance 1,48.844747,2.372988,2,stoparea:1,0 +node:1,Node 1,48.844748,2.372989,3,stoparea:2,0 +boarding:1,Boarding 1,48.844749,2.372990,4,stop:11,1 diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/trips.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/trips.txt new file mode 100644 index 000000000..c3210186c --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/input/trips.txt @@ -0,0 +1,6 @@ +route_id,service_id,trip_id +route:2,service:1,trip:3 +route:2,service:1,trip:4 +route:3,service:2,trip:5 +route:3,service:2,trip:6 +route:3,service:2,with_no_stop_times diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/calendar.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/calendar.txt new file mode 100644 index 000000000..d006cfce8 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/calendar.txt @@ -0,0 +1,3 @@ +service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date +service:1,1,1,1,0,0,0,0,20180101,20180103 +service:2,0,0,0,0,1,1,0,20180105,20180106 diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/commercial_modes.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/commercial_modes.txt new file mode 100644 index 000000000..8560e5b14 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/commercial_modes.txt @@ -0,0 +1,2 @@ +commercial_mode_id,commercial_mode_name +Metro,Metro diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/companies.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/companies.txt new file mode 100644 index 000000000..50051161e --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/companies.txt @@ -0,0 +1,2 @@ +company_id,company_name,company_address,company_url,company_mail,company_phone +default_agency_id,mon agence,,http://kisio.org,, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/contributors.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/contributors.txt new file mode 100644 index 000000000..bfa64e0e1 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/contributors.txt @@ -0,0 +1,2 @@ +contributor_id,contributor_name,contributor_license,contributor_website +default_contributor,Default contributor,Unknown license, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/datasets.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/datasets.txt new file mode 100644 index 000000000..f262db430 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/datasets.txt @@ -0,0 +1,2 @@ +dataset_id,contributor_id,dataset_start_date,dataset_end_date,dataset_type,dataset_extrapolation,dataset_desc,dataset_system +default_dataset,default_contributor,20180101,20180106,,0,, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/feed_infos.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/feed_infos.txt new file mode 100644 index 000000000..baa9c8c8b --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/feed_infos.txt @@ -0,0 +1,6 @@ +feed_info_param,feed_info_value +feed_creation_date,20191007 +feed_creation_time,09:22:53 +feed_end_date,20180106 +feed_start_date,20180101 +ntfs_version,0.9.2 diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/levels.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/levels.txt new file mode 100644 index 000000000..d8e745ff5 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/levels.txt @@ -0,0 +1,3 @@ +level_id,level_index,level_name +0,0.0, +1,-1.0, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/lines.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/lines.txt new file mode 100644 index 000000000..eb2dafca8 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/lines.txt @@ -0,0 +1,3 @@ +line_id,line_code,line_name,forward_line_name,backward_line_name,line_color,line_text_color,line_sort_order,network_id,commercial_mode_id,geometry_id,line_opening_time,line_closing_time +route:2,ma route 1,,,,,,,default_agency_id,Metro,,, +route:3,ma route 2,,,,,,,default_agency_id,Metro,,, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/networks.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/networks.txt new file mode 100644 index 000000000..c44830344 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/networks.txt @@ -0,0 +1,2 @@ +network_id,network_name,network_url,network_timezone,network_lang,network_phone,network_address,network_sort_order +default_agency_id,mon agence,http://kisio.org,Europe/Paris,,,, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/pathways.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/pathways.txt new file mode 100644 index 000000000..943cf4fcb --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/pathways.txt @@ -0,0 +1,3 @@ +pathway_id,from_stop_id,to_stop_id,pathway_mode,is_bidirectional,length,traversal_time,stair_count,max_slope,min_width,signposted_as,reversed_signposted_as +1,entrance:1,node:1,1,0,,,,,,, +2,node:1,boarding:1,2,1,,,,,,, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/physical_modes.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/physical_modes.txt new file mode 100644 index 000000000..090907455 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/physical_modes.txt @@ -0,0 +1,2 @@ +physical_mode_id,physical_mode_name,co2_emission +Metro,Metro, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/routes.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/routes.txt new file mode 100644 index 000000000..a38a3b9b0 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/routes.txt @@ -0,0 +1,3 @@ +route_id,route_name,direction_type,line_id,geometry_id,destination_id +route:2,,forward,route:2,, +route:3,,forward,route:3,, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/stop_times.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/stop_times.txt new file mode 100644 index 000000000..cc07f0fd1 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/stop_times.txt @@ -0,0 +1,12 @@ +stop_id,trip_id,stop_sequence,arrival_time,departure_time,boarding_duration,alighting_duration,pickup_type,drop_off_type,datetime_estimated,local_zone_id,stop_headsign,stop_time_id +stop:31,trip:3,0,23:50:00,23:50:00,0,0,0,0,0,,, +stop:32,trip:3,1,24:03:00,24:05:00,0,0,0,0,0,,, +stop:33,trip:3,2,24:10:00,24:15:00,0,0,0,0,0,,, +stop:11,trip:4,0,07:23:00,07:23:00,0,0,0,0,0,,, +stop:22,trip:4,1,07:32:00,07:32:00,0,0,0,0,0,,, +stop:33,trip:4,2,07:40:00,07:42:00,0,0,0,0,0,,, +stop:51,trip:5,0,13:23:00,13:23:00,0,0,0,0,0,,, +stop:52,trip:5,1,14:10:00,14:10:00,0,0,0,0,0,,, +stop:53,trip:5,2,14:40:00,14:40:00,0,0,0,0,0,,, +stop:61,trip:6,0,14:40:00,14:40:00,0,0,0,0,0,,, +stop:61,trip:6,1,15:20:00,15:20:00,0,0,0,0,0,,, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/stops.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/stops.txt new file mode 100644 index 000000000..15184319e --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/stops.txt @@ -0,0 +1,14 @@ +stop_id,stop_name,visible,fare_zone_id,zone_id,stop_lon,stop_lat,location_type,parent_station,stop_timezone,geometry_id,equipment_id,level_id,platform_code +stop:11,pouet,1,,,2.372987,48.844746,0,stoparea:1,,,,1, +stop:22,pouet,1,,,2.372987,48.844746,0,stoparea:1,,,,, +stop:31,pouet,1,,,2.372987,48.844746,0,stoparea:1,,,,, +stop:32,pouet,1,,,2.372987,48.844746,0,stoparea:1,,,,, +stop:33,pouet,1,,,2.372987,48.844746,0,stoparea:1,,,,, +stop:51,pouet,1,,,2.372987,48.844746,0,stoparea:1,,,,, +stop:52,pouet,1,,,2.372987,48.844746,0,stoparea:1,,,,, +stop:53,pouet,1,,,2.372987,48.844746,0,stoparea:1,,,,, +stop:61,pouet,1,,,2.372987,48.844746,0,stoparea:1,,,,, +stoparea:1,plop,1,,,2.372987,48.844746,1,,,,,, +entrance:1,Entrance 1,0,,,2.372988,48.844747,3,stoparea:1,,,,0, +node:1,Node 1,0,,,2.372989,48.844748,4,stoparea:2,,,,0, +boarding:1,Boarding 1,0,,,2.37299,48.844749,5,stop:11,,,,1, diff --git a/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/trips.txt b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/trips.txt new file mode 100644 index 000000000..50a98f331 --- /dev/null +++ b/tests/fixtures/gtfs2ntfs/levels_and_pathways/output/trips.txt @@ -0,0 +1,6 @@ +trip_id,route_id,physical_mode_id,dataset_id,service_id,trip_headsign,block_id,company_id,trip_property_id,geometry_id +trip:3,route:2,Metro,default_dataset,service:1,,,default_agency_id,, +trip:4,route:2,Metro,default_dataset,service:1,,,default_agency_id,, +trip:5,route:3,Metro,default_dataset,service:2,,,default_agency_id,, +trip:6,route:3,Metro,default_dataset,service:2,,,default_agency_id,, +with_no_stop_times,route:3,Metro,default_dataset,service:2,,,default_agency_id,, diff --git a/tests/gtfs2ntfs.rs b/tests/gtfs2ntfs.rs index 151d3f067..984b93efb 100644 --- a/tests/gtfs2ntfs.rs +++ b/tests/gtfs2ntfs.rs @@ -139,3 +139,17 @@ fn test_gtfs_with_platforms() { ); }); } + +#[test] +fn test_gtfs_with_levels() { + test_in_tmp_dir(|path| { + let input_dir = "./tests/fixtures/gtfs2ntfs/levels_and_pathways/input"; + let model = transit_model::gtfs::read_from_path(input_dir, None, None).unwrap(); + transit_model::ntfs::write(&model, path, get_test_datetime()).unwrap(); + compare_output_dir_with_expected( + &path, + Some(vec!["stops.txt", "pathways.txt", "levels.txt",],), + "./tests/fixtures/gtfs2ntfs/levels_and_pathways/output", + ); + }); +}