Skip to content

Commit

Permalink
Change roster service method name
Browse files Browse the repository at this point in the history
From assignment_roster_exists to assignment_roster_last_updated

Co-authored-by: Alejandro Celaya <[email protected]>
  • Loading branch information
marcospri and acelaya committed Dec 16, 2024
1 parent 21cde1c commit a9adfab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 3 additions & 1 deletion lms/services/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ def get_assignment_roster(
"dashboard", "rosters"
)
)
roster_last_updated = self._roster_service.assignment_roster_exists(assignment)
roster_last_updated = self._roster_service.assignment_roster_last_updated(
assignment
)

if rosters_enabled and roster_last_updated:
# If rostering is enabled and we do have the data, use it
Expand Down
8 changes: 2 additions & 6 deletions lms/services/roster.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,8 @@ def get_course_roster(

return select(LMSUser).where(LMSUser.id.in_(roster_query))

def assignment_roster_exists(self, assignment: Assignment) -> datetime | None:
"""
Check if we have roster data for the given assignment.
In case we have roster data, return the last updated timestamp, None otherwise.
"""
def assignment_roster_last_updated(self, assignment: Assignment) -> datetime | None:
"""Return the roster's last updated timestamp for given assignment, or None if we don't have roster data."""
return self._db.scalar(
select(AssignmentRoster.updated)
.where(AssignmentRoster.assignment_id == assignment.id)
Expand Down
7 changes: 5 additions & 2 deletions tests/unit/lms/services/dashboard_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def test_get_assignment_roster_with_roster_disabled(
course=factories.Course(application_instance=application_instance)
)
if not roster_available:
roster_service.assignment_roster_exists.return_value = None
roster_service.assignment_roster_last_updated.return_value = None

last_updated, roster = svc.get_assignment_roster(assignment, sentinel.h_userids)

Expand All @@ -256,7 +256,10 @@ def test_get_assignment_roster_with_roster_disabled(
role_type=RoleType.LEARNER,
h_userids=sentinel.h_userids,
)
assert last_updated == roster_service.assignment_roster_exists.return_value
assert (
last_updated
== roster_service.assignment_roster_last_updated.return_value
)
assert (
roster
== roster_service.get_assignment_roster.return_value.order_by.return_value
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/lms/services/roster_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TestRosterService:
"create_roster,expected",
[(True, datetime(2021, 1, 1)), (False, None)],
)
def test_assignment_roster_exists(
def test_assignment_roster_last_updated(
self, svc, assignment, db_session, create_roster, expected
):
lms_user = factories.LMSUser()
Expand All @@ -32,7 +32,7 @@ def test_assignment_roster_exists(
)
db_session.flush()

assert svc.assignment_roster_exists(assignment) == expected
assert svc.assignment_roster_last_updated(assignment) == expected

@pytest.mark.parametrize("with_role_scope", [True, False])
@pytest.mark.parametrize("with_role_type", [True, False])
Expand Down

0 comments on commit a9adfab

Please sign in to comment.