From b5d4967399875c74719bd1f737b610ff9ae148c8 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sat, 28 Mar 2015 14:27:59 +0100 Subject: [PATCH] tests: Add tests for setting dependencies via indentation --- tests/test_vwtask.py | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/test_vwtask.py b/tests/test_vwtask.py index 088f893..7457392 100644 --- a/tests/test_vwtask.py +++ b/tests/test_vwtask.py @@ -189,3 +189,70 @@ class TestSimpleTaskWithPriorityModification(IntegrationTest): assert task['description'] == 'This is a test task' assert task['status'] == 'pending' assert task['priority'] == "L" + + +class TestChildTaskCreation(IntegrationTest): + + viminput = """ + * [ ] This is parent task + * [ ] This is child task + """ + + vimoutput = """ + * [ ] This is parent task #{uuid} + * [ ] This is child task #{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()) == 2 + + parent = self.tw.tasks.filter(description="This is parent task")[0] + child = self.tw.tasks.filter(description="This is child task")[0] + + assert child['description'] == 'This is child task' + assert parent['description'] == 'This is parent task' + assert parent['depends'] == set([child]) + + +class TestChildTaskModification(IntegrationTest): + + viminput = """ + * [ ] This is parent task #{uuid} + * [ ] This is child task #{uuid} + """ + + vimoutput = """ + * [ ] This is parent task #{uuid} + * [ ] This is child task #{uuid} + """ + + tasks = [ + dict(description="This is parent task"), + dict(description="This is child task"), + ] + + def execute(self): + # Check that only two tasks are in the data files + assert len(self.tw.tasks.pending()) == 2 + + parent = self.tw.tasks.filter(description="This is parent task")[0] + child = self.tw.tasks.filter(description="This is child task")[0] + + assert parent['depends'] == set() + + # Indent the task in the buffer + buffer_content = self.read_buffer() + self.write_buffer([" " + buffer_content[1]], 1) + + self.command("w", regex="written$", lines=1) + + # Check that only two tasks are in the data files + assert len(self.tw.tasks.pending()) == 2 + + parent = self.tw.tasks.filter(description="This is parent task")[0] + child = self.tw.tasks.filter(description="This is child task")[0] + + assert parent['depends'] == set([child])