Skip to content

Commit

Permalink
Add test of section.primary_section*
Browse files Browse the repository at this point in the history
  • Loading branch information
fanglinfang committed Sep 21, 2024
1 parent 63ba713 commit a03b891
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 3 additions & 5 deletions uw_sws/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,13 @@ def _json_to_section(section_data,
primary_section = section_data.get("PrimarySection")
if primary_section is not None:
section.primary_section_href = primary_section.get("Href")
section.primary_section_id = primary_section.get("SectionID")
section.primary_section_curriculum_abbr = primary_section.get(
"CurriculumAbbreviation")
section.primary_section_course_number = primary_section.get(
"CourseNumber")
if section.primary_section_id == section.section_id:
section.is_primary_section = True
else:
section.is_primary_section = False
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
9 changes: 9 additions & 0 deletions uw_sws/tests/test_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@ 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

0 comments on commit a03b891

Please # to comment.