Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1635] Move string_to_timedelta() out of helpers
This is not intended to be a template helper function so doesn't belong in ckan/lib/helpers.py. Just put it in email_notifications, since that's the only module that uses it.
- Loading branch information
Sean Hammond
committed
Dec 11, 2012
1 parent
02cda1c
commit 5e4669d
Showing
4 changed files
with
87 additions
and
75 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
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,29 @@ | ||
'''Tests for the ckan.lib.email_notifications module. | ||
Note that email_notifications is used by an action function, so most of the | ||
tests for the module are done by testing the action function in | ||
ckan.test.functional.api. This test module contains some additional unit tests. | ||
''' | ||
import datetime | ||
|
||
import ckan.lib.email_notifications as email_notifications | ||
|
||
|
||
def test_string_to_time_delta(): | ||
assert email_notifications.string_to_timedelta('2 days') == ( | ||
datetime.timedelta(days=2)) | ||
assert email_notifications.string_to_timedelta('14 days') == ( | ||
datetime.timedelta(days=14)) | ||
assert email_notifications.string_to_timedelta('4:35:00') == ( | ||
datetime.timedelta(hours=4, minutes=35, seconds=00)) | ||
assert email_notifications.string_to_timedelta('4:35:12.087465') == ( | ||
datetime.timedelta(hours=4, minutes=35, seconds=12, | ||
milliseconds=87, microseconds=465)) | ||
assert email_notifications.string_to_timedelta('7 days, 3:23:34') == ( | ||
datetime.timedelta(days=7, hours=3, minutes=23, seconds=34)) | ||
assert email_notifications.string_to_timedelta( | ||
'7 days, 3:23:34.087465') == datetime.timedelta(days=7, hours=3, | ||
minutes=23, seconds=34, milliseconds=87, microseconds=465) | ||
assert email_notifications.string_to_timedelta('.123456') == ( | ||
datetime.timedelta(milliseconds=123, microseconds=456)) |
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