From c4815955ef2101068cad980938d0fa0fc4d3e80e Mon Sep 17 00:00:00 2001 From: Matt Snider Date: Fri, 21 Jun 2019 01:38:18 +0200 Subject: [PATCH] Raise error for unsupported recurrence for specific weekdays - e.g. every mon,tues,weds --- tests/test_recur.py | 6 +++++- todoist_taskwarrior/utils.py | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_recur.py b/tests/test_recur.py index b79b2fe..9c29d55 100644 --- a/tests/test_recur.py +++ b/tests/test_recur.py @@ -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') diff --git a/todoist_taskwarrior/utils.py b/todoist_taskwarrior/utils.py index 7464a3e..059bc63 100644 --- a/todoist_taskwarrior/utils.py +++ b/todoist_taskwarrior/utils.py @@ -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