def export_course_data(config, destination, environment): log.info('Exporting data for %s', config['course']) results = [] kwargs = get_config_for_env(config, environment) kwargs['work_dir'] = destination log.info("Getting data for course %s", config['course']) tasks_from_options = kwargs.get('tasks', []) course_tasks = _get_selected_tasks(CourseTask, tasks_from_options, []) filenames = run_tasks(course_tasks, **kwargs) results.extend(filenames) return results
def test_get_selected_tasks_excluded_tasks(): assert sorted(set(tasks.DEFAULT_TASKS) - set([tasks.OrgEmailOptInTask])) == sorted( main._get_selected_tasks(tasks.Task, [], ['OrgEmailOptInTask']))
def test_get_selected_tasks_specified_from_options(): assert [tasks.OrgEmailOptInTask ] == main._get_selected_tasks(tasks.Task, ['OrgEmailOptInTask'], [])
def test_get_selected_tasks_no_options_course_tasks(): assert sorted([ task for task in tasks.DEFAULT_TASKS if issubclass(task, tasks.CourseTask) ]) == sorted(main._get_selected_tasks(tasks.CourseTask, [], []))
def test_get_selected_tasks_no_options_org_tasks(): assert [tasks.OrgEmailOptInTask ] == main._get_selected_tasks(tasks.OrgTask, [], [])
def test_get_selected_tasks_excluded_tasks(): assert sorted(set(tasks.DEFAULT_TASKS) - set([tasks.OrgEmailOptInTask]), key=operator.attrgetter('NAME')) \ == sorted(main._get_selected_tasks(tasks.Task, [], ['OrgEmailOptInTask']), key=operator.attrgetter('NAME'))
def test_get_selected_tasks_no_options_course_tasks(): assert sorted([ task for task in tasks.DEFAULT_TASKS if issubclass(task, tasks.CourseTask)], key=operator.attrgetter('NAME')) \ == sorted(main._get_selected_tasks(tasks.CourseTask, [], []), key=operator.attrgetter('NAME'))