Skip to content

Commit

Permalink
TRAN-5264: SEPTA: Trolley translator
Browse files Browse the repository at this point in the history
Removing stop id from constructor as it is available in feed.
  • Loading branch information
Piyush Govani committed Jun 25, 2021
1 parent f62e495 commit 9b6fc43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions gtfs_realtime_translators/translators/septa_trolley_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@


class SeptaTrolleyLineTranslator:
def __init__(self, stop_id=None):
if stop_id is None:
raise ValueError('stop_id is required.')

self.stop_id = stop_id

def __call__(self, data):
json_data = json.loads(data)
entities = []
for data in json_data["data"]["predictionsData"]:
trip_updates = self.__make_trip_updates(data, self.stop_id)
stop_id = data.get("stopId", None)
if stop_id is None:
raise ValueError('stop_id is required.')

trip_updates = self.__make_trip_updates(data, stop_id)
entities.extend(trip_updates)

return FeedMessage.create(entities=entities)
Expand Down
2 changes: 1 addition & 1 deletion test/test_septa_trolley_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def septa_trolley_lines():


def test_septa_trolley_data(septa_trolley_lines):
translator = SeptaTrolleyLineTranslator(stop_id='20646')
translator = SeptaTrolleyLineTranslator()
with pendulum.test(pendulum.datetime(2021,6,16,12,0,0)):
message = translator(septa_trolley_lines)

Expand Down

0 comments on commit 9b6fc43

Please sign in to comment.