Skip to content

Commit

Permalink
Move grading test to events suite
Browse files Browse the repository at this point in the history
pylint correctly surmised that `test_grade` is an event test, so move it
over.
  • Loading branch information
arbrandes committed Sep 13, 2016
1 parent fb3bb25 commit c311a88
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
19 changes: 18 additions & 1 deletion tests/integration/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
21 changes: 0 additions & 21 deletions tests/integration/test_interaction_assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c311a88

Please sign in to comment.