-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: create_calendar raises if required columns not present
- Loading branch information
r-leyshon
committed
Jan 18, 2024
1 parent
8895d20
commit 20d5eee
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
) |