-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Show error if unable to connect to xqueue #1875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -253,7 +253,7 @@ def setUp(self): | |
| self.test_system.open_ended_grading_interface = None | ||
| self.test_system.location = self.location | ||
| self.mock_xqueue = MagicMock() | ||
| self.mock_xqueue.send_to_queue.return_value = (None, "Message") | ||
| self.mock_xqueue.send_to_queue.return_value = (0, "Queued") | ||
|
|
||
| def constructed_callback(dispatch="score_update"): | ||
| return dispatch | ||
|
|
@@ -286,7 +286,32 @@ def test_message_post(self): | |
| self.mock_xqueue.send_to_queue.assert_called_with(body=json.dumps(contents), header=ANY) | ||
|
|
||
| state = json.loads(self.openendedmodule.get_instance_state()) | ||
| self.assertIsNotNone(state['child_state'], OpenEndedModule.DONE) | ||
| self.assertEqual(state['child_state'], OpenEndedModule.DONE) | ||
|
|
||
| def test_message_post_fail(self): | ||
| """Test message_post() if unable to send feedback to xqueue.""" | ||
|
|
||
| get = {'feedback': 'feedback text', | ||
| 'submission_id': '1', | ||
| 'grader_id': '1', | ||
| 'score': 3} | ||
| qtime = datetime.strftime(datetime.now(UTC), xqueue_interface.dateformat) | ||
| student_info = {'anonymous_student_id': self.test_system.anonymous_student_id, | ||
| 'submission_time': qtime} | ||
| contents = { | ||
| 'feedback': get['feedback'], | ||
| 'submission_id': int(get['submission_id']), | ||
| 'grader_id': int(get['grader_id']), | ||
| 'score': get['score'], | ||
| 'student_info': json.dumps(student_info) | ||
| } | ||
|
|
||
| self.mock_xqueue.send_to_queue.return_value = (1, "Not Queued") | ||
| result = self.openendedmodule.message_post(get, self.test_system) | ||
| self.assertFalse(result['success']) | ||
|
|
||
| state = json.loads(self.openendedmodule.get_instance_state()) | ||
| self.assertNotEqual(state['child_state'], OpenEndedModule.DONE) | ||
|
|
||
| def test_send_to_grader(self): | ||
| submission = "This is a student submission" | ||
|
|
@@ -299,10 +324,41 @@ def test_send_to_grader(self): | |
| 'student_response': submission, | ||
| 'max_score': self.max_score | ||
| }) | ||
| result = self.openendedmodule.send_to_grader(submission, self.test_system) | ||
| result, __ = self.openendedmodule.send_to_grader(submission, self.test_system) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use only one underscore |
||
| self.assertTrue(result) | ||
| self.mock_xqueue.send_to_queue.assert_called_with(body=json.dumps(contents), header=ANY) | ||
|
|
||
| def test_send_to_grader_fail(self): | ||
| """Test send_to_grader() if unable to send submission to xqueue.""" | ||
|
|
||
| submission = "This is a student submission" | ||
| qtime = datetime.strftime(datetime.now(UTC), xqueue_interface.dateformat) | ||
| student_info = {'anonymous_student_id': self.test_system.anonymous_student_id, | ||
| 'submission_time': qtime} | ||
| contents = self.openendedmodule.payload.copy() | ||
| contents.update({ | ||
| 'student_info': json.dumps(student_info), | ||
| 'student_response': submission, | ||
| 'max_score': self.max_score | ||
| }) | ||
| self.mock_xqueue.send_to_queue.return_value = (1, "Not Queued") | ||
| result, __ = self.openendedmodule.send_to_grader(submission, self.test_system) | ||
| self.assertFalse(result) | ||
|
|
||
| def test_save_answer_fail(self): | ||
| """Test save_answer() if unable to send submission to grader.""" | ||
|
|
||
| submission = "This is a student submission" | ||
| self.openendedmodule.send_to_grader = Mock(return_value=(False, "Failed")) | ||
| response = self.openendedmodule.save_answer( | ||
| {"student_answer": submission}, | ||
| get_test_system() | ||
| ) | ||
| self.assertFalse(response['success']) | ||
| self.assertNotEqual(self.openendedmodule.latest_answer(), submission) | ||
| state = json.loads(self.openendedmodule.get_instance_state()) | ||
| self.assertEqual(state['child_state'], OpenEndedModule.INITIAL) | ||
|
|
||
| def update_score_single(self): | ||
| self.openendedmodule.new_history_entry("New Entry") | ||
| get = {'queuekey': "abcd", | ||
|
|
@@ -377,7 +433,7 @@ def test_open_ended_display(self): | |
| self.assertEqual(test_module.get_display_answer(), saved_response) | ||
|
|
||
| # Mock out the send_to_grader function so it doesn't try to connect to the xqueue. | ||
| test_module.send_to_grader = Mock(return_value=True) | ||
| test_module.send_to_grader = Mock(return_value=(True, "Success")) | ||
| # Submit a student response to the question. | ||
| test_module.handle_ajax( | ||
| "save_answer", | ||
|
|
@@ -901,7 +957,7 @@ def get_module_system(self, descriptor): | |
| test_system = get_test_system() | ||
| test_system.open_ended_grading_interface = None | ||
| test_system.xqueue['interface'] = Mock( | ||
| send_to_queue=Mock(side_effect=[1, "queued"]) | ||
| send_to_queue=Mock(return_value=(0, "Queued")) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. send_to_queue() returns (error_code, message) where error_code != 0 indicates an error. |
||
| ) | ||
|
|
||
| return test_system | ||
|
|
@@ -1062,7 +1118,7 @@ def get_module_system(self, descriptor): | |
| test_system = get_test_system() | ||
| test_system.open_ended_grading_interface = None | ||
| test_system.xqueue['interface'] = Mock( | ||
| send_to_queue=Mock(side_effect=[1, "queued"]) | ||
| send_to_queue=Mock(return_value=(0, "Queued")) | ||
| ) | ||
| return test_system | ||
|
|
||
|
|
@@ -1136,7 +1192,7 @@ def get_module_system(self, descriptor): | |
| test_system.open_ended_grading_interface = None | ||
| test_system.s3_interface = test_util_open_ended.S3_INTERFACE | ||
| test_system.xqueue['interface'] = Mock( | ||
| send_to_queue=Mock(side_effect=[1, "queued"]) | ||
| send_to_queue=Mock(return_value=(0, "Queued")) | ||
| ) | ||
| return test_system | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we losing this information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it isn't being saved anywhere. But having gone through ORA a bit more the last few days I realize if this was being stored it would have been trivial to match submissions across the two databases.