Raise error for unsupported recurrence for specific weekdays - e.g. every mon,tues,weds

This commit is contained in:
Matt Snider 2019-06-21 01:38:18 +02:00
parent 1ec6da17b3
commit c4815955ef
2 changed files with 9 additions and 2 deletions

View File

@ -169,5 +169,9 @@ def test_annually():
def test_unsupported():
pass
with pytest.raises(Exception):
utils.parse_recur('every mon,tues,weds')
with pytest.raises(Exception):
utils.parse_recur('every monday,tuesday,wednesday')

View File

@ -86,13 +86,16 @@ def parse_recur(date_string):
# - trim leading, trailing, and, duplicate spaces
# - convert to lowercase
date_string = ' '.join(date_string.lower().strip().split())
return (
result = (
_recur_single_cycle(date_string) or
_recur_multi_cycle(date_string) or
_recur_day_of_week(date_string) or
_recur_day_of_month(date_string) or
_recur_special(date_string)
)
if not result:
raise Exception("Recurrence not supported: %s" % date_string)
return result
# Atoms