Skip to content

Commit

Permalink
Merge pull request #7 from remix/fix-raw-feed-date-resolution
Browse files Browse the repository at this point in the history
Account for calendar days of week w/o service for raw_feed
  • Loading branch information
invisiblefunnel authored Oct 12, 2017
2 parents 5e11684 + 07bb5c0 commit 4c1e2bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion partridge/gtfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def service_ids_by_date(self):
dow = {i: cal[day] for i, day in enumerate(DAY_NAMES)}
for ordinal in range(start, end + 1):
date = datetime.date.fromordinal(ordinal)
if dow[date.weekday()]:
if int(dow[date.weekday()]):
results[date].add(cal.service_id)

# Process calendar_dates.txt if it exists
Expand Down
6 changes: 6 additions & 0 deletions tests/test_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ def test_service_ids_by_date():

service_ids_by_date = ptg.read_service_ids_by_date(path)
feed = ptg.feed(path)
raw_feed = ptg.raw_feed(path)

assert service_ids_by_date == feed.service_ids_by_date
assert service_ids_by_date == raw_feed.service_ids_by_date

assert service_ids_by_date == {
datetime.date(2017, 8, 1): frozenset({'1', '0'}),
Expand All @@ -176,8 +178,10 @@ def test_dates_by_service_ids():

dates_by_service_ids = ptg.read_dates_by_service_ids(path)
feed = ptg.feed(path)
raw_feed = ptg.raw_feed(path)

assert dates_by_service_ids == feed.dates_by_service_ids
assert dates_by_service_ids == raw_feed.dates_by_service_ids

assert dates_by_service_ids == {
frozenset({'1'}): {
Expand All @@ -198,8 +202,10 @@ def test_trip_counts_by_date():

trip_counts_by_date = ptg.read_trip_counts_by_date(path)
feed = ptg.feed(path)
raw_feed = ptg.raw_feed(path)

assert trip_counts_by_date == feed.trip_counts_by_date
assert trip_counts_by_date == raw_feed.trip_counts_by_date

assert trip_counts_by_date == {
datetime.date(2017, 8, 1): 442,
Expand Down

0 comments on commit 4c1e2bb

Please sign in to comment.