Skip to content

Commit

Permalink
test: create_calendar raises if required columns not present
Browse files Browse the repository at this point in the history
  • Loading branch information
r-leyshon committed Jan 18, 2024
1 parent 8895d20 commit 20d5eee
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/gtfs/test_calendar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Test calendar utilities."""
import pytest

import pandas as pd

from transport_performance.gtfs.calendar import create_calendar_from_dates


class TestCreateCalendarFromDates(object):
"""Tests for create_calendar_from_dates."""

def test_create_calendar_from_dates_defence(self):
"""Test defensive checks for create_calendar_from_dates."""
with pytest.raises(TypeError, match=".DataFrame'>. Got <class 'int'>"):
create_calendar_from_dates(calendar_dates=1)
with pytest.raises(
IndexError, match="service_id' is not a column in the dataframe."
):
create_calendar_from_dates(
calendar_dates=pd.DataFrame({"foo": 0}, index=[0])
)

0 comments on commit 20d5eee

Please sign in to comment.