fix: Restructuring to send course_id and score to edx submission fix: Refactoring of sending information to sent_to_submission fix: Elimination of unnecessary functions fix: Added usage comment to ProblemBlock in XqueueInterface constructor fix: update doc ADR fix: setting for Quality Others test (ubuntu-24.04, 3.11, 20) fix: Deprecation for django-trans-escape-filter-parse-error test: Add @pytest.mark.django_db decorator to test functions test: Fix for pylint being disabled fix: updated changes for pylint disable fix: update error from docs ADR-0005 update: xmodule/docs/decisions/0005-send-data-to-edx-submission.rst Co-authored-by: Sarina Canelake <sarina@axim.org> update: xmodule/docs/decisions/0005-send-data-to-edx-submission.rst Co-authored-by: Sarina Canelake <sarina@axim.org> fix: Adjusted correction fix: update date for docs ADR Revert "fix: update date for docs ADR" This reverts commit 0b4229c51c4937f95cb407872645dd448df45418. fix: replace call created_submission to create_external_grader_detail fix: update test xqueue_submission fix: add docstring in test_xqueue_submission fix: update date doc ADR fix: update version edx-submission 3.8.6 fix: add @pytest.mark.xfail fix: add 20 chances in test_capa_block: fix: increase retry attempts for seed generation in ProblemBlockTest fix: change version to edx-submission lib fix: new version edx-submission in testings fix: replace parameter file to files fix: update variable grader_file_name and points_possible fix: Adjustment in the is_flag_active function to always take the last record edited in the waffle fix: wrap large line of code fix: update function is_flag_active fix: code style adjustment fix: changes for 60 retry feat: use CourseWaffleFlag to determine xqueue callback path fix: Code style adjustment fix: remove deprecated xqueue callback route and simplify callback type logic fix: Deleting a comment in the ADR document fix: add log in self.block is None fix: Code style adjustment in log
58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
"""
|
|
Unit tests for custom error handling in the XQueue submission interface.
|
|
"""
|
|
|
|
import pytest
|
|
from xmodule.capa.errors import (
|
|
JSONParsingError,
|
|
MissingKeyError,
|
|
ValidationError,
|
|
TypeErrorSubmission,
|
|
RuntimeErrorSubmission,
|
|
GetSubmissionParamsError
|
|
)
|
|
|
|
|
|
def test_json_parsing_error():
|
|
with pytest.raises(JSONParsingError) as excinfo:
|
|
raise JSONParsingError("test_name", "test_error")
|
|
assert str(excinfo.value) == "Error parsing test_name: test_error"
|
|
|
|
|
|
def test_missing_key_error():
|
|
with pytest.raises(MissingKeyError) as excinfo:
|
|
raise MissingKeyError("test_key")
|
|
assert str(excinfo.value) == "Missing key: test_key"
|
|
|
|
|
|
def test_validation_error():
|
|
with pytest.raises(ValidationError) as excinfo:
|
|
raise ValidationError("test_error")
|
|
assert str(excinfo.value) == "Validation error: test_error"
|
|
|
|
|
|
def test_type_error_submission():
|
|
with pytest.raises(TypeErrorSubmission) as excinfo:
|
|
raise TypeErrorSubmission("test_error")
|
|
assert str(excinfo.value) == "Type error: test_error"
|
|
|
|
|
|
def test_runtime_error_submission():
|
|
with pytest.raises(RuntimeErrorSubmission) as excinfo:
|
|
raise RuntimeErrorSubmission("test_error")
|
|
assert str(excinfo.value) == "Runtime error: test_error"
|
|
|
|
|
|
def test_get_submission_params_error_default():
|
|
"""Test GetSubmissionParamsError with default message."""
|
|
with pytest.raises(GetSubmissionParamsError) as excinfo:
|
|
raise GetSubmissionParamsError()
|
|
assert str(excinfo.value) == "Submission parameters error: Block instance is not defined!"
|
|
|
|
|
|
def test_get_submission_params_error_custom():
|
|
"""Test GetSubmissionParamsError with a custom error message."""
|
|
with pytest.raises(GetSubmissionParamsError) as excinfo:
|
|
raise GetSubmissionParamsError("Custom error message")
|
|
assert str(excinfo.value) == "Submission parameters error: Custom error message"
|