From 4c6f474965f20fb24cb32177ab449495da4de90a Mon Sep 17 00:00:00 2001 From: Maria Grimaldi Date: Wed, 8 May 2024 16:19:20 -0400 Subject: [PATCH] fix: rewrite tests according latest feedback/changes --- openassessment/assessment/test/test_peer.py | 25 ++++++++----------- .../xblock/test/test_grade_explanation.py | 6 +++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/openassessment/assessment/test/test_peer.py b/openassessment/assessment/test/test_peer.py index a0c5016dc0..dff71d3656 100644 --- a/openassessment/assessment/test/test_peer.py +++ b/openassessment/assessment/test/test_peer.py @@ -2335,11 +2335,11 @@ def test_get_peer_score_with_grading_strategy_raise_errors( ) @override_settings(FEATURES=FEATURES_WITH_GRADING_STRATEGY_OFF) - @patch("openassessment.assessment.api.peer.Assessment") - def test_get_peer_score_with_grading_strategy_disabled( - self, - assessment_mock - ): + @patch( + "openassessment.assessment.api.peer.Assessment.scores_by_criterion", + {"criterion_1": [6, 8, 15, 29, 37], "criterion_2": [0, 1, 2, 4, 9]} + ) + def test_get_peer_score_with_grading_strategy_disabled(self): """Test get score when grading strategy feature is off. When grading strategy is disabled, the score is calculated using the @@ -2352,21 +2352,16 @@ def test_get_peer_score_with_grading_strategy_disabled( "grading_strategy": "mean", } submission_uuid = "test_submission_uuid" - scores_by_criterion = { - "criterion_1": [6, 8, 15, 29, 37], - "criterion_2": [0, 1, 2, 4, 9] - } - assessment_mock.scores_by_criterion.return_value = scores_by_criterion - peer_api.get_assessment_scores_with_grading_strategy( + scores = peer_api.get_assessment_scores_with_grading_strategy( submission_uuid, workflow_requirements ) - assessment_mock.get_score_dict.assert_called_once_with( - scores_by_criterion, - "median" - ) + self.assertDictEqual(scores, { + "criterion_1": 15, + "criterion_2": 2 + }) def test_mean_score_calculation(self): """Test mean score calculation for peer assessments.""" diff --git a/openassessment/xblock/test/test_grade_explanation.py b/openassessment/xblock/test/test_grade_explanation.py index a33ddbd139..abac06f8cd 100644 --- a/openassessment/xblock/test/test_grade_explanation.py +++ b/openassessment/xblock/test/test_grade_explanation.py @@ -4,6 +4,8 @@ import json +from django.conf import settings +from django.test.utils import override_settings from unittest.mock import patch from ddt import ddt, data @@ -18,6 +20,9 @@ scenario ) +FEATURES_WITH_GRADING_STRATEGY_ON = settings.FEATURES.copy() +FEATURES_WITH_GRADING_STRATEGY_ON['ENABLE_ORA_PEER_CONFIGURABLE_GRADING'] = True + @ddt class TestGradeExplanation(XBlockHandlerTestCase, SubmitAssessmentsMixin, SubmissionTestMixin): @@ -68,6 +73,7 @@ def test_render_explanation_grade_staff_only(self, xblock, assessment_score_prio mock_send_staff_notification.assert_called_once() + @override_settings(FEATURES=FEATURES_WITH_GRADING_STRATEGY_OFF) @scenario("data/peer_assessment_mean_grading_strategy_scenario.xml", user_id='Bernard') def test_render_grade_explanation_peer_only_mean_calculation(self, xblock): self.create_submission_and_assessments(