From d0e587d729e7074a2e5150495ed7a9bf9a0c7c73 Mon Sep 17 00:00:00 2001 From: Daniel Zhao Date: Thu, 2 Nov 2023 01:26:28 -0400 Subject: [PATCH] Fixed linting and tests --- backend/courses/util.py | 2 +- backend/plan/urls.py | 2 +- backend/plan/views.py | 13 +++++++------ backend/tests/courses/util.py | 23 +++++++++++++++++++++++ 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/backend/courses/util.py b/backend/courses/util.py index e207791af..1aef67e1b 100644 --- a/backend/courses/util.py +++ b/backend/courses/util.py @@ -1,5 +1,5 @@ -import json import itertools +import json import logging import os import random diff --git a/backend/plan/urls.py b/backend/plan/urls.py index 197c6747d..6c1f8902b 100644 --- a/backend/plan/urls.py +++ b/backend/plan/urls.py @@ -3,11 +3,11 @@ from rest_framework_nested import routers from plan.views import ( + AutomaticCourseScheduler, CalendarAPIView, PrimaryScheduleViewSet, ScheduleViewSet, recommend_courses_view, - AutomaticCourseScheduler, ) diff --git a/backend/plan/views.py b/backend/plan/views.py index 4cd9e1675..0daed25fc 100644 --- a/backend/plan/views.py +++ b/backend/plan/views.py @@ -17,8 +17,12 @@ from rest_framework.views import APIView from courses.models import Course, Meeting, Section -from courses.serializers import CourseListSerializer, CourseDetailSerializer, SectionDetailSerializer -from courses.util import get_course_and_section, get_current_semester, find_possible_schedules +from courses.serializers import ( + CourseDetailSerializer, + CourseListSerializer, + SectionDetailSerializer, +) +from courses.util import find_possible_schedules, get_course_and_section, get_current_semester from courses.views import get_accepted_friends from PennCourses.docs_settings import PcxAutoSchema from PennCourses.settings.base import PATH_REGISTRATION_SCHEDULE_NAME @@ -30,10 +34,7 @@ vectorize_user_by_courses, ) from plan.models import PrimarySchedule, Schedule -from plan.serializers import ( - PrimaryScheduleSerializer, - ScheduleSerializer, -) +from plan.serializers import PrimaryScheduleSerializer, ScheduleSerializer @api_view(["POST"]) diff --git a/backend/tests/courses/util.py b/backend/tests/courses/util.py index 632a32783..20dc47daa 100644 --- a/backend/tests/courses/util.py +++ b/backend/tests/courses/util.py @@ -30,6 +30,29 @@ def create_mock_data(code, semester, meeting_days="MWF", start=1100, end=1200): return course, section +def create_mock_recitation(code, semester, meeting_days="MWF", start=1100, end=1200): + course, section, _, _ = get_or_create_course_and_section(code, semester) + course.description = "This is a fake class." + course.save() + section.credits = 0 + section.status = "O" + section.activity = "REC" + section.save() + m = [ + { + "building_code": "LLAB", + "room_code": "10", + "days": meeting_days, + "begin_time_24": start, + "begin_time": time_str(start), + "end_time_24": end, + "end_time": time_str(end), + } + ] + set_meetings(section, m) + return course, section + + def create_mock_data_with_reviews(code, semester, number_of_instructors): course, section = create_mock_data(code, semester) reviews = []