Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-utils
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
edx
xblock-utils
Commits
213a97a5
Commit
213a97a5
authored
Jun 17, 2015
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #21 from open-craft/smarnach/update-xblock-hash
Update XBlock commit hash to latest version.
parents
e8a6b014
22675a3f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
21 deletions
+32
-21
requirements.txt
+1
-2
tests/integration/test_studio_editable.py
+23
-14
tests/unit/test_helpers.py
+8
-5
No files found.
requirements.txt
View file @
213a97a5
...
...
@@ -3,5 +3,4 @@
# XBlock
# This is not in/from PyPi, since it moves fast
-e git+https://github.com/edx/XBlock.git@8e496cff186ed33cf92964faab13ccb3691ee211#egg=XBlock
-e git+https://github.com/edx/XBlock.git@tag-master-2015-05-22#egg=XBlock
tests/integration/test_studio_editable.py
View file @
213a97a5
...
...
@@ -29,12 +29,12 @@ class TestEditableXBlock_StudioView(StudioEditableBaseTest):
"""
Test the Studio View created for EditableXBlock
"""
@XBlock.register_temp_plugin
(
EditableXBlock
,
"editable"
)
def
setUp
(
self
):
super
(
TestEditableXBlock_StudioView
,
self
)
.
setUp
()
def
set_up_root_block
(
self
):
self
.
set_scenario_xml
(
'<editable />'
)
self
.
go_to_view
(
"studio_view"
)
self
.
fix_js_environment
()
return
self
.
load_root_xblock
()
def
assert_unchanged
(
self
,
block
,
orig_field_values
=
None
,
explicitly_set
=
False
):
"""
...
...
@@ -48,21 +48,23 @@ class TestEditableXBlock_StudioView(StudioEditableBaseTest):
self
.
assertEqual
(
getattr
(
block
,
field_name
),
expected_value
)
self
.
assertEqual
(
block
.
fields
[
field_name
]
.
is_set_on
(
block
),
explicitly_set
)
@XBlock.register_temp_plugin
(
EditableXBlock
,
"editable"
)
def
test_no_changes_with_defaults
(
self
):
"""
If we load the edit form and then save right away, there should be no changes.
"""
block
=
self
.
load_root_x
block
()
block
=
self
.
set_up_root_
block
()
orig_values
=
{
field_name
:
getattr
(
block
,
field_name
)
for
field_name
in
EditableXBlock
.
editable_fields
}
self
.
click_save
()
self
.
assert_unchanged
(
block
,
orig_values
)
@XBlock.register_temp_plugin
(
EditableXBlock
,
"editable"
)
def
test_no_changes_with_values_set
(
self
):
"""
If the XBlock already has explicit values set, and we load the edit form and then save
right away, there should be no changes.
"""
block
=
self
.
load_root_x
block
()
block
=
self
.
set_up_root_
block
()
block
.
color
=
"green"
block
.
count
=
5
block
.
comment
=
"Hello"
...
...
@@ -76,12 +78,13 @@ class TestEditableXBlock_StudioView(StudioEditableBaseTest):
block
=
self
.
load_root_xblock
()
# Need to reload the block to bypass its cache
self
.
assert_unchanged
(
block
,
orig_values
,
explicitly_set
=
True
)
@XBlock.register_temp_plugin
(
EditableXBlock
,
"editable"
)
def
test_explicit_overrides
(
self
):
"""
Test that we can override the defaults with the same value as the default, and that the
value will be saved explicitly.
"""
block
=
self
.
load_root_x
block
()
block
=
self
.
set_up_root_
block
()
self
.
assert_unchanged
(
block
)
field_names
=
EditableXBlock
.
editable_fields
...
...
@@ -99,11 +102,12 @@ class TestEditableXBlock_StudioView(StudioEditableBaseTest):
self
.
click_save
()
self
.
assert_unchanged
(
block
,
explicitly_set
=
True
)
@XBlock.register_temp_plugin
(
EditableXBlock
,
"editable"
)
def
test_set_and_reset
(
self
):
"""
Test that we can set values, save, then reset to defaults.
"""
block
=
self
.
load_root_x
block
()
block
=
self
.
set_up_root_
block
()
self
.
assert_unchanged
(
block
)
for
field_name
in
EditableXBlock
.
editable_fields
:
...
...
@@ -126,6 +130,7 @@ class TestEditableXBlock_StudioView(StudioEditableBaseTest):
block
=
self
.
load_root_xblock
()
# Need to reload the block to bypass its cache
self
.
assert_unchanged
(
block
)
@XBlock.register_temp_plugin
(
EditableXBlock
,
"editable"
)
def
test_invalid_data
(
self
):
"""
Test that we get notified when there's a problem with our data.
...
...
@@ -136,6 +141,8 @@ class TestEditableXBlock_StudioView(StudioEditableBaseTest):
self
.
assertEqual
(
notification
[
1
][
"title"
],
"Unable to update settings"
)
self
.
assertEqual
(
notification
[
1
][
"message"
],
expected_message
)
block
=
self
.
set_up_root_block
()
color_control
=
self
.
get_element_for_field
(
'color'
)
color_control
.
clear
()
color_control
.
send_keys
(
'orange'
)
...
...
@@ -210,7 +217,7 @@ class FancyXBlock(StudioEditableXBlockMixin, XBlock):
list_values_provider
=
fancy_list_values_provider_b
,
default
=
[
"alex"
],
)
string_normal
=
String
(
display_name
=
"Normal String Field"
)
string_values
=
String
(
display_name
=
"String Field With Values"
,
default
=
"A"
,
values
=
(
"A"
,
"B"
,
"C"
,
"D"
))
string_values_provider
=
String
(
...
...
@@ -248,30 +255,32 @@ class TestFancyXBlock_StudioView(StudioEditableBaseTest):
"""
Test the Studio View created for FancyXBlock
"""
@XBlock.register_temp_plugin
(
FancyXBlock
,
"fancy"
)
def
setUp
(
self
):
super
(
TestFancyXBlock_StudioView
,
self
)
.
setUp
()
self
.
set_scenario_xml
(
"<fancy/>"
)
def
set_up_root_block
(
self
):
self
.
set_scenario_xml
(
'<fancy />'
)
self
.
go_to_view
(
"studio_view"
)
self
.
fix_js_environment
()
return
self
.
load_root_xblock
()
@XBlock.register_temp_plugin
(
FancyXBlock
,
"fancy"
)
def
test_no_changes_with_defaults
(
self
):
"""
If we load the edit form and then save right away, there should be no changes.
"""
block
=
self
.
load_root_x
block
()
block
=
self
.
set_up_root_
block
()
orig_values
=
{
field_name
:
getattr
(
block
,
field_name
)
for
field_name
in
FancyXBlock
.
editable_fields
}
self
.
click_save
()
for
field_name
in
FancyXBlock
.
editable_fields
:
self
.
assertEqual
(
getattr
(
block
,
field_name
),
orig_values
[
field_name
])
self
.
assertFalse
(
block
.
fields
[
field_name
]
.
is_set_on
(
block
))
@XBlock.register_temp_plugin
(
FancyXBlock
,
"fancy"
)
def
test_no_changes_with_values_set
(
self
):
"""
If the XBlock already has explicit values set, and we load the edit form and then save
right away, there should be no changes.
"""
block
=
self
.
load_root_x
block
()
block
=
self
.
set_up_root_
block
()
block
.
bool_normal
=
True
block
.
dict_normal
=
{
"more"
:
"cowbell"
}
block
.
float_normal
=
17.0
...
...
tests/unit/test_helpers.py
View file @
213a97a5
...
...
@@ -31,18 +31,16 @@ class TestChildIsInstance(unittest.TestCase):
"""
Test child_isinstance helper method, in the workbench runtime.
"""
@XBlock.register_temp_plugin
(
GoldenRetrieverXBlock
,
"gr"
)
@XBlock.register_temp_plugin
(
CatXBlock
,
"cat"
)
@XBlock.register_temp_plugin
(
BasicXBlock
,
"block"
)
def
setUp
(
self
):
super
(
TestChildIsInstance
,
self
)
.
setUp
()
self
.
runtime
=
WorkbenchRuntime
()
self
.
root_id
=
self
.
runtime
.
parse_xml_string
(
'<block> <block><cat/><gr/></block> <cat/> <gr/> </block>'
)
def
test_child_isinstance
(
self
):
"""
Check that child_isinstance() works on direct children
"""
self
.
runtime
=
WorkbenchRuntime
()
self
.
root_id
=
self
.
runtime
.
parse_xml_string
(
'<block> <block><cat/><gr/></block> <cat/> <gr/> </block>'
)
root
=
self
.
runtime
.
get_block
(
self
.
root_id
)
self
.
assertFalse
(
child_isinstance
(
root
,
root
.
children
[
0
],
DogXBlock
))
self
.
assertFalse
(
child_isinstance
(
root
,
root
.
children
[
0
],
GoldenRetrieverXBlock
))
...
...
@@ -56,10 +54,15 @@ class TestChildIsInstance(unittest.TestCase):
self
.
assertTrue
(
child_isinstance
(
root
,
root
.
children
[
2
],
DogXBlock
))
self
.
assertTrue
(
child_isinstance
(
root
,
root
.
children
[
2
],
GoldenRetrieverXBlock
))
@XBlock.register_temp_plugin
(
GoldenRetrieverXBlock
,
"gr"
)
@XBlock.register_temp_plugin
(
CatXBlock
,
"cat"
)
@XBlock.register_temp_plugin
(
BasicXBlock
,
"block"
)
def
test_child_isinstance_descendants
(
self
):
"""
Check that child_isinstance() works on deeper descendants
"""
self
.
runtime
=
WorkbenchRuntime
()
self
.
root_id
=
self
.
runtime
.
parse_xml_string
(
'<block> <block><cat/><gr/></block> <cat/> <gr/> </block>'
)
root
=
self
.
runtime
.
get_block
(
self
.
root_id
)
block
=
root
.
runtime
.
get_block
(
root
.
children
[
0
])
self
.
assertIsInstance
(
block
,
BasicXBlock
)
...
...
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