Skip to content

Commit

Permalink
Merge pull request #678 from woshilapin/improved-base-fixture
Browse files Browse the repository at this point in the history
[test] Add a more complete test on 'gtfs2ntfs'
  • Loading branch information
ArnaudOggy authored Jul 27, 2020
2 parents f13f342 + f88a103 commit ecf31c9
Show file tree
Hide file tree
Showing 65 changed files with 190 additions and 230 deletions.
6 changes: 3 additions & 3 deletions documentation/gtfs_to_ntfs_specs.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ The `gtfs_stop_code` complementary `object_code` is kept here for backward
compatibility reasons. It will be removed in the future.

(3) The `comment` object is a complex type with additional properties :
* `comment_id` : specify an identifier with the pattern **\stop:<stop_id of GTFS>**
* `comment_id` : specify an identifier with the pattern **stop:<stop_id of GTFS>**
* `comment_type` : specify the fixed value "information"

(4) The `equipment` object is a complex type with additional properties :
+ `equipment_id` : should be generated by the reader.
+ `wheelchair_boarding` : possible values are the same in both GTFS and NTFS
Be carefull to only create necessary equipments and avoid dupplicates.
+ `wheelchair_boarding` : possible values are the same in both GTFS and NTFS.
Be careful to only create necessary equipments and avoid duplicates.

**_"Source" complementary code :_**

Expand Down
4 changes: 2 additions & 2 deletions src/gtfs/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ where
.trim(csv::Trim::All)
.from_reader(reader);
let mut headsigns = HashMap::new();
let mut tmp_vjs = HashMap::new();
let mut tmp_vjs = BTreeMap::new();
for stop_time in rdr.deserialize() {
let mut stop_time: StopTime =
stop_time.with_context(|_| format!("Error reading {:?}", path))?;
Expand Down Expand Up @@ -1084,7 +1084,7 @@ fn make_ntfs_vehicle_journeys(
let (_, dataset) = datasets.iter().next().unwrap();
let mut vehicle_journeys: Vec<objects::VehicleJourney> = vec![];
let mut trip_properties: Vec<objects::TripProperty> = vec![];
let mut map_tps_trips: HashMap<(Availability, Availability), Vec<&Trip>> = HashMap::new();
let mut map_tps_trips: BTreeMap<(Availability, Availability), Vec<&Trip>> = BTreeMap::new();
let mut id_incr: u8 = 1;
let mut property_id: Option<String>;

Expand Down
4 changes: 3 additions & 1 deletion src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,9 @@ impl AddPrefix for Comment {
}
}

#[derive(Serialize, Deserialize, Debug, Derivative, PartialEq, Eq, Hash, Clone, Copy)]
#[derive(
Serialize, Deserialize, Debug, Derivative, PartialOrd, Ord, PartialEq, Eq, Hash, Clone, Copy,
)]
#[derivative(Default)]
pub enum Availability {
#[derivative(Default)]
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/gtfs/agency.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
agency_id,agency_name,agency_url,agency_timezone,agency_phone
1,mon agence,http://kisio.org,Europe/Paris,
2,my agency,http://kisio.org,Europe/Paris,0123456789
File renamed without changes.
Empty file.
11 changes: 11 additions & 0 deletions tests/fixtures/gtfs/frequencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
trip_id,start_time,end_time,headway_secs,exact_times
trip:1,07:00:00,08:00:00,1800,
trip:1,17:00:00,18:00:00,300,
trip:2,14:05:00,16:00:00,600,1
trip:3,10:00:00,10:15:00,900,1
trip:4,20:00:00,22:00:00,1800,0
trip:5,23:00:00,25:15:00,3000,1
trip:russian,15:00:00,60:00:00,43200,1
trip:after_midnight,10:30:00,10:30:00,900,1
trip:unexisting,10:30:00,10:55:00,900,1
trip:with_no_stop_times,10:30:00,10:55:00,300,1
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions tests/fixtures/gtfs/routes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
route_id,route_short_name,route_long_name,line_id,route_type,agency_id
route_not_in_trip:1,ma route 1,,line:1,1,1
route:2,ma route 1,,line:1,1,1
route:3,ma route 2,,line:2,1,2
route_not_in_trip:4,ma route 3,,line:2,1,2
12 changes: 12 additions & 0 deletions tests/fixtures/gtfs/stop_times.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trip_id,stop_sequence,stop_id,arrival_time,departure_time,pickup_type,drop_off_type
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,2,
trip:4,1,stop:22,07:32:00,07:32:00,2,
trip:4,2,stop:33,07:40:00,07:42:00,2,
trip:5,0,stop:51,13:23:00,13:23:00,2,
trip:5,1,stop:52,14:10:00,14:10:00,2,
trip:5,2,stop:53,14:40:00,14:40:00,,2
trip:6,0,stop:61,14:40:00,14:40:00,2,
trip:6,1,stop:61,15:20:00,15:20:00,2,
21 changes: 21 additions & 0 deletions tests/fixtures/gtfs/stops.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
stop_id,stop_name,stop_lat,stop_lon,location_type,parent_station,stop_desc,wheelchair_boarding,level_id,platform_code
stoparea:1,plop,48.844746,2.372987,1,,stoparea:1_comment,,,
stop:11,pouet,48.844746,2.372987,0,stoparea:1,stop:11_comment,1,1,A
stop:12,pouet,48.844746,2.372987,0,stoparea:1,,2,,
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,
node:2,Node 2,,,3,stoparea:2,,,0,
boarding:1,Boarding 1,48.844749,2.372990,4,stop:11,,,1,
boarding:2,Boarding 2,,,4,stop:11,,,1,
6 changes: 6 additions & 0 deletions tests/fixtures/gtfs/trips.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
route_id,service_id,trip_id,wheelchair_accessible
route:2,service:1,trip:3,1
route:2,service:1,trip:4,1
route:3,service:2,trip:5,2
route:3,service:2,trip:6,0
route:3,service:2,with_no_stop_times,0
File renamed without changes.
4 changes: 4 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/calendar.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date
ME:service:1,1,1,1,0,0,0,0,20180101,20180103
ME:service:2,0,0,0,0,1,1,0,20180105,20180106
ME:service:2:+1days,0,0,0,0,0,1,1,20180106,20180107
3 changes: 3 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/comment_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object_id,object_type,comment_id
ME:stoparea:1,stop_area,ME:stop:stoparea:1
ME:stop:11,stop_point,ME:stop:stop:11
3 changes: 3 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/comments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
comment_id,comment_type,comment_label,comment_name,comment_url
ME:stop:stoparea:1,information,,stoparea:1_comment,
ME:stop:stop:11,information,,stop:11_comment,
3 changes: 3 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/companies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
company_id,company_name,company_address,company_url,company_mail,company_phone
ME:1,mon agence,,http://kisio.org,,
ME:2,my agency,,http://kisio.org,,0123456789
2 changes: 2 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/contributors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
contributor_id,contributor_name,contributor_license,contributor_website
ME:DefaultContributorId,DefaultContributorName,DefaultDatasourceLicense,http://www.default-datasource-website.com
Original file line number Diff line number Diff line change
@@ -1,2 +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,,
ME:DefaultDatasetId,ME:DefaultContributorId,20180101,20180106,,0,,
2 changes: 2 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/equipments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
equipment_id,wheelchair_boarding,sheltered,elevator,escalator,bike_accepted,bike_depot,visual_announcement,audible_announcement,appropriate_escort,appropriate_signage
ME:0,1,0,0,0,0,0,0,0,0,0
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ feed_info_param,feed_info_value
feed_creation_date,20190403
feed_creation_time,17:19:00
feed_creation_datetime,2019-04-03T17:19:00+00:00
feed_end_date,20180103
feed_end_date,20180106
feed_license,DefaultDatasourceLicense
feed_license_url,http://www.default-datasource-website.com
feed_publisher_name,DefaultContributorName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
level_id,level_index,level_name
0,0.0,
1,-1.0,
ME:0,0.0,
ME:1,-1.0,
Original file line number Diff line number Diff line change
@@ -1,3 +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,,,
ME:route:2,ma route 1,,,,,,,ME:1,Metro,,10:00:00,21:47:00
ME:route:3,ma route 2,,,,,,,ME:2,Metro,,14:40:00,25:57:00
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
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,,,,
ME:1,mon agence,http://kisio.org,Europe/Paris,,,,
ME:2,my agency,http://kisio.org,Europe/Paris,,0123456789,,
22 changes: 22 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/object_codes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
object_type,object_id,object_system,object_code
stop_area,ME:stoparea:1,source,stoparea:1
stop_point,ME:stop:11,source,stop:11
stop_point,ME:stop:22,source,stop:22
stop_point,ME:stop:31,source,stop:31
stop_point,ME:stop:32,source,stop:32
stop_point,ME:stop:33,source,stop:33
stop_point,ME:stop:51,source,stop:51
stop_point,ME:stop:52,source,stop:52
stop_point,ME:stop:53,source,stop:53
stop_point,ME:stop:61,source,stop:61
network,ME:1,source,1
network,ME:2,source,2
trip,ME:trip:3-0,source,trip:3
trip,ME:trip:4-0,source,trip:4
trip,ME:trip:4-1,source,trip:4
trip,ME:trip:4-2,source,trip:4
trip,ME:trip:4-3,source,trip:4
trip,ME:trip:5-0,source,trip:5
trip,ME:trip:5-1,source,trip:5
trip,ME:trip:5-2,source,trip:5
trip,ME:trip:6,source,trip:6
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ME:1,ME:entrance:1,ME:node:1,1,0,,,,,,,
ME:2,ME:node:1,ME:boarding:1,2,1,,,,,,,
ME:3,ME:node:2,ME:boarding:2,2,1,,,42,,,,
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,,,,,,,
3,node:2,boarding:2,2,1,,,42,,,,
5 changes: 5 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/physical_modes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
physical_mode_id,physical_mode_name,co2_emission
Metro,Metro,3.0
Bike,Bike,0.0
BikeSharingService,BikeSharingService,0.0
Car,Car,184.0
3 changes: 3 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/routes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
route_id,route_name,direction_type,line_id,geometry_id,destination_id
ME:route:2,ma route 1,forward,ME:route:2,,ME:stoparea:1
ME:route:3,ma route 2,forward,ME:route:3,,ME:stoparea:1
27 changes: 27 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/stop_times.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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_time_precision
ME:stop:11,ME:trip:4-0,0,20:00:00,20:00:00,0,0,2,0,1,,,,0
ME:stop:11,ME:trip:4-1,0,20:30:00,20:30:00,0,0,2,0,1,,,,0
ME:stop:11,ME:trip:4-2,0,21:00:00,21:00:00,0,0,2,0,1,,,,0
ME:stop:11,ME:trip:4-3,0,21:30:00,21:30:00,0,0,2,0,1,,,,0
ME:stop:22,ME:trip:4-0,1,20:09:00,20:09:00,0,0,2,0,1,,,,0
ME:stop:22,ME:trip:4-1,1,20:39:00,20:39:00,0,0,2,0,1,,,,0
ME:stop:22,ME:trip:4-2,1,21:09:00,21:09:00,0,0,2,0,1,,,,0
ME:stop:22,ME:trip:4-3,1,21:39:00,21:39:00,0,0,2,0,1,,,,0
ME:stop:31,ME:trip:3-0,0,10:00:00,10:00:00,0,0,0,0,0,,,,0
ME:stop:32,ME:trip:3-0,1,10:13:00,10:15:00,0,0,0,0,0,,,,0
ME:stop:33,ME:trip:3-0,2,10:20:00,10:25:00,0,0,0,0,0,,,,0
ME:stop:33,ME:trip:4-0,2,20:17:00,20:19:00,0,0,2,0,1,,,,0
ME:stop:33,ME:trip:4-1,2,20:47:00,20:49:00,0,0,2,0,1,,,,0
ME:stop:33,ME:trip:4-2,2,21:17:00,21:19:00,0,0,2,0,1,,,,0
ME:stop:33,ME:trip:4-3,2,21:47:00,21:49:00,0,0,2,0,1,,,,0
ME:stop:51,ME:trip:5-0,0,23:00:00,23:00:00,0,0,2,0,0,,,,0
ME:stop:51,ME:trip:5-1,0,23:50:00,23:50:00,0,0,2,0,0,,,,0
ME:stop:51,ME:trip:5-2,0,00:40:00,00:40:00,0,0,2,0,0,,,,0
ME:stop:52,ME:trip:5-0,1,23:47:00,23:47:00,0,0,2,0,0,,,,0
ME:stop:52,ME:trip:5-1,1,24:37:00,24:37:00,0,0,2,0,0,,,,0
ME:stop:52,ME:trip:5-2,1,01:27:00,01:27:00,0,0,2,0,0,,,,0
ME:stop:53,ME:trip:5-0,2,24:17:00,24:17:00,0,0,0,2,0,,,,0
ME:stop:53,ME:trip:5-1,2,25:07:00,25:07:00,0,0,0,2,0,,,,0
ME:stop:53,ME:trip:5-2,2,01:57:00,01:57:00,0,0,0,2,0,,,,0
ME:stop:61,ME:trip:6,0,14:40:00,14:40:00,0,0,2,0,0,,,,0
ME:stop:61,ME:trip:6,1,15:20:00,15:20:00,0,0,2,0,0,,,,0
16 changes: 16 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/stops.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
stop_id,stop_name,stop_code,visible,fare_zone_id,stop_lon,stop_lat,location_type,parent_station,stop_timezone,geometry_id,equipment_id,level_id,platform_code
ME:stop:11,pouet,,1,,2.372987,48.844746,0,ME:stoparea:1,,,ME:0,ME:1,A
ME:stop:22,pouet,,1,,2.372987,48.844746,0,ME:stoparea:1,,,,,
ME:stop:31,pouet,,1,,2.372987,48.844746,0,ME:stoparea:1,,,,,
ME:stop:32,pouet,,1,,2.372987,48.844746,0,ME:stoparea:1,,,,,
ME:stop:33,pouet,,1,,2.372987,48.844746,0,ME:stoparea:1,,,,,
ME:stop:51,pouet,,1,,2.372987,48.844746,0,ME:stoparea:1,,,,,
ME:stop:52,pouet,,1,,2.372987,48.844746,0,ME:stoparea:1,,,,,
ME:stop:53,pouet,,1,,2.372987,48.844746,0,ME:stoparea:1,,,,,
ME:stop:61,pouet,,1,,2.372987,48.844746,0,ME:stoparea:1,,,,,
ME:stoparea:1,plop,,1,,2.372987,48.844746,1,,,,,,
ME:boarding:1,Boarding 1,,0,,2.37299,48.844749,5,ME:stop:11,,,,ME:1,
ME:boarding:2,Boarding 2,,0,,,,5,ME:stop:11,,,,ME:1,
ME:entrance:1,Entrance 1,,0,,2.372988,48.844747,3,ME:stoparea:1,,,,ME:0,
ME:node:1,Node 1,,0,,2.372989,48.844748,4,ME:stoparea:2,,,,ME:0,
ME:node:2,Node 2,,0,,,,4,ME:stoparea:2,,,,ME:0,
3 changes: 3 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/trip_properties.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
trip_property_id,wheelchair_accessible,bike_accepted,air_conditioned,visual_announcement,audible_announcement,appropriate_escort,appropriate_signage,school_vehicle_type
ME:1,1,0,0,0,0,0,0,0
ME:2,2,0,0,0,0,0,0,0
10 changes: 10 additions & 0 deletions tests/fixtures/gtfs2ntfs/full_output/trips.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
trip_id,route_id,physical_mode_id,dataset_id,service_id,trip_headsign,trip_short_name,block_id,company_id,trip_property_id,geometry_id,journey_pattern_id
ME:trip:3-0,ME:route:2,Metro,ME:DefaultDatasetId,ME:service:1,pouet,,,ME:1,ME:1,,
ME:trip:4-0,ME:route:2,Metro,ME:DefaultDatasetId,ME:service:1,pouet,,,ME:1,ME:1,,
ME:trip:4-1,ME:route:2,Metro,ME:DefaultDatasetId,ME:service:1,pouet,,,ME:1,ME:1,,
ME:trip:4-2,ME:route:2,Metro,ME:DefaultDatasetId,ME:service:1,pouet,,,ME:1,ME:1,,
ME:trip:4-3,ME:route:2,Metro,ME:DefaultDatasetId,ME:service:1,pouet,,,ME:1,ME:1,,
ME:trip:5-0,ME:route:3,Metro,ME:DefaultDatasetId,ME:service:2,pouet,,,ME:2,ME:2,,
ME:trip:5-1,ME:route:3,Metro,ME:DefaultDatasetId,ME:service:2,pouet,,,ME:2,ME:2,,
ME:trip:5-2,ME:route:3,Metro,ME:DefaultDatasetId,ME:service:2:+1days,pouet,,,ME:2,ME:2,,
ME:trip:6,ME:route:3,Metro,ME:DefaultDatasetId,ME:service:2,pouet,,,ME:2,,,
2 changes: 0 additions & 2 deletions tests/fixtures/gtfs2ntfs/levels_and_pathways/input/agency.txt

This file was deleted.

5 changes: 0 additions & 5 deletions tests/fixtures/gtfs2ntfs/levels_and_pathways/input/routes.txt

This file was deleted.

12 changes: 0 additions & 12 deletions tests/fixtures/gtfs2ntfs/levels_and_pathways/input/stop_times.txt

This file was deleted.

21 changes: 0 additions & 21 deletions tests/fixtures/gtfs2ntfs/levels_and_pathways/input/stops.txt

This file was deleted.

6 changes: 0 additions & 6 deletions tests/fixtures/gtfs2ntfs/levels_and_pathways/input/trips.txt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions tests/fixtures/gtfs2ntfs/levels_and_pathways/output/stop_times.txt

This file was deleted.

16 changes: 0 additions & 16 deletions tests/fixtures/gtfs2ntfs/levels_and_pathways/output/stops.txt

This file was deleted.

6 changes: 0 additions & 6 deletions tests/fixtures/gtfs2ntfs/levels_and_pathways/output/trips.txt

This file was deleted.

2 changes: 0 additions & 2 deletions tests/fixtures/gtfs2ntfs/minimal_with_config/input/agency.txt

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions tests/fixtures/gtfs2ntfs/minimal_with_config/input/routes.txt

This file was deleted.

This file was deleted.

Loading

0 comments on commit ecf31c9

Please sign in to comment.