Skip to content

Commit

Permalink
Add smoke test for accessible routing and accessibilityScore
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Nov 20, 2023
1 parent 5e9d486 commit ae965c9
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
sleep: 15
- name: houston
sleep: 15
- name: denver
sleep: 15
#- name: denver
# sleep: 15
- name: septa
sleep: 15
- name: portland
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@
<dependency>
<groupId>org.opentripplanner</groupId>
<artifactId>otp-client</artifactId>
<version>0.0.20</version>
<version>0.0.23</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
21 changes: 21 additions & 0 deletions smoke-tests/atlanta/router-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"routingDefaults": {
"itineraryFilters": {
// add IBI accessibility score between 0 and 1
"accessibilityScore": true
},
// use stop and trip with unknown wheelchair accessibility during routing
"wheelchairAccessibility": {
"trip": {
"onlyConsiderAccessible": false,
"unknownCost": 600,
"inaccessibleCost": 3600
},
"stop": {
"onlyConsiderAccessible": false,
"unknownCost": 600,
"inaccessibleCost": 3600
}
}
}
}
11 changes: 11 additions & 0 deletions smoke-tests/seattle/build-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,16 @@
"feedId" : "monorail",
"source" : "https://github.com/transitland/gtfs-archives-not-hosted-elsewhere/raw/master/seattlemonorail-wa-us.zip"
}
],
"transferRequests": [
{
"modes": "WALK"
},
{
"modes": "WALK",
"wheelchairAccessibility": {
"enabled": true
}
}
]
}
17 changes: 17 additions & 0 deletions smoke-tests/seattle/router-config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
{
"routingDefaults": {
"itineraryFilters": {
"accessibilityScore": true
},
"wheelchairAccessibility": {
"trip": {
"onlyConsiderAccessible": false,
"unknownCost": 600,
"inaccessibleCost": 3600
},
"stop": {
"onlyConsiderAccessible": false,
"unknownCost": 600,
"inaccessibleCost": 3600
}
}
},
"updaters": [
{
"type": "stop-time-updater",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void routeFromSouthToNorth() {
var modes = Set.of(TRANSIT, WALK);
var plan = SmokeTest.basicRouteTest(
new SmokeTestRequest(galvestonRoad, northLindale, modes),
List.of("WALK", "BUS", "BUS", "WALK", "TRAM", "WALK")
List.of("WALK", "BUS", "WALK", "TRAM", "WALK")
);

SmokeTest.assertThatAllTransitLegsHaveFareProducts(plan);
Expand All @@ -40,7 +40,7 @@ public void selectOnlyBusses() {
var modes = Set.of(BUS, WALK);
var plan = SmokeTest.basicRouteTest(
new SmokeTestRequest(galvestonRoad, northLindale, modes),
List.of("WALK", "BUS", "WALK", "BUS", "WALK", "BUS", "WALK")
List.of("WALK", "BUS", "WALK", "BUS", "WALK")
);

SmokeTest.assertThatAllTransitLegsHaveFareProducts(plan);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.opentripplanner.smoketest;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.opentripplanner.client.model.RequestMode.BUS;
import static org.opentripplanner.client.model.RequestMode.FLEX_ACCESS;
import static org.opentripplanner.client.model.RequestMode.FLEX_DIRECT;
Expand All @@ -18,6 +20,7 @@
import org.opentripplanner.client.model.Coordinate;
import org.opentripplanner.client.model.LegMode;
import org.opentripplanner.client.model.Route;
import org.opentripplanner.client.parameters.TripPlanParametersBuilder;
import org.opentripplanner.smoketest.util.SmokeTestRequest;

@Tag("smoke-test")
Expand All @@ -44,6 +47,29 @@ public void acrossTheCity() {
SmokeTest.assertThatAllTransitLegsHaveFareProducts(plan);
}

@Test
public void accessibleRouting() throws IOException {
var req = new TripPlanParametersBuilder()
.withFrom(sodo)
.withTo(clydeHill)
.withTime(SmokeTest.weekdayAtNoon())
.withWheelchair(true)
.withModes(TRANSIT)
.build();

var tripPlan = SmokeTest.API_CLIENT.plan(req);

assertFalse(tripPlan.transitItineraries().isEmpty());

// assert that accessibility score is there
tripPlan
.itineraries()
.forEach(i -> {
assertTrue(i.accessibilityScore().isPresent());
i.legs().forEach(l -> assertTrue(l.accessibilityScore().isPresent()));
});
}

@Test
public void flexAndTransit() {
var modes = Set.of(WALK, BUS, FLEX_DIRECT, FLEX_EGRESS, FLEX_ACCESS);
Expand Down Expand Up @@ -85,7 +111,7 @@ public void ccswwIntoSnohomishCounty() {

@Test
public void monorailRoute() throws IOException {
Set<Object> modes = SmokeTest.API_CLIENT
var modes = SmokeTest.API_CLIENT
.routes()
.stream()
.map(Route::mode)
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/org/opentripplanner/smoketest/SmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.IOException;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters;
Expand Down Expand Up @@ -46,9 +47,9 @@ public class SmokeTest {
* This is a problem in particular in the case of MARTA as they only publish new data about 2 days
* before the expiration date of the old one.
*/
public static LocalDate nextMonday() {
public static LocalDateTime weekdayAtNoon() {
var today = LocalDate.now();
return today.with(TemporalAdjusters.next(DayOfWeek.FRIDAY));
return today.with(TemporalAdjusters.next(DayOfWeek.TUESDAY)).atTime(LocalTime.of(12, 0));
}

public static void assertThatThereAreVehicleRentalStations() {
Expand Down Expand Up @@ -86,7 +87,7 @@ static TripPlan basicRouteTest(SmokeTestRequest req, List<String> expectedModes)
.withFrom(req.from())
.withTo(req.to())
.withModes(req.modes())
.withTime(SmokeTest.nextMonday().atTime(LocalTime.of(12, 0)))
.withTime(SmokeTest.weekdayAtNoon())
.withSearchDirection(req.searchDirection())
.build();
var plan = API_CLIENT.plan(tpr);
Expand Down

0 comments on commit ae965c9

Please sign in to comment.