Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudOggy committed Jul 3, 2024
1 parent 4a7ad57 commit ef48695
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date
Week,1,1,1,1,1,0,0,20180101,20181231
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
commercial_mode_id,commercial_mode_name
Bus,Bus
Metro,Metro
RER,Réseau Express Régional (RER)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
company_id,company_name,company_address,company_url,company_mail,company_phone
TGC,The Great Company,,,,
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
contributor_id,contributor_name,contributor_license,contributor_website
TGC,The Great Contributor,,
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dataset_id,contributor_id,dataset_start_date,dataset_end_date,dataset_type,dataset_extrapolation,dataset_desc,dataset_system
TGDS,TGC,20180101,20181231,,0,,
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
feed_info_param,feed_info_value
feed_creation_date,20240703
feed_creation_datetime,2024-07-03T12:49:20+00:00
feed_creation_time,12:49:20
feed_end_date,20181231
feed_start_date,20180101
ntfs_version,0.15.0
4 changes: 4 additions & 0 deletions ntfs2gtfs/tests/fixtures/input_ntfs_with_fare_urls/lines.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
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
M1,,Metro 1,,,,,,N1,Metro,,09:00:00,11:10:00
B42,,Bus 42,,,,,,N2,Bus,,07:00:00,10:20:00
RERA,,RER A,,,,,,N3,RER,,08:10:00,19:34:00
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
network_id,network_name,network_url,network_timezone,network_lang,network_phone,network_address,network_fare_url,network_sort_order
N1,Network 1,,,,,,,
N2,Network 2,,,,,,http://www.network2.com,
N3,Network 3,,,,,,http://www.network3.com,
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
physical_mode_id,physical_mode_name,co2_emission
Bus,Bus,132.0
Metro,Metro,3.0
RapidTransit,Rapid Transit,7.28
Bike,Bike,0.0
BikeSharingService,BikeSharingService,0.0
Car,Car,184.0
7 changes: 7 additions & 0 deletions ntfs2gtfs/tests/fixtures/input_ntfs_with_fare_urls/routes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
route_id,route_name,direction_type,line_id,geometry_id,destination_id
M1F,Nation - Charles de Gaulle,forward,M1,,CDG
M1B,Charles de Gaulle - Nation,forward,M1,,NAT
B42F,Gare de Lyon - Montparnasse,forward,B42,,MTP
B42B,Montparnasse - Gare de Lyon,forward,B42,,GDL
RERAF,Nation - La Défense,forward,RERA,,DEF
RERAB,La Défense - Nation,forward,RERA,,Navitia:MTPZ
24 changes: 24 additions & 0 deletions ntfs2gtfs/tests/fixtures/input_ntfs_with_fare_urls/stop_times.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
stop_id,trip_id,stop_sequence,arrival_time,departure_time,boarding_duration,alighting_duration,pickup_type,drop_off_type,local_zone_id,stop_headsign,stop_time_id,stop_time_precision
NATM,M1F1,0,09:00:00,09:00:00,0,0,0,1,,,,0
GDLM,M1F1,1,09:10:00,09:10:00,0,0,3,3,,,,0
CHAM,M1F1,2,09:20:00,09:20:00,0,0,0,0,,,,0
CDGM,M1F1,3,09:40:00,09:40:00,0,0,1,0,,,,0
CDGM,M1B1,6,10:40:00,10:40:00,0,0,0,1,,,,0
CHAM,M1B1,7,10:50:00,10:50:00,0,0,0,0,,,,0
GDLM,M1B1,8,11:00:00,11:00:00,0,0,0,0,,,,0
NATM,M1B1,9,11:10:00,11:10:00,0,0,1,0,,,,0
GDLB,B42F1,10,10:10:00,10:10:00,0,0,0,1,,,,0
MTPB,B42F1,20,10:20:00,10:20:00,0,0,1,0,,,,0
MTPB,B42B1,20,07:00:00,07:00:00,0,0,0,1,,,,0
GDLB,B42B1,30,07:10:00,07:10:00,0,0,1,0,,,,0
NATR,RERAF1,1,08:09:00,08:10:00,0,0,0,1,,,,0
GDLR,RERAF1,2,08:14:00,08:15:00,0,0,0,0,,,,0
CDGR,RERAF1,3,08:19:00,08:20:00,0,0,0,0,,,,0
DEFR,RERAF1,5,08:24:00,08:25:00,0,0,1,0,,,,0
DEFR,RERAB1,5,09:24:00,09:25:00,0,0,0,1,,,,2
CDGR,RERAB1,8,09:39:00,09:40:00,0,0,0,0,,,,0
GDLR,RERAB1,13,09:44:00,09:45:00,0,0,0,0,,,,0
NATR,RERAB1,21,09:49:00,09:50:00,0,0,0,0,,,,0
MTPZ,RERAB1,50,19:24:00,19:25:00,0,0,0,0,,,,2
CDGZ,RERAB1,51,19:26:00,19:27:00,0,0,0,0,,,,0
MTPZ,RERAB1,52,19:34:00,19:35:00,0,0,1,0,,,,2
21 changes: 21 additions & 0 deletions ntfs2gtfs/tests/fixtures/input_ntfs_with_fare_urls/stops.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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,address_id
GDLR,Gare de Lyon (RER),,1,,2.372987,48.844746,0,GDL,,,,,,
GDLM,Gare de Lyon (Metro),,1,,2.372987,48.844746,0,GDL,,,,,,
GDLB,Gare de Lyon (Bus),,1,,2.372987,48.844746,0,GDL,,,,,,
NATR,Nation (RER),,1,,2.396497,48.84849,0,NAT,,,,,,
NATM,Nation (Metro),,1,,2.396497,48.84849,0,NAT,,,,,,
CDGR,Charles de Gaulle (RER),,1,,2.295354,48.873965,0,CDG,,,,,,
CDGM,Charles de Gaulle (Metro),,1,,2.795354,48.973965,0,CDG,,,,,,
DEFR,La Défense (RER),,1,,2.238964,48.891737,0,DEF,,,,,,
CHAM,Châtelet (Metro),,1,,2.348145,48.858137,0,CHA,,,,,,
MTPB,Montparnasse (Bus),,1,,2.321783,48.842481,0,MTP,,,,,,
MTPZ,Montparnasse Zone,,1,,2.321783,48.842481,2,Navitia:MTPZ,,,,,,
CDGZ,Charles de Gaulle Zone,,1,,2.321783,48.842481,2,Navitia:CDGZ,,,,,,
GDL,Gare de Lyon,,1,,2.372987,48.844746,1,,,,,,,
NAT,Nation,,1,,2.396497,48.84849,1,,,,,,,
CDG,Charles de Gaulle,,1,,2.295354,48.873965,1,,,,,,,
DEF,La Défense,,1,,2.238964,48.891737,1,,,,,,,
CHA,Châtelet,,1,,2.348145,48.858137,1,,,,,,,
MTP,Montparnasse,,1,,2.321783,48.842481,1,,,,,,,
Navitia:MTPZ,Montparnasse Zone,,0,,2.321783,48.842481,1,,,,,,,
Navitia:CDGZ,Charles de Gaulle Zone,,0,,2.321783,48.842481,1,,,,,,,
27 changes: 27 additions & 0 deletions ntfs2gtfs/tests/fixtures/input_ntfs_with_fare_urls/transfers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from_stop_id,to_stop_id,min_transfer_time,real_min_transfer_time,equipment_id
GDLM,GDLM,0,60,
GDLR,GDLR,0,60,
CDGZ,MTPB,0,60,
GDLB,GDLM,0,60,
GDLM,GDLB,0,60,
GDLM,GDLR,0,60,
GDLR,GDLB,0,60,
GDLB,GDLR,0,60,
MTPZ,CDGZ,0,60,
MTPB,MTPB,0,60,
MTPZ,MTPZ,0,60,
CDGZ,MTPZ,0,60,
CDGM,CDGM,0,60,
NATM,NATM,0,60,
MTPB,CDGZ,0,60,
MTPB,MTPZ,0,60,
NATR,NATR,0,60,
DEFR,DEFR,0,60,
CHAM,CHAM,0,60,
NATM,NATR,0,60,
GDLB,GDLB,0,60,
NATR,NATM,0,60,
GDLR,GDLM,0,60,
CDGR,CDGR,0,60,
MTPZ,MTPB,0,60,
CDGZ,CDGZ,0,60,
7 changes: 7 additions & 0 deletions ntfs2gtfs/tests/fixtures/input_ntfs_with_fare_urls/trips.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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
M1F1,M1F,Metro,TGDS,Week,Charles de Gaulle (Metro),,,TGC,,,
M1B1,M1B,Metro,TGDS,Week,Nation (Metro),,,TGC,,,
B42F1,B42F,Bus,TGDS,Week,Montparnasse (Bus),,,TGC,,,
B42B1,B42B,Bus,TGDS,Week,Gare de Lyon (Bus),,,TGC,,,
RERAF1,RERAF,RapidTransit,TGDS,Week,La Défense (RER),,,TGC,,,
RERAB1,RERAB,Bus,TGDS,Week,Montparnasse Zone,,,TGC,,,
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
agency_id,agency_name,agency_url,agency_timezone,agency_lang,agency_phone,agency_email,agency_fare_url,ticketing_deep_link_id
N1,Network 1,http://www.navitia.io/,Europe/Paris,,,,,
N2,Network 2,http://www.navitia.io/,Europe/Paris,,,,http://www.network2.com,ticketing_deep_link:1
N3,Network 3,http://www.navitia.io/,Europe/Paris,,,,http://www.network3.com,ticketing_deep_link:2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ticketing_deep_link_id,web_url,android_intent_uri,ios_universal_link_url
ticketing_deep_link:1,http://www.network2.com,http://www.network2.com,http://www.network2.com
ticketing_deep_link:2,http://www.network3.com,http://www.network3.com,http://www.network3.com
18 changes: 18 additions & 0 deletions ntfs2gtfs/tests/ntfs2gtfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,21 @@ fn test_ntfs2gtfs_split_route_by_mode_extended() {
"./tests/fixtures/output_split_route_by_mode_extended",
);
}

#[test]
fn test_ntfs2gtfs_with_fare_urls_and_deeplinks() {
let output_dir = TempDir::new().expect("create temp dir failed");
Command::cargo_bin("ntfs2gtfs")
.expect("Failed to find binary 'ntfs2gtfs'")
.arg("--input")
.arg("tests/fixtures/input_ntfs_with_fare_urls")
.arg("--output")
.arg(output_dir.path().to_str().unwrap())
.assert()
.success();
compare_output_dir_with_expected(
output_dir,
Some(vec!["agency.txt", "ticketing_deep_links.txt"]),
"./tests/fixtures/output_gtfs_with_fare_url_deeplinks",
);
}
4 changes: 2 additions & 2 deletions src/gtfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use chrono_tz::Tz;
use derivative::Derivative;
use serde::{Deserialize, Serialize};
use std::{
collections::{BTreeMap, HashMap, HashSet},
collections::{BTreeMap, BTreeSet, HashMap},
fmt,
path::Path,
};
Expand Down Expand Up @@ -650,7 +650,7 @@ fn get_ticketing_deep_links(networks: &CollectionWithId<Network>) -> TicketingDe
networks
.values()
.filter_map(|n| n.fare_url.clone())
.collect::<HashSet<_>>()
.collect::<BTreeSet<_>>()
.iter()
.enumerate()
.map(|(i, fare_url)| {
Expand Down

0 comments on commit ef48695

Please sign in to comment.