Skip to content

Commit 345857d

Browse files
committed
Add tests for crontab changes.
Refs coleifer#603
1 parent 031d45f commit 345857d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docs/api.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ Huey object
11091109
of an unhandled exception in the parent task.
11101110

11111111

1112-
.. py:function:: crontab(month='*', day='*', day_of_week='*', hour='*', minute='*')
1112+
.. py:function:: crontab(month='*', day='*', day_of_week='*', hour='*', minute='*'[, strict=False])
11131113
11141114
Convert a "crontab"-style set of parameters into a test function that will
11151115
return ``True`` when a given ``datetime`` matches the parameters set forth in
@@ -1124,6 +1124,8 @@ Huey object
11241124
- "m-n" = run every time m..n
11251125
- "m,n" = run on m and n
11261126

1127+
:param bool strict: cause crontab to raise a ``ValueError`` if an input
1128+
does not match a supported input format.
11271129
:rtype: a test function that takes a ``datetime`` and returns a boolean
11281130

11291131
.. note::

huey/tests/test_crontab.py

+6
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,9 @@ def test_invalid_crontabs(self):
118118
self.assertRaises(ValueError, crontab, minute='61')
119119
self.assertRaises(ValueError, crontab, minute='0-61')
120120
self.assertRaises(ValueError, crontab, day_of_week='*/3')
121+
122+
def test_invalid_crontabs_2(self):
123+
self.assertTrue(crontab(minute='*abc'))
124+
invalid = ('abc', '*abc', 'a-b', '1-c', '0x9')
125+
for i in invalid:
126+
self.assertRaises(ValueError, crontab, minute=i, strict=True)

0 commit comments

Comments
 (0)