コード例 #1
0
    def test_writing_a_list_with_one_entry_to_the_file_cabinet(self):
        cabinet = todo.FileCabinet(self.stream)
        todoList = todo.Notepad()
        todoList.write("Write a todo list app")

        cabinet.store(todoList)
        self.assertEqual(self.stream.getvalue(), 'Write a todo list app')
コード例 #2
0
    def test_load_an_existing_todo_from_stream(self):
        self.stream.write("todo 1\n")
        self.stream.write("todo 2")
        self.stream.seek(0)
        cabinet = todo.FileCabinet(self.stream)
        todoList = todo.Notepad()
        cabinet.take_out(todoList)

        self.assertEqual(todoList.todos(), ("todo 1", "todo 2"))
コード例 #3
0
    def test_writing_many_entries_to_the_file_cabinet(self):
        cabinet = todo.FileCabinet(self.stream)
        todoList = todo.Notepad()
        todoList.write("Write a todo list app")
        todoList.write("Profit")

        cabinet.store(todoList)
        self.assertEqual(self.stream.getvalue(),
                         'Write a todo list app\nProfit')
コード例 #4
0
    def test_append_to_the_next_todos_on_store(self):
        self.stream.write("todo 1\n")
        self.stream.seek(0)
        cabinet = todo.FileCabinet(self.stream)
        todoList = todo.Notepad()
        cabinet.take_out(todoList)
        todoList.write("todo 2")
        cabinet.store(todoList)

        self.assertEqual(self.stream.getvalue(), "todo 1\ntodo 2")
コード例 #5
0
 def setUp(self):
     self.notepad = todo.Notepad()
コード例 #6
0
    def test_writing_an_empty_list_to_the_file_cabinet(self):
        cabinet = todo.FileCabinet(self.stream)
        todoList = todo.Notepad()

        cabinet.store(todoList)
        self.assertEqual(self.stream.getvalue(), '')