Commit 3fd86614 by Eric Fischer

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.
parent a7c2a3d9
......@@ -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
......
......@@ -236,6 +236,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()
self._apply_recalculate_subsection_grade(mock_score=None)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment