sub_api get_score return value is a dict
This access pattern was wrong, and was causing errors in production. I've included an additional happy-path test.
This commit is contained in:
@@ -146,7 +146,7 @@ def _has_database_updated_with_new_score(
|
||||
if api_score is None:
|
||||
# Same case as the initial 'if' above, for submissions-specific scores
|
||||
return score_deleted
|
||||
reported_modified_time = api_score.created_at
|
||||
reported_modified_time = api_score['created_at']
|
||||
else:
|
||||
reported_modified_time = score.modified
|
||||
|
||||
|
||||
@@ -235,6 +235,18 @@ class RecalculateSubsectionGradeTest(ModuleStoreTestCase):
|
||||
)
|
||||
self._assert_retry_called(mock_retry)
|
||||
|
||||
@patch('lms.djangoapps.grades.tasks.recalculate_subsection_grade_v2.retry')
|
||||
def test_retry_subsection_grade_on_update_not_complete_sub(self, mock_retry):
|
||||
self.set_up_course()
|
||||
with patch('lms.djangoapps.grades.tasks.sub_api.get_score') as mock_sub_score:
|
||||
mock_sub_score.return_value = {
|
||||
'created_at': datetime.utcnow().replace(tzinfo=pytz.UTC) - timedelta(days=1)
|
||||
}
|
||||
self._apply_recalculate_subsection_grade(
|
||||
mock_score=MagicMock(module_type='openassessment')
|
||||
)
|
||||
self._assert_retry_called(mock_retry)
|
||||
|
||||
@patch('lms.djangoapps.grades.tasks.recalculate_subsection_grade_v2.retry')
|
||||
def test_retry_subsection_grade_on_no_score(self, mock_retry):
|
||||
self.set_up_course()
|
||||
|
||||
Reference in New Issue
Block a user