Skip to content

Commit

Permalink
Exclude empty titled assignments from get_assignments
Browse files Browse the repository at this point in the history
Most of this come from the original creation of the table, where we only
had the title IDs.
  • Loading branch information
marcospri committed Jul 31, 2024
1 parent 9ca2539 commit ef01c41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lms/services/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ def get_assignments(
:param course_ids: only return assignments that belong to this course.
:param h_userids: return only assignments where these users are members.
"""

query = select(Assignment)
query = select(Assignment).where(Assignment.title.is_not(None))

# Let's crate no op clauses by default to avoid having to check the presence of these filters
instructor_h_userid_clause = cast(BinaryExpression, false())
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/lms/services/assignment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,18 @@ def test_get_assignments(

assert db_session.scalars(query).all() == [assignment]

def test_get_assignments_excludes_empty_titles(self, db_session, svc):
course = factories.Course()
assignment = factories.Assignment(title=None)
factories.AssignmentGrouping(
grouping=course, assignment=assignment, updated=date(2022, 1, 1)
)
db_session.flush()

assert not db_session.scalars(
svc.get_assignments(course_ids=[course.id])
).all() == [assignment]

def test_get_assignments_by_course_id_with_duplicate(
self, db_session, svc, application_instance, organization
):
Expand Down

0 comments on commit ef01c41

Please sign in to comment.