def test_sort_by_name_sorts_correctly(self): tasks = SimpleTasks('work') tasks.add('tasks 2') tasks.add('tasks 1') tasks.add('tasks 3') self.assertEqual(['tasks 2', 'tasks 1', 'tasks 3'], list(map(lambda i: i.name, tasks.all()))) tasks.sort_by_name() self.assertEqual(['tasks 1', 'tasks 2', 'tasks 3'], list(map(lambda i: i.name, tasks.all()))) tasks.sort_by_name(desc=True) self.assertEqual(['tasks 3', 'tasks 2', 'tasks 1'], list(map(lambda i: i.name, tasks.all())))
def test_tasks_all_returns_all_the_tasks_in_tasks(self): tasks = SimpleTasks('work') tasks.add('tasks 1') tasks.add('tasks 2') task_list = tasks.all() self.assertTrue(isinstance(task_list[0], Task)) self.assertTrue(isinstance(task_list[1], Task)) self.assertEqual(task_list[0].name, 'tasks 1') self.assertEqual(task_list[1].name, 'tasks 2')
def test_tasks_all_is_empty_when_initialized(self): tasks = SimpleTasks('work') self.assertEqual(0, len(tasks.all()))