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
b1c94160
Commit
b1c94160
authored
Jan 18, 2016
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for backwards compatibility
parent
dfdecfb6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
0 deletions
+116
-0
tests/integration/data/old_version_data.json
+81
-0
tests/integration/test_sizing.py
+35
-0
No files found.
tests/integration/data/old_version_data.json
0 → 100644
View file @
b1c94160
{
"question_text"
:
"Note: This is an example of data in the format used by prior versions of this block. Not in particular the old `size` data."
,
"zones"
:
[
{
"index"
:
1
,
"width"
:
200
,
"title"
:
"Zone 1"
,
"height"
:
100
,
"y"
:
"200"
,
"x"
:
"100"
,
"id"
:
"zone-1"
},
{
"index"
:
2
,
"width"
:
200
,
"title"
:
"Zone 2"
,
"height"
:
100
,
"y"
:
0
,
"x"
:
0
,
"id"
:
"zone-2"
}
],
"items"
:
[
{
"displayName"
:
"1"
,
"feedback"
:
{
"incorrect"
:
"No 1"
,
"correct"
:
"Yes 1"
},
"zone"
:
"Zone 1"
,
"backgroundImage"
:
""
,
"id"
:
0
,
"size"
:
{
"width"
:
"190px"
,
"height"
:
"auto"
}
},
{
"displayName"
:
"2"
,
"feedback"
:
{
"incorrect"
:
"No 2"
,
"correct"
:
"Yes 2"
},
"zone"
:
"Zone 2"
,
"backgroundImage"
:
""
,
"id"
:
1
,
"size"
:
{
"width"
:
"190px"
,
"height"
:
"100px"
},
"inputOptions"
:
{
"value"
:
100
,
"margin"
:
5
}
},
{
"displayName"
:
"Pic"
,
"feedback"
:
{
"incorrect"
:
""
,
"correct"
:
""
},
"zone"
:
"Zone 1"
,
"backgroundImage"
:
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNjAwIiBzdHlsZT0iYmFja2dyb3VuZDogI2VlZjsiPjwvc3ZnPg=="
,
"id"
:
2
,
"size"
:
{
"width"
:
"100px"
,
"height"
:
"auto"
}
}
],
"state"
:
{
"items"
:
{},
"finished"
:
true
},
"feedback"
:
{
"start"
:
"Intro Feedback"
,
"finish"
:
"Final Feedback"
},
"title"
:
"Drag and Drop (Old-style data)"
}
\ No newline at end of file
tests/integration/test_sizing.py
View file @
b1c94160
...
...
@@ -191,3 +191,38 @@ class SizingTests(InteractionTestBase, BaseIntegrationTest):
container_width
=
target_img_width
,
expected_percent
=
expected_width_percent
,
)
class
SizingBackwardsCompatibilityTests
(
InteractionTestBase
,
BaseIntegrationTest
):
"""
Test backwards compatibility with data generated in older versions of this block.
Older versions allowed authors to specify a fixed width and height for each draggable, in
pixels (new versions only have a configurable width, and it is a percent width).
"""
PAGE_TITLE
=
'Drag and Drop v2 Sizing Backwards Compatibility'
PAGE_ID
=
'drag_and_drop_v2_sizing_backwards_compatibility'
@staticmethod
def
_get_scenario_xml
():
"""
Set up the test scenario:
* One DndDv2 block using 'old_version_data.json'
"""
dnd_block
=
"<drag-and-drop-v2 data='{data}'/>"
.
format
(
data
=
loader
.
load_unicode
(
"data/old_version_data.json"
)
)
return
"<vertical_demo>{}</vertical_demo>"
.
format
(
dnd_block
)
def
test_draggable_sizes
(
self
):
""" Test the fixed pixel widths set in old versions of the block """
self
.
_expect_width_px
(
item_id
=
0
,
width_px
=
190
,
zone_id
=
"Zone 1"
)
self
.
_expect_width_px
(
item_id
=
1
,
width_px
=
190
,
zone_id
=
"Zone 2"
)
self
.
_expect_width_px
(
item_id
=
2
,
width_px
=
100
,
zone_id
=
"Zone 1"
)
def
_expect_width_px
(
self
,
item_id
,
width_px
,
zone_id
):
item
=
self
.
_get_unplaced_item_by_value
(
item_id
)
self
.
assertEqual
(
item
.
size
[
"width"
],
width_px
)
self
.
place_item
(
item_id
,
zone_id
)
item
=
self
.
_get_placed_item_by_value
(
item_id
)
self
.
assertEqual
(
item
.
size
[
"width"
],
width_px
)
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