From 12e4cf5a9c120eeed62257a4648f40d67ffa8681 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Sun, 12 May 2024 22:34:04 +0200 Subject: [PATCH 1/9] update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b51ddcc..8d7750d 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ For our Python libraries to understand the interface specified by the GTFS-realt virtualenv ~/.env/gtfs-realtime-bindings source ~/.env/gtfs-realtime-bindings/bin/activate pip install grpcio-tools +python3 -m grpc_tools.protoc -I gtfs_realtime_translators/bindings/ --python_out=gtfs_realtime_translators/bindings/ gtfs_realtime_translators/bindings/gtfs-realtime.proto python3 -m grpc_tools.protoc -I gtfs_realtime_translators/bindings/ --python_out=gtfs_realtime_translators/bindings/ gtfs_realtime_translators/bindings/intersection.proto ``` Since we are using the published spec bindings, we must do one more step. Inside the generated file, `gtfs_realtime_translators/bindings/intersection_pb2.py`, change the following line From 522acf0bafc2348c9c1d2920f4d0e5b08de3ddb1 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Thu, 21 Mar 2024 09:30:35 +0100 Subject: [PATCH 2/9] fix: harmonize license to Apache-2.0 --- gtfs_realtime_translators/__version__.py | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gtfs_realtime_translators/__version__.py b/gtfs_realtime_translators/__version__.py index 1a72d32..513df70 100644 --- a/gtfs_realtime_translators/__version__.py +++ b/gtfs_realtime_translators/__version__.py @@ -1 +1,2 @@ __version__ = '1.1.0' +__license__ = "Apache-2.0" diff --git a/setup.py b/setup.py index 5050699..613dbaa 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,6 @@ f'{PACKAGE_ROOT}.bindings', f'{PACKAGE_ROOT}.validators', ], - license='MIT license', + license=about['__license__'], install_requires=requirements, ) From 667d16bed6f87e03153523fa354a20b8e790c16b Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Sun, 17 Mar 2024 17:41:43 +0100 Subject: [PATCH 3/9] fix: adapt test to reflect commit 474d536 --- test/test_wcdot_bus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_wcdot_bus.py b/test/test_wcdot_bus.py index a98c1b5..c38d2bf 100644 --- a/test/test_wcdot_bus.py +++ b/test/test_wcdot_bus.py @@ -20,7 +20,7 @@ def test_wcdot_data(wcdot_bus): assert trip_update.trip.trip_id == '8612' assert stop_time_update.arrival.delay == -60 assert stop_time_update.departure.delay == -60 - assert trip_update.trip.route_id == "0066" + assert trip_update.trip.route_id == "66" assert entity.id == "130" assert stop_time_update.stop_id == "5142" From a50d664b5b999abc2f4381b6ff8dfe6c5809f05d Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Thu, 21 Mar 2024 08:39:18 +0100 Subject: [PATCH 4/9] fix: adapt fixture to reflect commit 3a7e129 --- test/fixtures/septa_regional_rail.json | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/fixtures/septa_regional_rail.json b/test/fixtures/septa_regional_rail.json index 885cadf..900ff49 100644 --- a/test/fixtures/septa_regional_rail.json +++ b/test/fixtures/septa_regional_rail.json @@ -42,7 +42,7 @@ "train_id": "3420", "origin": "Secane", "destination": "Warminster", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "1 min", "service_type": "LOCAL", "next_station": "Secane", @@ -195,7 +195,7 @@ "train_id": "3596", "origin": "Elwyn Station", "destination": "Doylestown", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "EXP TO FT WASH", "next_station": null, @@ -416,7 +416,7 @@ "train_id": "3448", "origin": "Elwyn Station", "destination": "Warminster", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "EXP TO JENKINTOWN", "next_station": null, @@ -569,7 +569,7 @@ "train_id": "380", "origin": "Elwyn Station", "destination": "West Trenton", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "LOCAL", "next_station": null, @@ -739,7 +739,7 @@ "train_id": "384", "origin": "Elwyn Station", "destination": "West Trenton", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "LOCAL", "next_station": null, @@ -977,7 +977,7 @@ "train_id": "1386", "origin": "Elwyn Station", "destination": "Suburban Sta", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "LOCAL", "next_station": null, @@ -1113,7 +1113,7 @@ "train_id": "388", "origin": "Elwyn Station", "destination": "West Trenton", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "LOCAL", "next_station": null, @@ -1300,7 +1300,7 @@ "train_id": "390", "origin": "Elwyn Station", "destination": "West Trenton", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "LOCAL", "next_station": null, @@ -1436,7 +1436,7 @@ "train_id": "392", "origin": "Elwyn Station", "destination": "West Trenton", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "LOCAL", "next_station": null, @@ -1572,7 +1572,7 @@ "train_id": "394", "origin": "Elwyn Station", "destination": "West Trenton", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "LOCAL", "next_station": null, @@ -1674,7 +1674,7 @@ "train_id": "396", "origin": "Elwyn Station", "destination": "West Trenton", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "LOCAL", "next_station": null, @@ -1793,7 +1793,7 @@ "train_id": "398", "origin": "Elwyn Station", "destination": "West Trenton", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "LOCAL", "next_station": null, @@ -1950,7 +1950,7 @@ "train_id": "6311", "origin": "Jefferson Station", "destination": "30th St", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "1 min", "service_type": "LOCAL", "next_station": "Jefferson", @@ -2035,7 +2035,7 @@ "train_id": "9355", "origin": "Temple U", "destination": "Elwyn", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "LOCAL", "next_station": null, @@ -2256,7 +2256,7 @@ "train_id": "9359", "origin": "Temple U", "destination": "Elwyn", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "LOCAL", "next_station": null, @@ -2409,7 +2409,7 @@ "train_id": "7363", "origin": "Temple U", "destination": "Elwyn", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "EXP TO PRIMOS", "next_station": null, @@ -2613,7 +2613,7 @@ "train_id": "9365", "origin": "Temple U", "destination": "Elwyn", - "line": "Media/Elwyn", + "line": "Media/Wawa", "status": "On Time", "service_type": "EXP TO PRIMOS", "next_station": null, From 040de5916af98e8c24831c561621614d93a306c8 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Thu, 21 Mar 2024 08:40:20 +0100 Subject: [PATCH 5/9] fix: fix testcase --- test/test_cta_bus.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/test_cta_bus.py b/test/test_cta_bus.py index 6ac15ed..8c64a47 100644 --- a/test/test_cta_bus.py +++ b/test/test_cta_bus.py @@ -32,9 +32,7 @@ def test_cta_bus_realtime_arrival(cta_bus): # Test Intersection extensions intersection_trip_update = trip_update.Extensions[intersection_gtfs_realtime.intersection_trip_update] assert intersection_trip_update.headsign == 'Howard Station' - - intersection_stop_time_update = stop_time_update.Extensions[intersection_gtfs_realtime.intersection_stop_time_update] - assert intersection_stop_time_update.scheduled_arrival.time == 0 + assert intersection_trip_update.custom_status == '3 min' def test_cta_bus_scheduled_departure(cta_bus): translator = CtaBusGtfsRealtimeTranslator() @@ -46,8 +44,9 @@ def test_cta_bus_scheduled_departure(cta_bus): stop_time_update = trip_update.stop_time_update[0] assert entity.id == '2' - assert stop_time_update.arrival.time == 0 + assert stop_time_update.arrival.time == 1570531500 # Test Intersection extensions - intersection_stop_time_update = stop_time_update.Extensions[intersection_gtfs_realtime.intersection_stop_time_update] - assert intersection_stop_time_update.scheduled_arrival.time == 1570531500 + intersection_trip_update = trip_update.Extensions[intersection_gtfs_realtime.intersection_trip_update] + assert intersection_trip_update.custom_status == '10 min' + From b516f6bb148367aa181c1b64d16e8b2d6e4d5db7 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Thu, 21 Mar 2024 08:43:33 +0100 Subject: [PATCH 6/9] fix: adapt test to reflect commit 6576540 --- test/test_njt_rail.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_njt_rail.py b/test/test_njt_rail.py index 72e84df..68fd84e 100644 --- a/test/test_njt_rail.py +++ b/test/test_njt_rail.py @@ -24,7 +24,7 @@ def test_njt_data(njt_rail): assert entity.id == '7' assert trip_update.trip.trip_id == '' - assert trip_update.trip.route_id == '9' + assert trip_update.trip.route_id == '10' assert stop_time_update.stop_id == 'NP' assert stop_time_update.departure.time == 1570045710 @@ -69,8 +69,8 @@ def test_njt_data_amtrak(njt_rail): assert intersection_trip_update.headsign == 'Boston' assert intersection_trip_update.route_short_name == 'AMTRAK' assert intersection_trip_update.route_long_name == 'Amtrak' - assert intersection_trip_update.route_color == 'yellow' - assert intersection_trip_update.route_text_color == 'black' + assert intersection_trip_update.route_color == '#FFFF00' + assert intersection_trip_update.route_text_color == '#000000' assert intersection_trip_update.block_id == 'A176' assert intersection_trip_update.agency_timezone == 'America/New_York' assert intersection_trip_update.custom_status == 'All Aboard' @@ -98,8 +98,8 @@ def test_njt_data_amtrak(njt_rail): assert intersection_trip_update.headsign == 'Washington' assert intersection_trip_update.route_short_name == 'ACELA EXPRESS' assert intersection_trip_update.route_long_name == 'Amtrak Acela Express' - assert intersection_trip_update.route_color == 'yellow' - assert intersection_trip_update.route_text_color == 'black' + assert intersection_trip_update.route_color == '#FFFF00' + assert intersection_trip_update.route_text_color == '#000000' assert intersection_trip_update.block_id == 'A2165' assert intersection_trip_update.agency_timezone == 'America/New_York' assert intersection_trip_update.custom_status == '' From 395ce593109cc134180dca0fb05a8df150872662 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Thu, 21 Mar 2024 08:51:03 +0100 Subject: [PATCH 7/9] fix: adapt fixture to reflect commit b1197bb --- test/fixtures/cta_subway.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/fixtures/cta_subway.json b/test/fixtures/cta_subway.json index 48415f2..8577236 100644 --- a/test/fixtures/cta_subway.json +++ b/test/fixtures/cta_subway.json @@ -18,6 +18,7 @@ "arrT": "2019-10-07T14:30:02", "isApp": "1", "isSch": "0", + "schInt": "0", "isDly": "0", "isFlt": "0", "flags": null, @@ -39,6 +40,7 @@ "arrT": "2019-10-07T14:32:56", "isApp": "0", "isSch": "1", + "schInt": "1", "isDly": "0", "isFlt": "0", "flags": null, From dd08855697f6938156e6c7b6b1ec41db427e6d2b Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Sun, 17 Mar 2024 17:38:11 +0100 Subject: [PATCH 8/9] bump python and dependency versions --- .travis.yml | 3 +-- requirements.txt | 6 +++--- setup.py | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index b985dde..ee817a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ dist: xenial language: python python: - - "3.6" - - "3.7" + - "3.11" # command to install dependencies install: - pip install -r requirements.txt diff --git a/requirements.txt b/requirements.txt index 4647fd4..a3e346b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -gtfs-realtime-bindings==0.0.5 pendulum==2.0.5 -pytest==5.2.2 -xmltodict==0.12.0 +gtfs-realtime-bindings==1.0.0 +pytest==6.2.5 +xmltodict==0.13.0 diff --git a/setup.py b/setup.py index 613dbaa..daa90a7 100644 --- a/setup.py +++ b/setup.py @@ -12,9 +12,9 @@ exec(f.read(), about) requirements = [ - 'gtfs-realtime-bindings==0.0.5', 'pendulum==2.0.5', - 'xmltodict==0.12.0', + 'gtfs-realtime-bindings==1.0.0', + 'xmltodict==0.13.0', ] setup( From d7c875ae234fdfc68063c3940b517c50b4a0dfc4 Mon Sep 17 00:00:00 2001 From: Holger Bruch Date: Sun, 17 Mar 2024 17:39:52 +0100 Subject: [PATCH 9/9] bump pendulum to v3.0.0 --- requirements.txt | 2 +- setup.py | 2 +- test/test_cta_bus.py | 4 ++-- test/test_cta_subway.py | 4 ++-- test/test_la_metro.py | 4 ++-- test/test_mta_subway.py | 2 +- test/test_path_new.py | 2 +- test/test_path_rail.py | 2 +- test/test_septa.py | 2 +- test/test_septa_regional_rail.py | 6 +++--- test/test_vta.py | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/requirements.txt b/requirements.txt index a3e346b..79a3751 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -pendulum==2.0.5 gtfs-realtime-bindings==1.0.0 +pendulum==3.0.0 pytest==6.2.5 xmltodict==0.13.0 diff --git a/setup.py b/setup.py index daa90a7..252f823 100644 --- a/setup.py +++ b/setup.py @@ -12,8 +12,8 @@ exec(f.read(), about) requirements = [ - 'pendulum==2.0.5', 'gtfs-realtime-bindings==1.0.0', + 'pendulum==3.0.0', 'xmltodict==0.13.0', ] diff --git a/test/test_cta_bus.py b/test/test_cta_bus.py index 8c64a47..c6af25e 100644 --- a/test/test_cta_bus.py +++ b/test/test_cta_bus.py @@ -15,7 +15,7 @@ def cta_bus(): def test_cta_bus_realtime_arrival(cta_bus): translator = CtaBusGtfsRealtimeTranslator() - with pendulum.test(pendulum.datetime(2019, 2, 20, 17)): + with pendulum.travel_to(pendulum.datetime(2019, 2, 20, 17)): message = translator(cta_bus) entity = message.entity[0] @@ -36,7 +36,7 @@ def test_cta_bus_realtime_arrival(cta_bus): def test_cta_bus_scheduled_departure(cta_bus): translator = CtaBusGtfsRealtimeTranslator() - with pendulum.test(pendulum.datetime(2019, 2, 20, 17)): + with pendulum.travel_to(pendulum.datetime(2019, 2, 20, 17)): message = translator(cta_bus) entity = message.entity[1] diff --git a/test/test_cta_subway.py b/test/test_cta_subway.py index 0629a3a..a2d4fdf 100644 --- a/test/test_cta_subway.py +++ b/test/test_cta_subway.py @@ -16,7 +16,7 @@ def cta_subway(): def test_cta_subway_realtime_arrival(cta_subway): translator = CtaSubwayGtfsRealtimeTranslator() - with pendulum.test(pendulum.datetime(2019, 2, 20, 17)): + with pendulum.travel_to(pendulum.datetime(2019, 2, 20, 17)): message = translator(cta_subway) entity = message.entity[0] @@ -39,7 +39,7 @@ def test_cta_subway_realtime_arrival(cta_subway): def test_cta_subway_scheduled_arrival(cta_subway): translator = CtaSubwayGtfsRealtimeTranslator() - with pendulum.test(pendulum.datetime(2019, 2, 20, 17)): + with pendulum.travel_to(pendulum.datetime(2019, 2, 20, 17)): message = translator(cta_subway) entity = message.entity[1] diff --git a/test/test_la_metro.py b/test/test_la_metro.py index c8e828d..c71c622 100644 --- a/test/test_la_metro.py +++ b/test/test_la_metro.py @@ -15,7 +15,7 @@ def la_metro_rail(): def test_la_data(la_metro_rail): translator = LaMetroGtfsRealtimeTranslator(stop_id='80122') - with pendulum.test(pendulum.datetime(2019,2,20,17,0,0)): + with pendulum.travel_to(pendulum.datetime(2019,2,20,17,0,0)): message = translator(la_metro_rail) entity = message.entity[0] @@ -36,7 +36,7 @@ def test_la_data(la_metro_rail): def test_la_data_with_floats(la_metro_rail): translator = LaMetroGtfsRealtimeTranslator(stop_id='80122') - with pendulum.test(pendulum.datetime(2019,2,20,17,0,0)): + with pendulum.travel_to(pendulum.datetime(2019,2,20,17,0,0)): message = translator(la_metro_rail) entity = message.entity[1] diff --git a/test/test_mta_subway.py b/test/test_mta_subway.py index 98fedc0..da8afbe 100644 --- a/test/test_mta_subway.py +++ b/test/test_mta_subway.py @@ -16,7 +16,7 @@ def mta_subway(): def test_mta_subway_data(mta_subway): translator = MtaSubwayGtfsRealtimeTranslator() - with pendulum.test(pendulum.datetime(2019,2,20,17,0,0)): + with pendulum.travel_to(pendulum.datetime(2019,2,20,17,0,0)): message = translator(mta_subway) entity = message.entity[0] diff --git a/test/test_path_new.py b/test/test_path_new.py index d7683fe..ca1674a 100644 --- a/test/test_path_new.py +++ b/test/test_path_new.py @@ -15,7 +15,7 @@ def path_new(): def test_path_data(path_new): translator = PathNewGtfsRealtimeTranslator() - with pendulum.test(pendulum.datetime(2020, 2, 22, 12, 0, 0)): + with pendulum.travel_to(pendulum.datetime(2020, 2, 22, 12, 0, 0)): message = translator(path_new) assert message.header.gtfs_realtime_version == FeedMessage.VERSION entity = message.entity[0] diff --git a/test/test_path_rail.py b/test/test_path_rail.py index 9cf27df..0ff3b06 100644 --- a/test/test_path_rail.py +++ b/test/test_path_rail.py @@ -14,7 +14,7 @@ def path_rail(): def test_path_data(path_rail): translator = PathGtfsRealtimeTranslator() - with pendulum.test(pendulum.datetime(2020, 2, 22, 12, 0, 0)): + with pendulum.travel_to(pendulum.datetime(2020, 2, 22, 12, 0, 0)): message = translator(path_rail) assert message.header.gtfs_realtime_version == FeedMessage.VERSION diff --git a/test/test_septa.py b/test/test_septa.py index 6e1eb62..cc72df9 100644 --- a/test/test_septa.py +++ b/test/test_septa.py @@ -16,7 +16,7 @@ def septa_trolley_lines(): def test_septa_trolley_data(septa_trolley_lines): translator = SwiftlyGtfsRealtimeTranslator(stop_id='20646') - with pendulum.test(pendulum.datetime(2021,6,16,12,0,0)): + with pendulum.travel_to(pendulum.datetime(2021,6,16,12,0,0)): message = translator(septa_trolley_lines) # check first entity diff --git a/test/test_septa_regional_rail.py b/test/test_septa_regional_rail.py index b4e6229..b716b5d 100644 --- a/test/test_septa_regional_rail.py +++ b/test/test_septa_regional_rail.py @@ -15,7 +15,7 @@ def septa_regional_rail(): def test_septa_regional_rail(septa_regional_rail): - with pendulum.test(pendulum.datetime(2019,4,26,15,0,0, tz='America/New_York')): + with pendulum.travel_to(pendulum.datetime(2019,4,26,15,0,0, tz='America/New_York')): translator = SeptaRegionalRailTranslator(stop_id='90004', filter_seconds=7200) message = translator(septa_regional_rail) @@ -39,7 +39,7 @@ def test_septa_regional_rail(septa_regional_rail): def test_septa_regional_rail_with_delay(septa_regional_rail): - with pendulum.test(pendulum.datetime(2019,4,26,15,0,0, tz='America/New_York')): + with pendulum.travel_to(pendulum.datetime(2019,4,26,15,0,0, tz='America/New_York')): translator = SeptaRegionalRailTranslator(stop_id='90004', filter_seconds=7200) message = translator(septa_regional_rail) @@ -98,5 +98,5 @@ def test_calculate_realtime(): def test_time_at(): - with pendulum.test(pendulum.datetime(2019,3,8,12,0,0)): + with pendulum.travel_to(pendulum.datetime(2019,3,8,12,0,0)): assert SeptaRegionalRailTranslator.calculate_time_at(seconds=1) == int(pendulum.datetime(2019,3,8,12,0,1).timestamp()) diff --git a/test/test_vta.py b/test/test_vta.py index a52becc..5da0d02 100644 --- a/test/test_vta.py +++ b/test/test_vta.py @@ -16,7 +16,7 @@ def vta_rail(): def test_vta_data(vta_rail): translator = SwiftlyGtfsRealtimeTranslator(stop_id='5236') - with pendulum.test(pendulum.datetime(2019,2,20,17,0,0)): + with pendulum.travel_to(pendulum.datetime(2019,2,20,17,0,0)): message = translator(vta_rail) entity = message.entity[0]