def test_taskresultset_get_single(): """Tests retrieving a single task resultset item by index.""" due_on = now = aware_datetime(2017, 2, 28, 9, 0) due_date = DueDateFactory.build(due_on=due_on) task = TranslationTask(due_date=due_date, now=now, words_left=1) task_resultset = TaskResultSet([task]) assert task_resultset[0] == task.data
def test_taskresultset_importance_order(test_name, snapshot_stack, sort_type, fake_task_args): """Tests ordering of tasks according to their importance.""" tasks = [LightTask(*task_args) for task_args in fake_task_args] with snapshot_stack.push([as_dir(test_name), sort_type]) as snapshot: task_resultset = TaskResultSet(tasks).order_by_importance() snapshot.assert_matches([task for task in task_resultset])
def test_taskresultset_get_raises(index): """Tests retrieving from a task resultset by using an invalid index/slice.""" due_on = now = aware_datetime(2017, 2, 28, 9, 0) due_date = DueDateFactory.build(due_on=due_on) task = TranslationTask(due_date=due_date, now=now, words_left=1) task_resultset = TaskResultSet([task]) with pytest.raises(TypeError): task_resultset[index]