Skip to content

Commit

Permalink
Filter out blank rows (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaygandecha authored Oct 17, 2024
1 parent 92474b0 commit ae84763
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/services/academics/section_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ def import_users_from_csv(self, subject: User, section_id: int, csv_data: str):

try:
for row in reader:
if reader.line_num != 2 and row["Student"] != "Student, Test":
if (
reader.line_num != 2
and row["Student"] != "Student, Test"
and len(row["Student"]) > 0
):

# Ensure that the uploaded CSV only contains one section
unique_sections.add(row["Section"])
Expand Down
8 changes: 8 additions & 0 deletions backend/test/services/academics/section_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,3 +554,11 @@ def fake_data_fixture(session: Session):
"Student, Sally",0,sstudent,COMP301.001.S224,,,,,,,,,,,,,,,,
"Student, New",0,345345345,nstudent,COMP301.001.S224,,,,,,,,,,,,,,,,
"Jordan, Kris",0,89898989,kjordan,COMP301.001.S224,,,,,,,,,,,,,,,,"""

extra_row_roster_csv = """Student,ID,SIS User ID,SIS Login ID,Section,Assignments Current Points,Assignments Final Points,Assignments Current Score,Assignments Unposted Current Score,Assignments Final Score,Assignments Unposted Final Score,Current Points,Final Points,Current Score,Unposted Current Score,Final Score,Unposted Final Score,Current Grade,Unposted Current Grade,Final Grade,Unposted Final Grade
Points Possible,,,,,(read only),(read only),(read only),(read only),(read only),(read only),(read only),(read only),(read only),(read only),(read only),(read only),(read only),(read only),(read only),(read only)
,,,,,,,,,,,,,,,,,,,
"Root, Rhonda",0,999999999,rroot,COMP301.001.S224,,,,,,,,,,,,,,,,
"Student, Sally",0,111111111,sstudent,COMP301.001.S224,,,,,,,,,,,,,,,,
"Student, New",0,345345345,nstudent,COMP301.001.S224,,,,,,,,,,,,,,,,
"Jordan, Kris",0,89898989,kjordan,COMP301.001.S224,,,,,,,,,,,,,,,,"""
5 changes: 5 additions & 0 deletions backend/test/services/academics/section_member_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ def test_create_from_csv_remove(section_member_svc: SectionMemberService):
section_data.comp_301_001_current_term.id,
csv_data=section_data.smaller_roster_csv,
)
section_member_svc.import_users_from_csv(
user_data.instructor,
section_data.comp_301_001_current_term.id,
csv_data=section_data.extra_row_roster_csv,
)


def test_create_from_csv_not_instructor(section_member_svc: SectionMemberService):
Expand Down

0 comments on commit ae84763

Please sign in to comment.