Пример #1
0
 def test_TodoList_adds_unique_id_after_several_adds_and_a_do(self):
     """Can add several, one do and still have unique number."""
     todolist = TodoList(self.mock_persister)
     todolist.add("One")
     todolist.add("Two")
     todolist.add("Three")
     todolist.do("2")
     todolist.add("This message should have ID: 4")
     self.assertEqual(todolist.next_id, 5)
Пример #2
0
 def test_TodoList_completes_a_message(self):
     """A completed message gets removed."""
     todolist = TodoList(self.mock_persister)
     todolist.add("New message")
     ret_string = "Completed #1 New message"
     self.assertEqual(todolist.do("1"), ret_string)
     self.assertEqual(0, len(self.mock_persister.tasks))
Пример #3
0
 def test_TodoList_add_then_complete(self):
     todolist = TodoList(self.mock_persister)
     after_add = "#1 New message"
     self.assertEqual(todolist.add("New message"), after_add)
     actual_task = self.mock_persister.tasks[0]
     self.assertEqual(actual_task.text, "New message")
     self.assertEqual(actual_task.id, 1)
     after_do = "Completed #1 New message"
     self.assertEqual(1, len(self.mock_persister.tasks))
     self.assertEqual(todolist.do("1"), after_do)
     self.assertEqual(0, len(self.mock_persister.tasks))
Пример #4
0
 def test_TodoList_notifies_that_empty_list_cannot_be_completed(self):
     """Notify that nicely that we cannot complete from an empty list."""
     todolist = TodoList(self.mock_persister)
     after_do_empty = "No entries to do yet."
     self.assertEqual(todolist.do("1"), after_do_empty)
Пример #5
0
 def test_TodoList_notifies_if_id_is_not_a_number(self):
     todolist = TodoList(self.mock_persister)
     todolist.add("New message")
     after_invalid = "Error: ID must be number."
     self.assertEqual(todolist.do("fem"), after_invalid)
Пример #6
0
 def test_TodoList_notifies_if_id_does_not_exist(self):
     todolist = TodoList(self.mock_persister)
     todolist.add("New message")
     after_invalid = "Error: ID 404 not found."
     self.assertEqual(todolist.do("404"), after_invalid)