Commit 1930af65 by Braden MacDonald

Move tests and add pylint check

parent f8966a18
......@@ -11,6 +11,7 @@ install:
- "pip install dist/xblock-drag-and-drop-v2-0.1.tar.gz"
script:
- pep8 drag_and_drop_v2 tests --max-line-length=120
- pylint drag_and_drop_v2 tests
- python run_tests.py
notifications:
email: false
......
......@@ -12,7 +12,7 @@ from xblock.core import XBlock
from xblock.fields import Scope, String, Dict, Float, Boolean
from xblock.fragment import Fragment
from .utils import _, render_template, load_resource
from .utils import _, render_template, load_resource # pylint: disable=unused-import
from .default_data import DEFAULT_DATA
......@@ -309,7 +309,7 @@ class DragAndDropBlock(XBlock):
# edX Studio uses a different runtime for 'studio_view' than 'student_view',
# and the 'studio_view' runtime doesn't provide the replace_urls API.
try:
from static_replace import replace_static_urls
from static_replace import replace_static_urls # pylint: disable=import-error
url = replace_static_urls('"{}"'.format(url), None, course_id=self.runtime.course_id)[1:-1]
except ImportError:
pass
......
......@@ -6,11 +6,17 @@ max-line-length=120
[MESSAGES CONTROL]
disable=
attribute-defined-outside-init,
locally-disabled,
missing-docstring,
too-many-ancestors,
too-many-arguments,
too-many-instance-attributes,
too-few-public-methods,
too-many-public-methods,
unused-argument
unused-argument,
invalid-name,
no-member
[SIMILARITIES]
min-similarity-lines=8
# Imports ###########################################################
from xml.sax.saxutils import escape
from selenium.webdriver.support.ui import WebDriverWait
from tests.utils import load_resource
from ..utils import load_resource
from workbench import scenarios
......@@ -19,7 +19,8 @@ class BaseIntegrationTest(SeleniumBaseTest):
"'": "'"
}
def _make_scenario_xml(self, display_name, show_title, question_text, completed=False, show_question_header=True):
@staticmethod
def _make_scenario_xml(display_name, show_title, question_text, completed=False, show_question_header=True):
return """
<vertical_demo>
<drag-and-drop-v2
......@@ -62,10 +63,12 @@ class BaseIntegrationTest(SeleniumBaseTest):
def scroll_down(self, pixels=50):
self.browser.execute_script("$(window).scrollTop({})".format(pixels))
def get_element_html(self, element):
@staticmethod
def get_element_html(element):
return element.get_attribute('innerHTML').strip()
def get_element_classes(self, element):
@staticmethod
def get_element_classes(element):
return element.get_attribute('class').split()
def wait_until_html_in(self, html, elem):
......@@ -73,7 +76,8 @@ class BaseIntegrationTest(SeleniumBaseTest):
wait.until(lambda e: html in e.get_attribute('innerHTML'),
u"{} should be in {}".format(html, elem.get_attribute('innerHTML')))
def wait_until_has_class(self, class_name, elem):
@staticmethod
def wait_until_has_class(class_name, elem):
wait = WebDriverWait(elem, 2)
wait.until(lambda e: class_name in e.get_attribute('class').split(),
u"Class name {} not in {}".format(class_name, elem.get_attribute('class')))
from tests.integration.test_base import BaseIntegrationTest
from .test_base import BaseIntegrationTest
class TestCustomDataDragAndDropRendering(BaseIntegrationTest):
......
from selenium.webdriver import ActionChains
from tests.integration.test_base import BaseIntegrationTest
from .test_base import BaseIntegrationTest
class ItemDefinition(object):
def __init__(self, item_id, zone_id, feedback_positive, feedback_negative, input=None):
def __init__(self, item_id, zone_id, feedback_positive, feedback_negative, input_value=None):
self.feedback_negative = feedback_negative
self.feedback_positive = feedback_positive
self.zone_id = zone_id
self.item_id = item_id
self.input = input
self.input = input_value
class InteractionTestFixture(object):
......@@ -32,7 +32,7 @@ class InteractionTestFixture(object):
"final": "Good work! You have completed this drag and drop exercise."
}
def _get_scenario_xml(self):
def _get_scenario_xml(self): # pylint: disable=no-self-use
return "<vertical_demo><drag-and-drop-v2/></vertical_demo>"
@classmethod
......
from ddt import ddt, unpack, data
from tests.integration.test_base import BaseIntegrationTest
from .test_base import BaseIntegrationTest
class Colors(object):
......
from ddt import ddt, unpack, data
from selenium.common.exceptions import NoSuchElementException
from tests.integration.test_base import BaseIntegrationTest
from .test_base import BaseIntegrationTest
from workbench import scenarios
......
import json
import unittest
from .utils import (
from ..utils import (
make_block,
load_resource,
TestCaseMixin,
......@@ -32,15 +32,15 @@ class BaseDragAndDropAjaxFixture(TestCaseMixin):
@classmethod
def initial_data(cls):
return json.loads(load_resource('data/{}/data.json'.format(cls.FOLDER)))
return json.loads(load_resource('unit/data/{}/data.json'.format(cls.FOLDER)))
@classmethod
def initial_settings(cls):
return json.loads(load_resource('data/{}/settings.json'.format(cls.FOLDER)))
return json.loads(load_resource('unit/data/{}/settings.json'.format(cls.FOLDER)))
@classmethod
def expected_configuration(cls):
return json.loads(load_resource('data/{}/config_out.json'.format(cls.FOLDER)))
return json.loads(load_resource('unit/data/{}/config_out.json'.format(cls.FOLDER)))
@classmethod
def initial_feedback(cls):
......
import unittest
from .utils import (
from ..utils import (
DEFAULT_START_FEEDBACK,
DEFAULT_FINISH_FEEDBACK,
make_request,
make_block,
TestCaseMixin,
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment