Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug which caused primary_section_id to be null #226

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions uw_sws/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,17 @@ def _json_to_section(section_data,

section.auditors = int(section_data['Auditors'])
section.allows_secondary_grading = section_data["SecondaryGradingOption"]

primary_section = section_data["PrimarySection"]
if (primary_section is not None and
primary_section["SectionID"] != section.section_id):
section.is_primary_section = False
section.primary_section_href = primary_section["Href"]
section.primary_section_id = primary_section["SectionID"]
section.primary_section_curriculum_abbr = primary_section[
"CurriculumAbbreviation"]
section.primary_section_course_number = primary_section[
"CourseNumber"]
else:
section.is_primary_section = True
section.is_primary_section = True
primary_section = section_data.get("PrimarySection")
if primary_section is not None:
section.primary_section_href = primary_section.get("Href")
section.primary_section_curriculum_abbr = primary_section.get(
"CurriculumAbbreviation")
section.primary_section_course_number = primary_section.get(
"CourseNumber")
section.primary_section_id = primary_section.get("SectionID")
section.is_primary_section = (
section.primary_section_id == section.section_id)

section.linked_section_urls = []
for linked_section_type in section_data["LinkedSectionTypes"]:
Expand Down
11 changes: 11 additions & 0 deletions uw_sws/tests/test_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,19 @@ def test_section(self):

section = get_section_by_label('2013,summer,PHIL,495/A')
self.assertTrue(section.is_ind_study())
self.assertTrue(section.is_primary_section)
self.assertEqual(section.primary_section_id, "A")
self.assertEqual(
section.primary_section_href,
"/student/v5/course/2013,summer,PHIL,495/A.json")
self.assertEqual(
section.primary_section_curriculum_abbr, "PHIL")
self.assertEqual(
section.primary_section_course_number, '495')
section = get_section_by_label('2013,summer,PHYS,121/AK')
self.assertTrue(section.is_quiz())
self.assertFalse(section.is_primary_section)
self.assertEqual(section.primary_section_id, "A")
section = get_section_by_label('2013,summer,PHYS,121/AQ')
self.assertTrue(section.is_lab())
self.assertIsNotNone(section.json_data())
Expand Down
Loading