def assert_data_generated_correctly(self, course_run, expected_team_data, creating=False): course = course_run.course expected = { 'title': course_run.title_override or course.title, 'org': course.organizations.first().key, 'number': course.number, 'run': StudioAPI.calculate_course_run_key_run_value( course.number, course_run.start_date_temporary), 'schedule': { 'start': serialize_datetime(course_run.start_date_temporary), 'end': serialize_datetime(course_run.end_date_temporary), }, 'team': expected_team_data, 'pacing_type': course_run.pacing_type_temporary, } assert StudioAPI.generate_data_for_studio_api( course_run, creating=creating) == expected
def test_generate_data_for_studio_api_without_team(self): run = CourseRunFactory() with mock.patch('course_discovery.apps.api.utils.logger.warning') as mock_logger: assert StudioAPI.generate_data_for_studio_api(run, True) == self.make_studio_data(run) mock_logger.assert_called_with( 'No course team admin specified for course [%s]. This may result in a Studio course run ' 'being created without a course team.', run.key.split('/')[1] )
def test_generate_data_for_studio_api(self): run = CourseRunFactory() editor = CourseEditorFactory(course=run.course) team = [ { 'user': editor.user.username, 'role': 'instructor', }, ] assert StudioAPI.generate_data_for_studio_api(run, True) == self.make_studio_data(run, team=team)