Skip to content

Commit

Permalink
Quality and import fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
E. Kolpakov committed Aug 29, 2016
1 parent 2c78472 commit 0d61569
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 39 deletions.
6 changes: 5 additions & 1 deletion drag_and_drop_v2/drag_and_drop_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def do_attempt(self, data, suffix=''):
self._validate_do_attempt()

self.attempts += 1
# pylint: disable=fixme
# TODO: Refactor this method to "freeze" item_state and pass it to methods that need access to it.
# These implicit dependencies between methods exist because most of them use `item_state` or other
# fields, either as an "input" (i.e. read value) or as output (i.e. set value) or both. As a result,
Expand Down Expand Up @@ -480,7 +481,9 @@ def _add_msg_if_exists(ids_list, message_template, message_class):

if self.item_state or include_item_feedback:
_add_msg_if_exists(
items.correctly_placed, FeedbackMessages.correctly_placed, FeedbackMessages.MessageClasses.CORRECTLY_PLACED
items.correctly_placed,
FeedbackMessages.correctly_placed,
FeedbackMessages.MessageClasses.CORRECTLY_PLACED
)
_add_msg_if_exists(misplaced_ids, FeedbackMessages.misplaced, FeedbackMessages.MessageClasses.MISPLACED)
_add_msg_if_exists(missing_ids, FeedbackMessages.not_placed, FeedbackMessages.MessageClasses.NOT_PLACED)
Expand Down Expand Up @@ -578,6 +581,7 @@ def _mark_complete_and_publish_grade(self):
"""
Helper method to update `self.completed` and submit grade event if appropriate conditions met.
"""
# pylint: disable=fixme
# TODO: (arguable) split this method into "clean" functions (with no side effects and implicit state)
# This method implicitly depends on self.item_state (via _is_answer_correct and _get_grade)
# and also updates self.grade if some conditions are met. As a result this method implies some order of
Expand Down
5 changes: 2 additions & 3 deletions tests/integration/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
TOP_ZONE_TITLE, TOP_ZONE_ID, MIDDLE_ZONE_TITLE, MIDDLE_ZONE_ID, ITEM_CORRECT_FEEDBACK, ITEM_INCORRECT_FEEDBACK
)
from tests.integration.test_base import BaseIntegrationTest
from tests.integration.test_interaction import (
DefaultDataTestMixin, InteractionTestBase, DefaultAssessmentDataTestMixin, AssessmentTestMixin
)
from tests.integration.test_interaction import DefaultDataTestMixin, InteractionTestBase
from tests.integration.test_interaction_assessment import DefaultAssessmentDataTestMixin, AssessmentTestMixin


class BaseEventsTests(InteractionTestBase, BaseIntegrationTest):
Expand Down
32 changes: 0 additions & 32 deletions tests/integration/test_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

# Imports ###########################################################

import time
from ddt import ddt, data, unpack
from mock import patch, Mock

from selenium.common.exceptions import WebDriverException
from selenium.webdriver import ActionChains
Expand Down Expand Up @@ -487,36 +485,6 @@ def _get_scenario_xml(self): # pylint: disable=no-self-use
return "<vertical_demo><drag-and-drop-v2/></vertical_demo>"


class DefaultAssessmentDataTestMixin(DefaultDataTestMixin):
"""
Provides a test scenario with default options in assessment mode.
"""
MAX_ATTEMPTS = 5

def _get_scenario_xml(self): # pylint: disable=no-self-use
return """
<vertical_demo><drag-and-drop-v2 mode='assessment' max_attempts='{max_attempts}'/></vertical_demo>
""".format(max_attempts=self.MAX_ATTEMPTS)


class AssessmentTestMixin(object):
"""
Provides helper methods for assessment tests
"""
@staticmethod
def _wait_until_enabled(element, message=None):
wait = WebDriverWait(element, 2)
wait.until(lambda e: e.is_displayed() and e.get_attribute('disabled') is None, message)

def click_submit(self):
submit_button = self._get_submit_button()

self._wait_until_enabled(submit_button, "Submit button is not clickable")

submit_button.click()
self.wait_for_ajax()


@ddt
class StandardInteractionTest(DefaultDataTestMixin, InteractionTestBase, BaseIntegrationTest):
"""
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/test_interaction_assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def test_do_attempt_feedback_is_updated(self):
FeedbackMessages.correctly_placed(1),
FeedbackMessages.misplaced(1),
FeedbackMessages.not_placed(2),
FeedbackMessages.MISPLACED_ITEMS_RETURNED,
START_FEEDBACK
]
expected_feedback = "\n".join(feedback_lines)
Expand Down Expand Up @@ -255,4 +254,4 @@ def delayed_drop_item(item_attempt, suffix=''): # pylint: disable=unused-argume
self.assert_button_enabled(submit_button, enabled=False)
self.wait_until_ondrop_xhr_finished(self._get_placed_item_by_value(item_id))

self.assert_button_enabled(submit_button, enabled=True)
self.assert_button_enabled(submit_button, enabled=True)
2 changes: 1 addition & 1 deletion tests/unit/test_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,4 +616,4 @@ def test_do_attempt_correct_takes_decoy_into_account(self):
self._submit_solution({0: self.ZONE_1, 1: self.ZONE_2, 2: self.ZONE_2, 3: self.ZONE_2})
res = self._do_attempt()

self.assertFalse(res['correct'])
self.assertFalse(res['correct'])

0 comments on commit 0d61569

Please sign in to comment.