diff --git a/lms/services/dashboard.py b/lms/services/dashboard.py index 9df963fed2..12cbd18e99 100644 --- a/lms/services/dashboard.py +++ b/lms/services/dashboard.py @@ -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 diff --git a/lms/services/roster.py b/lms/services/roster.py index e37aca76be..3d1e568971 100644 --- a/lms/services/roster.py +++ b/lms/services/roster.py @@ -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) diff --git a/tests/unit/lms/services/dashboard_test.py b/tests/unit/lms/services/dashboard_test.py index a2cf20e5d3..a8bc8a81ac 100644 --- a/tests/unit/lms/services/dashboard_test.py +++ b/tests/unit/lms/services/dashboard_test.py @@ -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) @@ -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 diff --git a/tests/unit/lms/services/roster_test.py b/tests/unit/lms/services/roster_test.py index a872cfe79f..6cc5e8cce9 100644 --- a/tests/unit/lms/services/roster_test.py +++ b/tests/unit/lms/services/roster_test.py @@ -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() @@ -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])