Commit 1930af65 by Braden MacDonald

Move tests and add pylint check

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