def test_new_tree(self): store = TaskStore() root_task = store.new('My Root Task') child_task = store.new('My Child Task', root_task.id) self.assertEqual(store.count(), 2) self.assertEqual(store.count(root_only=True), 1)
def test_xml_load_simple(self): task_store = TaskStore() tag_store = TagStore() TAG_ID = '6f1ba7b3-a797-44b9-accd-303adaf04073' TASK_ID = '1d34df07-4185-43ad-adbd-698a86193411' tag = Tag2(id=TAG_ID, name='My Tag') tag_store.add(tag) parsed_xml = XML(f''' <tasklist> <task id="{TASK_ID}" status="Active" recurring="False"> <tags> <tag>{TAG_ID}</tag> </tags> <title>My Task</title> <dates> <added>2020-10-23T00:00:00</added> <modified>2021-03-20T14:55:46.219761</modified> <done></done> <fuzzyDue></fuzzyDue> <start>2010-07-20</start> </dates> <recurring enabled="false"> <term>None</term> </recurring> <subtasks/> <content><![CDATA[ My Content ]]></content> </task> </tasklist> ''') task_store.from_xml(parsed_xml, tag_store) self.assertEqual(task_store.count(), 1)
def test_new_simple(self): store = TaskStore() task = store.new('My Task') self.assertIsInstance(task, Task2) self.assertEqual(store.get(task.id), task) self.assertEqual(task.title, 'My Task') self.assertEqual(store.count(), 1)
def test_parenting(self): store = TaskStore() root_task = store.new('My Root Task') child_task = store.new('My Child task') store.parent(child_task.id, root_task.id) self.assertEqual(store.count(), 2) self.assertEqual(store.count(root_only=True), 1) self.assertEqual(child_task.parent, root_task) self.assertEqual(root_task.children[0], child_task) store.unparent(child_task.id, root_task.id) self.assertEqual(store.count(), 2) self.assertEqual(store.count(root_only=True), 2) self.assertEqual(child_task.parent, None) self.assertEqual(len(root_task.children), 0) inner_child_task = store.new('Inner Child task') store.parent(child_task.id, root_task.id) store.parent(inner_child_task.id, child_task.id) self.assertEqual(store.count(), 3) self.assertEqual(store.count(root_only=True), 1) self.assertEqual(child_task.parent, root_task) self.assertEqual(root_task.children[0], child_task) self.assertEqual(child_task.children[0], inner_child_task) self.assertEqual(child_task.parent, root_task) self.assertEqual(inner_child_task.parent, child_task) store.unparent(inner_child_task.id, inner_child_task.parent.id) self.assertEqual(inner_child_task.parent, None) self.assertEqual(len(child_task.children), 0)
def test_xml_load_tree(self): task_store = TaskStore() TASK_ID_1 = uuid4() TASK_ID_2 = uuid4() TASK_ID_3 = uuid4() TASK_ID_4 = uuid4() parsed_xml = XML(f''' <tasklist> <task id="{TASK_ID_1}" status="Active" recurring="False"> <title>My Task</title> <dates> <added>2020-10-23T00:00:00</added> <modified>2021-03-20T14:55:46.219761</modified> <done></done> <fuzzyDue></fuzzyDue> <start>2010-07-20</start> </dates> <recurring enabled="false"> <term>None</term> </recurring> <subtasks> <sub>{TASK_ID_2}</sub> <sub>{TASK_ID_3}</sub> </subtasks> <content><![CDATA[ My Content ]]></content> </task> <task id="{TASK_ID_2}" status="Active" recurring="False"> <title>My Task</title> <dates> <added>2020-10-23T00:00:00</added> <modified>2021-03-20T14:55:46.219761</modified> <done></done> <fuzzyDue></fuzzyDue> <start>2010-07-20</start> </dates> <recurring enabled="false"> <term>None</term> </recurring> <subtasks/> <content><![CDATA[ My Content ]]></content> </task> <task id="{TASK_ID_3}" status="Active" recurring="False"> <title>My Task</title> <dates> <added>2020-10-23T00:00:00</added> <modified>2021-03-20T14:55:46.219761</modified> <done></done> <fuzzyDue></fuzzyDue> <start>2010-07-20</start> </dates> <recurring enabled="false"> <term>None</term> </recurring> <subtasks> <sub>{TASK_ID_4}</sub> </subtasks> <content><![CDATA[ My Content ]]></content> </task> <task id="{TASK_ID_4}" status="Active" recurring="False"> <title>My Task</title> <dates> <added>2020-10-23T00:00:00</added> <modified>2021-03-20T14:55:46.219761</modified> <done></done> <fuzzyDue></fuzzyDue> <start>2010-07-20</start> </dates> <recurring enabled="false"> <term>None</term> </recurring> <subtasks/> <content><![CDATA[ My Content ]]></content> </task> </tasklist> ''') task_store.from_xml(parsed_xml, None) self.assertEqual(task_store.count(), 4) self.assertEqual(task_store.count(root_only=True), 1) self.assertEqual(len(task_store.get(str(TASK_ID_1)).children), 2)