From b0f0d4b5785581ec8da36f659d27fa0b2bca345b Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Tue, 11 Aug 2015 06:44:43 +0200 Subject: [PATCH] tests: Add tests for generation of sorted dependency tree --- tests/test_viewport.py | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/test_viewport.py b/tests/test_viewport.py index e26acfc..d510ab3 100644 --- a/tests/test_viewport.py +++ b/tests/test_viewport.py @@ -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)