Skip to content

Commit

Permalink
Assert that all transit legs have fares
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Oct 6, 2023
1 parent 443f084 commit c11bb68
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
3 changes: 1 addition & 2 deletions smoke-tests/denver/router-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
{
"type": "vehicle-positions",
"url": "https://www.rtd-denver.com/files/gtfs-rt/VehiclePosition.pb",
"feedId": "denver",
"frequencySec": 60
"feedId": "denver"
}
]
}
1 change: 0 additions & 1 deletion smoke-tests/portland/otp-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"otpFeatures" : {
"SandboxAPILegacyGraphQLApi": true
}
}
5 changes: 2 additions & 3 deletions smoke-tests/portland/router-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
"updaters": [
{
"type": "real-time-alerts",
"frequencySec": 60,
"earlyStartSec": 864000,
"url": "https://trimet.org/transweb/ws/V1/FeedSpecAlerts/includeFuture/true/suppressSystemWideAlerts/true/",
"feedId": "TriMet"
},
{
"type": "stop-time-updater",
"frequencySec": 30,
"frequency": "30s",
"url": "https://trimet.org/transweb/ws/V1/TripUpdate",
"feedId": "TriMet"
},
{
"type": "vehicle-rental",
"frequencySec": 90,
"frequency": "90s",
"sourceType": "gbfs",
"url": "https://mds.bird.co/gbfs/v2/public/portland/gbfs.json",
"geofencingZones": "true"
Expand Down
1 change: 0 additions & 1 deletion smoke-tests/septa/otp-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"otpFeatures" : {
"SandboxAPILegacyGraphQLApi": true
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.opentripplanner.smoketest;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.opentripplanner.client.model.RequestMode.BICYCLE;
import static org.opentripplanner.client.model.RequestMode.BUS;
import static org.opentripplanner.client.model.RequestMode.TRANSIT;
Expand Down Expand Up @@ -27,10 +28,12 @@ public class HoustonSmokeTest {
@Test
public void routeFromSouthToNorth() {
var modes = Set.of(TRANSIT, WALK);
SmokeTest.basicRouteTest(
var plan = SmokeTest.basicRouteTest(
new SmokeTestRequest(galvestonRoad, northLindale, modes),
List.of("WALK", "BUS", "BUS", "WALK", "TRAM", "WALK")
);

SmokeTest.assertThatAllTransitLegsHaveFares(plan);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ public class PortlandSmokeTest {
public void railTrip() {
// this used to be across the city by since the train is interrupted in April '23 this is a
// much shorter trip
SmokeTest.basicRouteTest(
var plan = SmokeTest.basicRouteTest(
new SmokeTestRequest(cennentenial, hazelwood, Set.of(TRAM, WALK)),
List.of("WALK", "TRAM", "WALK")
);

SmokeTest.assertThatAllTransitLegsHaveFares(plan);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/org/opentripplanner/smoketest/SmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ static void assertThereArePatternsWithVehiclePositions() {
}
}

static void assertThatAllTransitLegsHaveFares(TripPlan plan) {
var transitLegs = plan.transitItineraries().stream().flatMap(i-> i.transitLegs().stream());
transitLegs.forEach(leg -> assertFalse(leg.fareProducts().isEmpty()));
}

/**
* The Fare class is a little hard to deserialize, so we have a custom deserializer as we don't
* run any assertions against the fares. (That is done during unit tests.)
Expand Down

0 comments on commit c11bb68

Please sign in to comment.