Skip to content

Commit

Permalink
fix: rewrite tests according latest feedback/changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi committed May 8, 2024
1 parent 9ba4f80 commit 4c6f474
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
25 changes: 10 additions & 15 deletions openassessment/assessment/test/test_peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."""
Expand Down
6 changes: 6 additions & 0 deletions openassessment/xblock/test/test_grade_explanation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 4c6f474

Please sign in to comment.