From c311a88569214989b2409caec6dbac226ef9f91d Mon Sep 17 00:00:00 2001 From: "Adolfo R. Brandes" Date: Mon, 5 Sep 2016 18:59:10 -0300 Subject: [PATCH] Move grading test to events suite pylint correctly surmised that `test_grade` is an event test, so move it over. --- tests/integration/test_events.py | 19 ++++++++++++++++- .../test_interaction_assessment.py | 21 ------------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/tests/integration/test_events.py b/tests/integration/test_events.py index 150d4b29c..787cf5706 100644 --- a/tests/integration/test_events.py +++ b/tests/integration/test_events.py @@ -2,10 +2,13 @@ from mock import Mock, patch from selenium.webdriver.common.keys import Keys +from selenium.webdriver.common.keys import Keys + from workbench.runtime import WorkbenchRuntime from drag_and_drop_v2.default_data import ( - TOP_ZONE_TITLE, TOP_ZONE_ID, MIDDLE_ZONE_TITLE, MIDDLE_ZONE_ID, ITEM_CORRECT_FEEDBACK, ITEM_INCORRECT_FEEDBACK, + TOP_ZONE_TITLE, TOP_ZONE_ID, MIDDLE_ZONE_TITLE, MIDDLE_ZONE_ID, BOTTOM_ZONE_ID, + ITEM_CORRECT_FEEDBACK, ITEM_INCORRECT_FEEDBACK, ITEM_TOP_ZONE_NAME, ITEM_MIDDLE_ZONE_NAME, ) from tests.integration.test_base import BaseIntegrationTest, DefaultDataTestMixin, InteractionTestBase, ItemDefinition @@ -146,6 +149,20 @@ def test_event(self): self.assertEqual(name, event['name']) self.assertEqual(published_data, event['data']) + def test_grade(self): + """ + Test grading after submitting solution in assessment mode + """ + self.place_item(0, TOP_ZONE_ID, Keys.RETURN) # Correctly placed item + self.place_item(1, BOTTOM_ZONE_ID, Keys.RETURN) # Incorrectly placed item + self.place_item(4, MIDDLE_ZONE_ID, Keys.RETURN) # Incorrectly placed decoy + self.click_submit() + + events = self.publish.call_args_list + published_grade = next((event[0][2] for event in events if event[0][1] == 'grade')) + expected_grade = {'max_value': 1, 'value': (1.0 / 5.0)} + self.assertEqual(published_grade, expected_grade) + @ddt class ItemDroppedEventTest(DefaultDataTestMixin, BaseEventsTests): diff --git a/tests/integration/test_interaction_assessment.py b/tests/integration/test_interaction_assessment.py index c54c4c7be..b53af074f 100644 --- a/tests/integration/test_interaction_assessment.py +++ b/tests/integration/test_interaction_assessment.py @@ -9,7 +9,6 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.keys import Keys -from workbench.runtime import WorkbenchRuntime from xblockutils.resources import ResourceLoader from drag_and_drop_v2.default_data import ( @@ -290,26 +289,6 @@ def test_do_attempt_feedback_is_updated(self): expected_feedback = "\n".join(feedback_lines) self.assertEqual(self._get_feedback().text, expected_feedback) - def test_grade(self): - """ - Test grading after submitting solution in assessment mode - """ - mock = Mock() - context = patch.object(WorkbenchRuntime, 'publish', mock) - context.start() - self.addCleanup(context.stop) - self.publish = mock - - self.place_item(0, TOP_ZONE_ID, Keys.RETURN) # Correctly placed item - self.place_item(1, BOTTOM_ZONE_ID, Keys.RETURN) # Incorrectly placed item - self.place_item(4, MIDDLE_ZONE_ID, Keys.RETURN) # Incorrectly placed decoy - self.click_submit() - - events = self.publish.call_args_list - published_grade = next((event[0][2] for event in events if event[0][1] == 'grade')) - expected_grade = {'max_value': 1, 'value': (1.0 / 5.0)} - self.assertEqual(published_grade, expected_grade) - def test_per_item_feedback_multiple_misplaced(self): self.place_item(0, MIDDLE_ZONE_ID, Keys.RETURN) self.place_item(1, BOTTOM_ZONE_ID, Keys.RETURN)