Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-drag-and-drop-v2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
xblock-drag-and-drop-v2
Commits
1930af65
Commit
1930af65
authored
Dec 15, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move tests and add pylint check
parent
f8966a18
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
35 additions
and
25 deletions
+35
-25
.travis.yml
+1
-0
drag_and_drop_v2/drag_and_drop_v2.py
+2
-2
pylintrc
+11
-5
tests/integration/test_base.py
+9
-5
tests/integration/test_custom_data_render.py
+1
-1
tests/integration/test_interaction.py
+4
-4
tests/integration/test_render.py
+1
-1
tests/integration/test_title_and_question.py
+1
-1
tests/unit/__init__.py
+0
-0
tests/unit/data/html/config_out.json
+0
-0
tests/unit/data/html/data.json
+0
-0
tests/unit/data/html/settings.json
+0
-0
tests/unit/data/old/config_out.json
+0
-0
tests/unit/data/old/data.json
+0
-0
tests/unit/data/old/settings.json
+0
-0
tests/unit/data/plain/config_out.json
+0
-0
tests/unit/data/plain/data.json
+0
-0
tests/unit/data/plain/settings.json
+0
-0
tests/unit/test_advanced.py
+4
-4
tests/unit/test_basics.py
+1
-2
No files found.
.travis.yml
View file @
1930af65
...
@@ -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
...
...
drag_and_drop_v2/drag_and_drop_v2.py
View file @
1930af65
...
@@ -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
...
...
pylintrc
View file @
1930af65
...
@@ -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
tests/integration/test_base.py
View file @
1930af65
# 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'
)))
tests/integration/test_custom_data_render.py
View file @
1930af65
from
tests.integration
.test_base
import
BaseIntegrationTest
from
.test_base
import
BaseIntegrationTest
class
TestCustomDataDragAndDropRendering
(
BaseIntegrationTest
):
class
TestCustomDataDragAndDropRendering
(
BaseIntegrationTest
):
...
...
tests/integration/test_interaction.py
View file @
1930af65
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
...
...
tests/integration/test_render.py
View file @
1930af65
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
):
...
...
tests/integration/test_title_and_question.py
View file @
1930af65
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
...
...
tests/unit/__init__.py
0 → 100644
View file @
1930af65
tests/data/html/config_out.json
→
tests/
unit/
data/html/config_out.json
View file @
1930af65
File moved
tests/data/html/data.json
→
tests/
unit/
data/html/data.json
View file @
1930af65
File moved
tests/data/html/settings.json
→
tests/
unit/
data/html/settings.json
View file @
1930af65
File moved
tests/data/old/config_out.json
→
tests/
unit/
data/old/config_out.json
View file @
1930af65
File moved
tests/data/old/data.json
→
tests/
unit/
data/old/data.json
View file @
1930af65
File moved
tests/data/old/settings.json
→
tests/
unit/
data/old/settings.json
View file @
1930af65
File moved
tests/data/plain/config_out.json
→
tests/
unit/
data/plain/config_out.json
View file @
1930af65
File moved
tests/data/plain/data.json
→
tests/
unit/
data/plain/data.json
View file @
1930af65
File moved
tests/data/plain/settings.json
→
tests/
unit/
data/plain/settings.json
View file @
1930af65
File moved
tests/test_advanced.py
→
tests/
unit/
test_advanced.py
View file @
1930af65
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
):
...
...
tests/test_basics.py
→
tests/
unit/
test_basics.py
View file @
1930af65
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
,
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment