def test_set_task_from_scratch(self): test_str = "(B) 2012-08-27" test_item = TodoItem(test_str) self.assertIsNone(test_item.task) test_item.task = "foo bar" self.assertIsNotNone(test_item.task) self.assertEquals("foo bar", test_item.task) self.assertEquals(test_str + " " + "foo bar", test_item.todo_txt_line) test_str = "(B)" test_item = TodoItem(test_str) test_item.task = "foo bar" self.assertIsNotNone(test_item.task) self.assertEquals("foo bar", test_item.task) self.assertEquals(test_str + " " + "foo bar", test_item.todo_txt_line)
def test_set_task_existing(self): test_str = "(B) 2012-08-27 Xbox repair" test_item = TodoItem(test_str) self.assertIsNotNone(test_item.task) test_item.task = "ps3 polish" self.assertEqual("ps3 polish", test_item.task) self.assertEqual("(B) 2012-08-27 ps3 polish", 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()