Skip to content

Commit

Permalink
Add tests for crontab changes.
Browse files Browse the repository at this point in the history
Refs #603
  • Loading branch information
coleifer committed Jun 7, 2021
1 parent 031d45f commit 345857d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ Huey object
of an unhandled exception in the parent task.


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

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

.. note::
Expand Down
6 changes: 6 additions & 0 deletions huey/tests/test_crontab.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,9 @@ def test_invalid_crontabs(self):
self.assertRaises(ValueError, crontab, minute='61')
self.assertRaises(ValueError, crontab, minute='0-61')
self.assertRaises(ValueError, crontab, day_of_week='*/3')

def test_invalid_crontabs_2(self):
self.assertTrue(crontab(minute='*abc'))
invalid = ('abc', '*abc', 'a-b', '1-c', '0x9')
for i in invalid:
self.assertRaises(ValueError, crontab, minute=i, strict=True)

0 comments on commit 345857d

Please sign in to comment.