Skip to content

Commit

Permalink
Merge branch 'fork' into de-vvs-alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
hbruch authored Nov 21, 2024
2 parents 236d0c3 + d7c875a commit b70a7a6
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 53 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions gtfs_realtime_translators/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__version__ = '1.1.0'
__license__ = "Apache-2.0"
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
gtfs-realtime-bindings==0.0.5
pendulum==2.0.5
pytest==5.2.2
xmltodict==0.12.0
gtfs-realtime-bindings==1.0.0
pendulum==3.0.0
pytest==6.2.5
xmltodict==0.13.0
beautifulsoup4==4.12.3
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
'pendulum==3.0.0',
'xmltodict==0.13.0',
]

setup(
Expand All @@ -33,6 +33,6 @@
f'{PACKAGE_ROOT}.bindings',
f'{PACKAGE_ROOT}.validators',
],
license='MIT license',
license=about['__license__'],
install_requires=requirements,
)
2 changes: 2 additions & 0 deletions test/fixtures/cta_subway.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"arrT": "2019-10-07T14:30:02",
"isApp": "1",
"isSch": "0",
"schInt": "0",
"isDly": "0",
"isFlt": "0",
"flags": null,
Expand All @@ -39,6 +40,7 @@
"arrT": "2019-10-07T14:32:56",
"isApp": "0",
"isSch": "1",
"schInt": "1",
"isDly": "0",
"isFlt": "0",
"flags": null,
Expand Down
34 changes: 17 additions & 17 deletions test/fixtures/septa_regional_rail.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 7 additions & 8 deletions test/test_cta_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -32,22 +32,21 @@ 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()
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]
trip_update = entity.trip_update
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'

4 changes: 2 additions & 2 deletions test/test_cta_subway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions test/test_la_metro.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion test/test_mta_subway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 5 additions & 5 deletions test/test_njt_rail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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 == ''
Expand Down
2 changes: 1 addition & 1 deletion test/test_path_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion test/test_path_rail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_septa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/test_septa_regional_rail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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())
2 changes: 1 addition & 1 deletion test/test_vta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading

0 comments on commit b70a7a6

Please sign in to comment.