Skip to content

Commit

Permalink
Merge pull request #332 from conveyal/dev
Browse files Browse the repository at this point in the history
Fix release Sept 30, 2021
  • Loading branch information
binh-dam-ibigroup authored Sep 30, 2021
2 parents 7fca642 + 5ccb9f3 commit d40d0b3
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Set<NewGTFSError> check(
);
if (lineContext.table.name.equals(referenceTableName) &&
!POSTGRES_NULL_TEXT.equals(referenceFieldValue) &&
!uniqueValuesForFields.get(dependentFieldName).contains(foreignFieldReference)
!uniqueValuesForFields.get(dependentFieldName).contains(referenceFieldValue)
) {
errors.add(
NewGTFSError.forLine(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public class ConditionallyRequiredTest {
private static DataSource triDeltaDataSource;
private static String triDeltaNamespace;

private static String caltrainDBName;
private static DataSource caltrainDataSource;
private static String caltrainNamespace;

@BeforeAll
public static void setUpClass() throws IOException {
VTADBName = TestUtils.generateNewDB();
Expand All @@ -38,6 +42,10 @@ public static void setUpClass() throws IOException {
triDeltaDBName = TestUtils.generateNewDB();
triDeltaDataSource = TestUtils.createTestDataSource(String.format("jdbc:postgresql://localhost/%s", triDeltaDBName));
triDeltaNamespace = loadFeedAndValidate(triDeltaDataSource, "real-world-gtfs-feeds/tri-delta-fare-rules");

caltrainDBName = TestUtils.generateNewDB();
caltrainDataSource = TestUtils.createTestDataSource(String.format("jdbc:postgresql://localhost/%s", caltrainDBName));
caltrainNamespace = loadFeedAndValidate(caltrainDataSource, "real-world-gtfs-feeds/caltrain-fare-zones");
}

/**
Expand All @@ -56,6 +64,7 @@ private static String loadFeedAndValidate(DataSource dataSource, String zipFolde
public static void tearDownClass() {
TestUtils.dropDB(VTADBName);
TestUtils.dropDB(triDeltaDBName);
TestUtils.dropDB(caltrainDBName);
}

@Test
Expand Down Expand Up @@ -152,6 +161,25 @@ void shouldNotTriggerRefIntegrityErrorForMissingOptionalColumn() {
);
}

/**
* Valid foreign key references should not trigger referential integrity errors
* (e.g. if the "origin_id" or "destination_id" column from the "fare_rules" table
* actually point to a value referenced in the "stops" table).
*/
@Test
void shouldNotTriggerRefIntegrityErrorForValidForeignReferences() {
checkFeedHasExpectedNumberOfErrors(
caltrainNamespace,
caltrainDataSource,
REFERENTIAL_INTEGRITY,
"FareRule",
"2",
"3526",
null,
0
);
}

@Test
void routeTableMissingConditionallyRequiredAgencyId() {
checkFeedHasOneError(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
agency_id,agency_url,agency_lang,agency_name,agency_phone,agency_timezone,agency_fare_url
1000,http://www.caltrain.com,en,Caltrain,800-660-4287,America/Los_Angeles,
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
service_id,service_name,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date
c_21817_b_30633_d_96,Year Round starting 8/30/21 (Weekend),0,0,0,0,0,1,1,20210830,20220701
c_21817_b_30633_d_31,Year Round starting 8/30/21 (Weekday),1,1,1,1,1,0,0,20210830,20220701
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
agency_id,fare_id,price,currency_type,payment_method,transfers,transfer_duration
1000,3526,6.00,USD,1,,14400
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fare_id,route_id,origin_id,destination_id,contains_id
3526,,2272,2273,
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feed_publisher_url,feed_publisher_name,feed_lang,feed_version,feed_license,feed_contact_email,feed_contact_url,feed_start_date,feed_end_date,feed_id
http://www.trilliumtransit.com,"Trillium Solutions, Inc.",en,UTC: 31-Aug-2021 18:17,,[email protected],http://support.trilliumtransit.com,20210831,20220101,caltrain-ca-us
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
agency_id,route_id,route_short_name,route_long_name,route_desc,route_type,route_url,route_color,route_text_color,route_sort_order,min_headway_minutes,eligibility_restricted,continuous_pickup,continuous_drop_off
1000,19599,L3,LTD 3,,2,,fcedc7,000000,2,,0,1,1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
shape_id,shape_pt_lat,shape_pt_lon,shape_pt_sequence,shape_dist_traveled
p_1277282,37.003512297983,-121.566145420074,1,0
p_1277282,37.77639,-122.394992,467,123619.60803258
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
trip_id,arrival_time,departure_time,stop_id,stop_sequence,stop_headsign,pickup_type,drop_off_type,shape_dist_traveled,timepoint,start_service_area_id,end_service_area_id,start_service_area_radius,end_service_area_radius,continuous_pickup,continuous_drop_off,pickup_booking_rule_id,drop_off_booking_rule_id,start_pickup_dropoff_window,end_pickup_dropoff_window,mean_duration_factor,mean_duration_offset,safe_duration_factor,safe_duration_offset
303,07:07:00,07:07:00,70281,1,,0,0,40330.9714799222,1,,,,,1,1,,,,,,,,
303,07:23:00,07:23:00,70261,2,,0,0,48219.5593911282,1,,,,,1,1,,,,,,,,
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
stop_id,stop_code,platform_code,stop_name,stop_desc,stop_lat,stop_lon,zone_id,stop_url,location_type,parent_station,stop_timezone,position,direction,wheelchair_boarding
70261,70261,,San Jose Diridon Caltrain,,37.329239,-121.903011,2272,,0,,America/Los_Angeles,,,1
70281,70281,,Capitol Caltrain,,37.284102,-121.841955,2273,,0,,America/Los_Angeles,,,1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
route_id,service_id,trip_id,trip_short_name,trip_headsign,direction_id,block_id,shape_id,bikes_allowed,wheelchair_accessible,trip_type,drt_max_travel_time,drt_avg_travel_time,drt_advance_book_min,drt_pickup_message,drt_drop_off_message,continuous_pickup_message,continuous_drop_off_message
19599,c_21817_b_30633_d_31,303,303,San Francisco,0,,p_1277282,,,,,,,,,,

0 comments on commit d40d0b3

Please sign in to comment.