def test_calculate_course_run_key_run_value_with_multiple_runs_per_trimester(): number = 'TestX' organization = OrganizationFactory() partner = organization.partner course_key = '{org}+{number}'.format(org=organization.key, number=number) discovery_course = DiscoveryCourseFactory(partner=partner, key=course_key) start = datetime.datetime(2017, 2, 1) DiscoveryCourseRunFactory(key='course-v1:TestX+Testing101x+1T2017', course=discovery_course) assert StudioAPI.calculate_course_run_key_run_value(number, start) == '1T2017a' DiscoveryCourseRunFactory(key='course-v1:TestX+Testing101x+1T2017a', course=discovery_course) assert StudioAPI.calculate_course_run_key_run_value(number, start) == '1T2017b'
def assert_data_generated_correctly(course_run, expected_team_data): 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_run), '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) == expected
def assert_data_generated_correctly(course_run, expected_team_data): 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, } # the publisher djangoapp doesn't care about the 'creating' flag passed below, so we just always set it False assert StudioAPI.generate_data_for_studio_api(course_run, creating=False) == expected
def test_calculate_course_run_key_run_value(month, expected): course = CourseFactory() start = datetime.datetime(2017, month, 1) assert StudioAPI.calculate_course_run_key_run_value( course.number, start=start) == expected
def test_calculate_course_run_key_run_value(month, expected): course_run = CourseRunFactory(start=datetime.datetime(2017, month, 1)) assert StudioAPI.calculate_course_run_key_run_value(course_run) == expected