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_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)