mirror of
https://git.webmeisterei.com/webmeisterei/todoist-taskwarrior.git
synced 2023-12-21 10:23:00 +01:00
Add tests for recur
This commit is contained in:
parent
245daaa3fb
commit
c4a6e7bfc7
10
README.md
10
README.md
@ -2,4 +2,14 @@
|
||||
|
||||
A tool for migrating Todoist tasks to Taskwarrior.
|
||||
|
||||
## Usage
|
||||
|
||||
...
|
||||
|
||||
## Development
|
||||
|
||||
### Testing
|
||||
|
||||
```sh
|
||||
$ python -m pytest tests
|
||||
```
|
||||
|
2
test_requirements.txt
Normal file
2
test_requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
pytest==4.0.0
|
||||
|
101
tests/test_recur.py
Normal file
101
tests/test_recur.py
Normal file
@ -0,0 +1,101 @@
|
||||
""" Recur Tests
|
||||
|
||||
Tests parsing `recur` strings from Todoist `date_string`s
|
||||
"""
|
||||
from todoist_taskwarrior import utils
|
||||
|
||||
# TODO: try with every and ev
|
||||
|
||||
def test_hourly():
|
||||
assert utils.parse_recur('every hour') == 'hourly'
|
||||
assert utils.parse_recur('every 1 hour') == 'hourly'
|
||||
assert utils.parse_recur('every 2 hour') == '2 hours'
|
||||
assert utils.parse_recur('every 2 hours') == '2 hours'
|
||||
assert utils.parse_recur('every 3 hours') == '3 hours'
|
||||
|
||||
|
||||
def test_every_n_days():
|
||||
assert utils.parse_recur('daily') == 'daily'
|
||||
assert utils.parse_recur('every day') == 'daily'
|
||||
assert utils.parse_recur('every 1 day') == 'daily'
|
||||
assert utils.parse_recur('every 1 days') == 'daily'
|
||||
assert utils.parse_recur('every other day') == '2 days'
|
||||
assert utils.parse_recur('every 3 day') == '3 days'
|
||||
assert utils.parse_recur('every 3 days') == '3 days'
|
||||
|
||||
|
||||
def test_special():
|
||||
# Indicates daily at 9am - the time is saved in the `due` property
|
||||
assert utils.parse_recur('every morning') == 'daily'
|
||||
# Indicates daily at 7pm - the time is saved in the `due` property
|
||||
assert utils.parse_recur('every evening') == 'daily'
|
||||
|
||||
# Weekdays
|
||||
assert utils.parse_recur('every weekday') == 'weekdays'
|
||||
assert utils.parse_recur('every workday') == 'weekdays'
|
||||
|
||||
|
||||
def test_weekly():
|
||||
assert utils.parse_recur('every week') == 'weekly'
|
||||
assert utils.parse_recur('every 1 week') == 'weekly'
|
||||
assert utils.parse_recur('every 1 weeks') == 'weekly'
|
||||
assert utils.parse_recur('weekly') == 'weekly'
|
||||
assert utils.parse_recur('every 3 week') == '3 weeks'
|
||||
assert utils.parse_recur('every 3 weeks') == '3 weeks'
|
||||
|
||||
|
||||
def test_monthly():
|
||||
assert utils.parse_recur('every month') == 'monthly'
|
||||
assert utils.parse_recur('every 1 month') == 'monthly'
|
||||
assert utils.parse_recur('every 1 months') == 'monthly'
|
||||
assert utils.parse_recur('monthly') == 'monthly'
|
||||
assert utils.parse_recur('every 2 months') == '2 months'
|
||||
|
||||
# ordinal
|
||||
assert utils.parse_recur('every 2nd month') == '2 months'
|
||||
assert utils.parse_recur('every 3rd month') == '3 months'
|
||||
|
||||
|
||||
def test_day_of_week():
|
||||
""" The actual day should be indicated in the `due` property, so here
|
||||
we just need to ensure that the recurrence is correct.
|
||||
"""
|
||||
# TODO: test every day of the week (incl short forms)
|
||||
assert utils.parse_recur('every mon') == 'weekly'
|
||||
assert utils.parse_recur('every monday') == 'weekly'
|
||||
assert utils.parse_recur('every tuesday') == 'weekly'
|
||||
assert utils.parse_recur('every tues') == 'weekly'
|
||||
assert utils.parse_recur('every 2nd monday') == '2 weeks'
|
||||
assert utils.parse_recur('every 3rd friday') == '3 weeks'
|
||||
|
||||
|
||||
def test_day_of_month():
|
||||
""" The actual due date should be indicated by the `due` property, so here
|
||||
we just need to ensure a monthly recurrence.
|
||||
"""
|
||||
assert utils.parse_recur('every 1st') == 'monthly'
|
||||
assert utils.parse_recur('every 2nd') == 'monthly'
|
||||
assert utils.parse_recur('every 3rd') == 'monthly'
|
||||
assert utils.parse_recur('every 4th') == 'monthly'
|
||||
assert utils.parse_recur('every 21st') == 'monthly'
|
||||
assert utils.parse_recur('every 22nd') == 'monthly'
|
||||
assert utils.parse_recur('every 23rd') == 'monthly'
|
||||
assert utils.parse_recur('every 24th') == 'monthly'
|
||||
|
||||
# TODO: taskwarrior doesn't support this *exactly* -- monthly just means 30d
|
||||
# https://github.com/GothenburgBitFactory/taskwarrior/issues/1647
|
||||
assert utils.parse_recur('every last day') == 'monthly'
|
||||
|
||||
|
||||
def test_annually():
|
||||
assert utils.parse_recur('every year') == 'yearly'
|
||||
assert utils.parse_recur('every 2 year') == '2 years'
|
||||
assert utils.parse_recur('every 2 years') == '2 years'
|
||||
|
||||
|
||||
def test_unsupported():
|
||||
# TODO: expect exception
|
||||
# taskwarrior doesn't support reccurances of form
|
||||
# - every monday,tuesday,...
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user