Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
0d83d2e6
Commit
0d83d2e6
authored
Jul 30, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add roundtrip test for malformed module
* also fix error message in backcompat_module
parent
53608922
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
6 deletions
+31
-6
common/lib/xmodule/tests/test_import.py
+30
-5
common/lib/xmodule/xmodule/backcompat_module.py
+1
-1
No files found.
common/lib/xmodule/tests/test_import.py
View file @
0d83d2e6
...
...
@@ -9,11 +9,9 @@ from xmodule.modulestore import Location
class
ImportTestCase
(
unittest
.
TestCase
):
'''Make sure module imports work properly, including for malformed inputs'''
def
test_fallback
(
self
):
'''Make sure that malformed xml loads as a MalformedDescriptorb.'''
bad_xml
=
'''<sequential display_name="oops"><video url="hi"></sequential>'''
@staticmethod
def
get_system
():
'''Get a dummy system'''
# Shouldn't need any system params, because the initial parse should fail
def
load_item
(
loc
):
raise
Exception
(
"Shouldn't be called"
)
...
...
@@ -31,8 +29,35 @@ class ImportTestCase(unittest.TestCase):
ignore_errors_handler
,
process_xml
)
system
.
render_template
=
render_template
return
system
def
test_fallback
(
self
):
'''Make sure that malformed xml loads as a MalformedDescriptorb.'''
bad_xml
=
'''<sequential display_name="oops"><video url="hi"></sequential>'''
system
=
self
.
get_system
()
descriptor
=
XModuleDescriptor
.
load_from_xml
(
bad_xml
,
system
,
'org'
,
'course'
,
None
)
self
.
assertEqual
(
descriptor
.
__class__
.
__name__
,
'MalformedDescriptor'
)
def
test_reimport
(
self
):
'''Make sure an already-exported malformed xml tag loads properly'''
bad_xml
=
'''<sequential display_name="oops"><video url="hi"></sequential>'''
system
=
self
.
get_system
()
descriptor
=
XModuleDescriptor
.
load_from_xml
(
bad_xml
,
system
,
'org'
,
'course'
,
None
)
resource_fs
=
None
tag_xml
=
descriptor
.
export_to_xml
(
resource_fs
)
re_import_descriptor
=
XModuleDescriptor
.
load_from_xml
(
tag_xml
,
system
,
'org'
,
'course'
,
None
)
self
.
assertEqual
(
re_import_descriptor
.
__class__
.
__name__
,
'MalformedDescriptor'
)
self
.
assertEqual
(
descriptor
.
definition
[
'data'
],
re_import_descriptor
.
definition
[
'data'
])
common/lib/xmodule/xmodule/backcompat_module.py
View file @
0d83d2e6
...
...
@@ -32,7 +32,7 @@ def process_includes(fn):
# read in and convert to XML
incxml
=
etree
.
XML
(
ifp
.
read
())
# insert new XML into tree in place of in
lc
ude
# insert new XML into tree in place of in
cl
ude
parent
.
insert
(
parent
.
index
(
next_include
),
incxml
)
except
Exception
:
msg
=
"Error in problem xml include:
%
s"
%
(
etree
.
tostring
(
next_include
,
pretty_print
=
True
))
...
...
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