def test_save_load(self): name = "test2" tsk1 = task.Task("Do something", 1367144289 , 0) tsk2 = task.Task("Do something else", 1367144288 , 0) tsk3 = task.Task("A completed task", 13671442887, 0) before = TaskList(name, self.workingD) before.add(tsk1) before.add(tsk2) before.add(tsk3) before.complete(2) before.save() after = TaskList(name, self.workingD) assert after.active() == 2 assert after.completed() == 1 assert after.activetasks[0].equals(before.activetasks[0]) assert after.activetasks[1].equals(before.activetasks[1]) assert after.completedtasks[0].equals(before.completedtasks[0]) before.destroy()
def test_simple_path(sentence1): node_0 = Node('', 0, sentence1, state=NodeState.ROOT) tasklist = TaskList(node_0) assert len(tasklist) == 1 next_node_0 = tasklist.next() assert len(tasklist) == 0 assert next_node_0.next_pos == 0 node_1 = Node('..', 0, '-.--.', parent=next_node_0) tasklist.add(node_1) next_node_1 = tasklist.next() assert len(tasklist) == 0 assert next_node_1.next_pos == 2 node_2 = Node('-', 2, '.--.', parent=next_node_1) tasklist.add(node_2) next_node_2 = tasklist.next() assert len(tasklist) == 0 assert next_node_2.next_pos == 3 node_3 = Node('.--', 3, '.', parent=next_node_2) tasklist.add(node_3) next_node_3 = tasklist.next() assert len(tasklist) == 0 assert next_node_3.next_pos == 6 node_4 = Node('.', 6, '', parent=next_node_3) tasklist.add(node_4) next_node_4 = tasklist.next() assert len(tasklist) == 0 assert next_node_4.next_pos == 7 next_node_done = tasklist.next() assert next_node_done is None
def test_take_2(sentence1): node_0 = Node('', 0, sentence1, state=NodeState.ROOT) tasklist = TaskList(node_0) assert len(tasklist) == 1 nodes = tasklist.next(size=2) assert len(nodes) == 1 next_node_0 = nodes[0] assert len(tasklist) == 0 assert next_node_0.next_pos == 0 node_1 = Node('..', 0, '-.--.', parent=next_node_0) tasklist.add(node_1) node_2 = Node('-', 2, '.--.', parent=node_1) tasklist.add(node_2) nodes = tasklist.next(size=2) assert len(nodes) == 2
def test_active_sort(self): name = "test3" tl = TaskList(name, self.workingD) tsk1 = task.Task("Task with early due date and priority 0", 1367144200 , 0) tsk2 = task.Task("Task with later due date and priority 0", 1367144210 , 0) tl.add(tsk1) tl.add(tsk2) assert tl.activetasks[0].equals(tsk1) tsk3 = task.Task("Task with earlier due date and priority 0", 1367144100 , 0) tl.add(tsk3) assert tl.activetasks[0].equals(tsk3) tsk4 = task.Task("Task with the same due date and higher priority", 1367144100, 1) tl.add(tsk4) assert tl.activetasks[0].equals(tsk4)
# No arguments, default to list by adding it if len(sys.argv) == 1: sys.argv.append('list') # Get command from args cmd = sys.argv[1].lower() if cmd == 'list': # List tasks t = TaskList('default', taskerfolder) t.print_list() elif cmd == 'add': t = TaskList('default', taskerfolder) t.add(create_new_task()) t.save() t.print_list() elif cmd =='-h' or cmd == '--help': # Show usage print "Try one of the following:" print " list \t: List your tasks." print " add \t: Add a new task to the list" else: # Unrecognised command print "Unrecognised command: '%s'" % cmd print "Try one of the following:" print " list \t: List your tasks." print " add \t: Add a new task to the list"
def test_task_order(sentence1): node_0 = Node('', 0, sentence1, state=NodeState.ROOT) tasklist = TaskList(node_0) node_1a = Node('6', 6, '', parent=node_0) tasklist.add(node_1a) node_1b = Node('5', 5, '', parent=node_0) tasklist.add(node_1b) node_1c = Node('2', 2, '', parent=node_0) tasklist.add(node_1c) node_1d = Node('3', 3, '', parent=node_0) tasklist.add(node_1d) node_1e = Node('4', 4, '', parent=node_0) tasklist.add(node_1e) node_1f = Node('1', 1, '', parent=node_0) tasklist.add(node_1f) assert len(tasklist) == 7 next_node = tasklist.next() assert next_node.next_pos == 7 assert len(tasklist) == 6 next_node = tasklist.next() assert next_node.next_pos == 6 assert len(tasklist) == 5