tests: Add tests for generation of sorted dependency tree

This commit is contained in:
Tomas Babej 2015-08-11 06:44:43 +02:00
parent d73ead1bf7
commit b0f0d4b578

View file

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from datetime import datetime
from tests.base import IntegrationTest
from time import sleep
@ -156,3 +157,48 @@ class TestViewportsUnicodeTaskGeneration(IntegrationTest):
def execute(self):
self.command("w", regex="written$", lines=1)
class TestViewportsTaskSortedGeneration(IntegrationTest):
viminput = """
=== Work tasks | +work ===
"""
vimoutput = """
=== Work tasks | +work ===
* [ ] main task 1 (2015-08-07 00:00) #{uuid}
* [ ] sub task 1a (2015-08-01 00:00) #{uuid}
* [ ] sub task 1aa #{uuid}
* [ ] sub task 1b #{uuid}
* [ ] main task 2 (2015-08-08 00:00) #{uuid}
* [ ] main task 3 (2015-08-09 00:00) #{uuid}
* [ ] sub task 3a (2015-08-03 00:00) #{uuid}
* [ ] sub task 3b #{uuid}
* [ ] main task 4 #{uuid}
"""
tasks = [
dict(description="main task 3", tags=['work'], due=datetime(2015,8,9)),
dict(description="main task 2", tags=['work'], due=datetime(2015,8,8)),
dict(description="main task 1", tags=['work'], due=datetime(2015,8,7)),
dict(description="main task 4", tags=['work']),
dict(description="sub task 1b", tags=['work']),
dict(description="sub task 1a", tags=['work'], due=datetime(2015,8,1)),
dict(description="sub task 1aa", tags=['work']),
dict(description="sub task 3b", tags=['work']),
dict(description="sub task 3a", tags=['work'], due=datetime(2015,8,3)),
]
def execute(self):
# Mark the dependencies
self.tasks[2]['depends'].add(self.tasks[4])
self.tasks[2]['depends'].add(self.tasks[5])
self.tasks[0]['depends'].add(self.tasks[7])
self.tasks[0]['depends'].add(self.tasks[8])
self.tasks[5]['depends'].add(self.tasks[6])
for task in self.tasks:
task.save()
self.command("w", regex="written$", lines=1)