def create_sample_completed_lcgm(site, user_count, course_count): """Generate test data TODO: Make this a parametrized fixture https://docs.pytest.org/en/3.1.3/example/parametrize.html We don't create CourseEnrollment objects because we don't need them as Figures models try to rely on the content and context of the data in the LMS and not the LMS models specifically """ users = [UserFactory() for i in range(user_count)] # We need just the course_ids course_ids = [COURSE_ID_STR_TEMPLATE.format(i) for i in range(course_count)] # Two records for each enrollment, one shows not complete, one shows complete lcgm_data = [ dict( date_for='2020-04-01', points_possible=40, points_earned=40, sections_possible=5, sections_worked=4), dict( date_for='2020-05-05', points_possible=50, points_earned=50, sections_possible=5, sections_worked=5) ] lcgm_list = [] for user in users: for course_id in course_ids: for lcgm in lcgm_data: lcgm_list.append(LearnerCourseGradeMetricsFactory( site=site, user=user, course_id=course_id, date_for=lcgm['date_for'], points_possible=lcgm['points_possible'], points_earned=lcgm['points_earned'], sections_possible=lcgm['sections_possible'], sections_worked=lcgm['sections_worked'] ) ) return dict( lcgm_list=lcgm_list, users=users, course_ids=course_ids, site=site, )
def setup(self): self.course_key_string = COURSE_ID_STR_TEMPLATE.format(1) self.course_key = CourseKey.from_string(self.course_key_string)
def sample_course_id(index=1): return CourseKey.from_string(COURSE_ID_STR_TEMPLATE.format(index))