mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-19 06:43:06 +02:00
tests: Add tests for adding and modifying tasks with due dates
This commit is contained in:
parent
03ebab5464
commit
73a0db867e
1 changed files with 86 additions and 1 deletions
|
@ -1,7 +1,9 @@
|
|||
from datetime import datetime
|
||||
from tasklib.task import local_zone
|
||||
from tests.base import IntegrationTest
|
||||
|
||||
|
||||
class TestSimpleTask(IntegrationTest):
|
||||
class TestSimpleTaskCreation(IntegrationTest):
|
||||
|
||||
viminput = """
|
||||
* [ ] This is a test task
|
||||
|
@ -20,3 +22,86 @@ class TestSimpleTask(IntegrationTest):
|
|||
task = self.tw.tasks.pending()[0]
|
||||
assert task['description'] == 'This is a test task'
|
||||
assert task['status'] == 'pending'
|
||||
|
||||
|
||||
class TestSimpleTaskWithDueDatetimeCreation(IntegrationTest):
|
||||
|
||||
viminput = """
|
||||
* [ ] This is a test task (2015-03-03 12:00)
|
||||
"""
|
||||
|
||||
vimoutput = """
|
||||
* [ ] This is a test task (2015-03-03 12:00) #{uuid}
|
||||
"""
|
||||
|
||||
def execute(self):
|
||||
self.command("w", regex="written$", lines=1)
|
||||
|
||||
# Check that only one tasks with this description exists
|
||||
assert len(self.tw.tasks.pending()) == 1
|
||||
|
||||
due = datetime(2015, 3, 3, 12, 0)
|
||||
|
||||
task = self.tw.tasks.pending()[0]
|
||||
assert task['description'] == 'This is a test task'
|
||||
assert task['status'] == 'pending'
|
||||
assert task['due'] == local_zone.localize(due)
|
||||
|
||||
|
||||
class TestSimpleTaskWithDueDateCreation(IntegrationTest):
|
||||
|
||||
viminput = """
|
||||
* [ ] This is a test task (2015-03-03)
|
||||
"""
|
||||
|
||||
vimoutput = """
|
||||
* [ ] This is a test task (2015-03-03 00:00) #{uuid}
|
||||
"""
|
||||
|
||||
def execute(self):
|
||||
self.command("w", regex="written$", lines=1)
|
||||
|
||||
# Check that only one tasks with this description exists
|
||||
assert len(self.tw.tasks.pending()) == 1
|
||||
|
||||
due = datetime(2015, 3, 3, 0, 0)
|
||||
|
||||
task = self.tw.tasks.pending()[0]
|
||||
assert task['description'] == 'This is a test task'
|
||||
assert task['status'] == 'pending'
|
||||
assert task['due'] == local_zone.localize(due)
|
||||
|
||||
|
||||
class TestSimpleTaskWithDueDatetimeModification(IntegrationTest):
|
||||
|
||||
viminput = """
|
||||
* [ ] This is a test task (2015-03-03 12:00) #{uuid}
|
||||
"""
|
||||
|
||||
vimoutput = """
|
||||
* [ ] This is a test task (2015-03-04 13:00) #{uuid}
|
||||
"""
|
||||
|
||||
tasks = [
|
||||
dict(description="This is a test task", due=datetime(2015, 3, 3, 12, 0))
|
||||
]
|
||||
|
||||
def execute(self):
|
||||
# Change the current line's due date
|
||||
current_data = self.read_buffer()
|
||||
current_data[0] = current_data[0].replace('2015-03-03 12:00',
|
||||
'2015-03-04 13:00')
|
||||
self.write_buffer(current_data)
|
||||
|
||||
# Save the changes
|
||||
self.command("w", regex="written$", lines=1)
|
||||
|
||||
# Check that only one tasks with exists
|
||||
assert len(self.tw.tasks.pending()) == 1
|
||||
|
||||
due = datetime(2015, 3, 4, 13, 0)
|
||||
|
||||
task = self.tw.tasks.pending()[0]
|
||||
assert task['description'] == 'This is a test task'
|
||||
assert task['status'] == 'pending'
|
||||
assert task['due'] == local_zone.localize(due)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue