Exemplo n.º 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')
Exemplo n.º 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"))
Exemplo n.º 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')
Exemplo n.º 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")
Exemplo n.º 5
0
 def setUp(self):
     self.notepad = todo.Notepad()
Exemplo n.º 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(), '')