mirror of
https://git.webmeisterei.com/webmeisterei/todoist-taskwarrior.git
synced 2023-12-21 10:23:00 +01:00
Change base Exception to UnsupportedRecurrence
This commit is contained in:
parent
c4815955ef
commit
7f5e9708dc
@ -4,6 +4,7 @@ Tests parsing `recur` strings from Todoist `date_string`s
|
|||||||
"""
|
"""
|
||||||
import pytest
|
import pytest
|
||||||
from todoist_taskwarrior import utils
|
from todoist_taskwarrior import utils
|
||||||
|
from todoist_taskwarrior import errors
|
||||||
|
|
||||||
|
|
||||||
def test_hourly():
|
def test_hourly():
|
||||||
@ -169,9 +170,9 @@ def test_annually():
|
|||||||
|
|
||||||
|
|
||||||
def test_unsupported():
|
def test_unsupported():
|
||||||
with pytest.raises(Exception):
|
with pytest.raises(errors.UnsupportedRecurrence):
|
||||||
utils.parse_recur('every mon,tues,weds')
|
utils.parse_recur('every mon,tues,weds')
|
||||||
|
|
||||||
with pytest.raises(Exception):
|
with pytest.raises(errors.UnsupportedRecurrence):
|
||||||
utils.parse_recur('every monday,tuesday,wednesday')
|
utils.parse_recur('every monday,tuesday,wednesday')
|
||||||
|
|
||||||
|
9
todoist_taskwarrior/errors.py
Normal file
9
todoist_taskwarrior/errors.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
""" Custom Errors """
|
||||||
|
|
||||||
|
|
||||||
|
class UnsupportedRecurrence(Exception):
|
||||||
|
|
||||||
|
def __init__(self, date_string):
|
||||||
|
super().__init__('Unsupported recurrence: %s' % date_string)
|
||||||
|
self.date_string = date_string
|
||||||
|
|
@ -1,6 +1,7 @@
|
|||||||
import click
|
import click
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from .errors import UnsupportedRecurrence
|
||||||
|
|
||||||
""" Validation """
|
""" Validation """
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ def parse_recur(date_string):
|
|||||||
_recur_special(date_string)
|
_recur_special(date_string)
|
||||||
)
|
)
|
||||||
if not result:
|
if not result:
|
||||||
raise Exception("Recurrence not supported: %s" % date_string)
|
raise UnsupportedRecurrence(date_string)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user