-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from justjasongreen/date_utils
Test date_utils (closes #8)
- Loading branch information
Showing
2 changed files
with
49 additions
and
2 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
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,43 @@ | ||
from datetime import datetime | ||
|
||
from predictive_punter import date_utils | ||
|
||
|
||
def test_equal(): | ||
"""The dates iterator should generate the expected date when date_from == date_to""" | ||
|
||
expected_dates = [ | ||
datetime(2016, 2, 2) | ||
] | ||
|
||
actual_dates = [date for date in date_utils.dates(datetime(2016, 2, 2), datetime(2016, 2, 2))] | ||
|
||
assert actual_dates == expected_dates | ||
|
||
|
||
def test_forward(): | ||
"""The dates iterator should generate the expected dates when date_from < date_to""" | ||
|
||
expected_dates = [ | ||
datetime(2016, 2, 1), | ||
datetime(2016, 2, 2), | ||
datetime(2016, 2, 3) | ||
] | ||
|
||
actual_dates = [date for date in date_utils.dates(datetime(2016, 2, 1), datetime(2016, 2, 3))] | ||
|
||
assert actual_dates == expected_dates | ||
|
||
|
||
def test_reverse(): | ||
"""The dates iterator should generate the expected dates when date_from > date_to""" | ||
|
||
expected_dates = [ | ||
datetime(2016, 2, 3), | ||
datetime(2016, 2, 2), | ||
datetime(2016, 2, 1) | ||
] | ||
|
||
actual_dates = [date for date in date_utils.dates(datetime(2016, 2, 3), datetime(2016, 2, 1))] | ||
|
||
assert actual_dates == expected_dates |