Skip to content

Commit

Permalink
stop_schedule: Add headsign and trip_short_name on display informations
Browse files Browse the repository at this point in the history
  • Loading branch information
datanel committed Oct 10, 2024
1 parent acbed14 commit e1f933f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
22 changes: 22 additions & 0 deletions source/jormungandr/tests/departure_board_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,28 @@ def test_display_informations_in_routes_schedule(self):
assert display_information_route['name'] == 'line:A'
assert display_information_route['code'] == 'A'

def test_display_informations_in_stop_schedule(self):
"""
verify some attributs in display_informations of a stop_schedule
"""
response = self.query_region(
"stop_areas/stop1/stop_schedules?from_datetime=20120615T080000&disable_geojson=true"
)
schedules = get_not_null(response, 'stop_schedules')
assert len(schedules) == 1, "there should be only one elt"
schedule = schedules[0]
is_valid_stop_schedule(response["stop_schedules"], self.tester, only_time=False)

display_information_route = get_not_null(schedule, 'display_informations')
assert display_information_route['direction'] == 'stop2'
assert display_information_route['label'] == 'A'
assert display_information_route['color'] == '289728'
assert display_information_route['text_color'] == 'FFD700'
assert display_information_route['name'] == 'line:A'
assert display_information_route['code'] == 'A'
assert display_information_route['headsign'] == 'week'
assert display_information_route['trip_short_name'] == 'week'

def test_terminus_schedules(self):
"""
terminus_schedules for a given date
Expand Down
8 changes: 8 additions & 0 deletions source/time_tables/departure_boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,16 @@ static void render(PbCreator& pb_creator,
auto pt_display_information = schedule->mutable_pt_display_informations();
pb_creator.fill(route, pt_display_information, 0);

bool vj_found = false;

// Now we fill the date_times
for (auto dt_st : id_vec.second) {
if (!vj_found && dt_st.second != nullptr) {
auto vj = dt_st.second->vehicle_journey;
pt_display_information->set_trip_short_name(vj->name);
pt_display_information->set_headsign(pb_creator.data->pt_data->headsign_handler.get_headsign(vj));
vj_found = true;
}
fill_date_times(pb_creator, schedule, dt_st, calendar_id);
}

Expand Down
2 changes: 2 additions & 0 deletions source/time_tables/tests/departure_boards_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ BOOST_AUTO_TEST_CASE(departureboard_test1) {
BOOST_REQUIRE_EQUAL(resp.stop_schedules_size(), 2);
BOOST_REQUIRE_EQUAL(resp.stop_schedules(0).date_times_size(), 1);
BOOST_REQUIRE_EQUAL(resp.stop_schedules(1).date_times_size(), 1);
BOOST_REQUIRE_EQUAL(resp.stop_schedules(0).pt_display_informations().headsign(), "headsign_vj1");
BOOST_REQUIRE_EQUAL(resp.stop_schedules(0).pt_display_informations().trip_short_name(), "vj1");
}

// comparing terminus_schedule with above stop_schedules (function "departure_board")
Expand Down

0 comments on commit e1f933f

Please sign in to comment.