def test_del_priority(self): test_str = "(B) 2012-08-27 @home Xbox repair" test_item = TodoItem(test_str) test_item.priority = None self.assertIsNone(test_item.priority) self.assertEqual("2012-08-27 Xbox repair @home", test_item.todo_txt_line)
def test_set_priority_from_scratch(self): test_str = "2012-09-15 bar baz @home" test_item = TodoItem(test_str) self.assertIsNone(test_item.priority) test_item.priority = "D" self.assertIsNotNone(test_item.priority) self.assertEquals("(D) " + test_str, test_item.todo_txt_line)
def test_mark_done(self): test_str = "(B) 2012-08-27 @home Xbox repair" done_item = TodoItem("x " + TodoItem.curr_date_str() + " 2012-08-27 @home Xbox repair") test_item = TodoItem(test_str) test_item.done = True test_item.priority = None self.assertEqual(test_item.__dict__, done_item.__dict__)
def cmd_add(self): priarg = self.cmd.replace("add", "") new_td = TodoItem(self.addargs) new_td.priority = priarg new_td.create_today() #print "Adding " + str(new_td) self.td_file.append(new_td) self.save() self.cmd_ls()
def test_set_priority_exists(self): test_str = "(A) 2012-09-15 bar baz @home" test_item = TodoItem(test_str) self.assertIsNotNone(test_item.priority) test_item.priority = "D" self.assertIsNotNone(test_item.priority) self.assertEquals("D", test_item.priority) self.assertEquals("(D) 2012-09-15 bar baz @home", test_item.todo_txt_line)
def save(self): self.set_status("Adding new item: ") new_item = TodoItem() new_item.priority = self.new_priority.get() if new_item.priority == "": new_item.priority = None new_item.context = self.new_context.get() if new_item.context == "" or new_item.context == "None": new_item.context = None new_item.task = self.new_task.get() new_item.creation_date = self.new_date.get() if new_item.creation_date == "": new_item.creation_date = None self.set_status("Adding new item: " + str(new_item)) self.active_td_file().append(new_item) self.set_status( "Adding new item: " + str(new_item) + " ... save complete") self.reset_ui()