class TestTodoList(unittest.TestCase): def setUp(self): self.client = Redis(decode_responses=True) self.client.flushdb() self.todolist = TodoList(self.client, "peter") self.events = [ "buy some milk", "have lunch", "watch tv", "finish homework", "go to sleep" ] def test_add(self): self.assertEqual(self.todolist.show_todo_list(), []) self.todolist.add(self.events[0]) self.assertNotEqual(self.todolist.show_todo_list(), []) def test_remove(self): self.todolist.add(self.events[0]) self.todolist.remove(self.events[0]) self.assertEqual(self.todolist.show_todo_list(), []) def test_done(self): self.todolist.add(self.events[0]) self.todolist.done(self.events[0]) self.assertEqual(self.todolist.show_todo_list(), []) self.assertNotEqual(self.todolist.show_done_list(), []) def test_show_todo_list(self): self.assertEqual(self.todolist.show_todo_list(), []) for event in self.events: self.todolist.add(event) self.assertEqual(self.todolist.show_todo_list(), list(reversed(self.events))) def test_show_done_list(self): self.assertEqual(self.todolist.show_done_list(), []) for event in self.events: self.todolist.add(event) for event in self.events: self.todolist.done(event) self.assertEqual(self.todolist.show_done_list(), list(reversed(self.events)))
from todo import Todo from todo_list import TodoList print(''' 1. Wyswietl liste. 2. Dodaj zadanie. 3. Usun zadanie. 4. Wyjdz. ''') todo_list = TodoList() while True: option = input('Wybierz czynnosc: (1|2|3|4): ') if option == '1': todo_list.show() if option == '2': content = input('Podaj tresc zadania: ') new_todo = Todo(content) todo_list.add(todo=new_todo) if option == '3': idx = int(input('Podaj indeks zadania do usuniecia: ')) todo_list.remove(idx) if option == '4': break print('Koniec dzialania progrmu.')