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
2dc4f5d6
Commit
2dc4f5d6
authored
Aug 25, 2016
by
Eric Fischer
Committed by
GitHub
Aug 25, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13303 from edx/efischer/tnl_5057
TNL 5057 Silence XML parse error in capa_module
parents
bf421108
0059f88d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
common/lib/xmodule/xmodule/capa_module.py
+9
-4
common/lib/xmodule/xmodule/tests/test_capa_module.py
+16
-0
No files found.
common/lib/xmodule/xmodule/capa_module.py
View file @
2dc4f5d6
...
@@ -220,9 +220,13 @@ class CapaDescriptor(CapaFields, RawDescriptor):
...
@@ -220,9 +220,13 @@ class CapaDescriptor(CapaFields, RawDescriptor):
@property
@property
def
problem_types
(
self
):
def
problem_types
(
self
):
""" Low-level problem type introspection for content libraries filtering by problem type """
""" Low-level problem type introspection for content libraries filtering by problem type """
tree
=
etree
.
XML
(
self
.
data
)
try
:
tree
=
etree
.
XML
(
self
.
data
)
except
etree
.
XMLSyntaxError
:
log
.
error
(
'Error parsing problem types from xml for capa module {}'
.
format
(
self
.
display_name
))
return
None
# short-term fix to prevent errors (TNL-5057). Will be more properly addressed in TNL-4525.
registered_tags
=
responsetypes
.
registry
.
registered_tags
()
registered_tags
=
responsetypes
.
registry
.
registered_tags
()
return
set
([
node
.
tag
for
node
in
tree
.
iter
()
if
node
.
tag
in
registered_tags
])
return
{
node
.
tag
for
node
in
tree
.
iter
()
if
node
.
tag
in
registered_tags
}
def
index_dictionary
(
self
):
def
index_dictionary
(
self
):
"""
"""
...
@@ -263,9 +267,10 @@ class CapaDescriptor(CapaFields, RawDescriptor):
...
@@ -263,9 +267,10 @@ class CapaDescriptor(CapaFields, RawDescriptor):
Returns whether the given view has support for the given functionality.
Returns whether the given view has support for the given functionality.
"""
"""
if
functionality
==
"multi_device"
:
if
functionality
==
"multi_device"
:
return
all
(
types
=
self
.
problem_types
# Avoid calculating this property twice
return
types
is
not
None
and
all
(
responsetypes
.
registry
.
get_class_for_tag
(
tag
)
.
multi_device_support
responsetypes
.
registry
.
get_class_for_tag
(
tag
)
.
multi_device_support
for
tag
in
self
.
problem_
types
for
tag
in
types
)
)
return
False
return
False
...
...
common/lib/xmodule/xmodule/tests/test_capa_module.py
View file @
2dc4f5d6
...
@@ -13,6 +13,7 @@ import textwrap
...
@@ -13,6 +13,7 @@ import textwrap
import
unittest
import
unittest
import
ddt
import
ddt
from
lxml
import
etree
from
mock
import
Mock
,
patch
,
DEFAULT
from
mock
import
Mock
,
patch
,
DEFAULT
import
webob
import
webob
from
webob.multidict
import
MultiDict
from
webob.multidict
import
MultiDict
...
@@ -2517,6 +2518,21 @@ class CapaDescriptorTest(unittest.TestCase):
...
@@ -2517,6 +2518,21 @@ class CapaDescriptorTest(unittest.TestCase):
}
}
)
)
def
test_invalid_xml_handling
(
self
):
"""
Tests to confirm that invalid XML does not throw a wake-up-ops level error.
See TNL-5057 for quick fix, TNL-5245 for full resolution.
"""
sample_invalid_xml
=
textwrap
.
dedent
(
"""
<problem>
</proble-oh no my finger broke and I can't close the problem tag properly...
"""
)
descriptor
=
self
.
_create_descriptor
(
sample_invalid_xml
,
name
=
"Invalid XML"
)
try
:
descriptor
.
has_support
(
None
,
"multi_device"
)
except
etree
.
XMLSyntaxError
:
self
.
fail
(
"Exception raised during XML parsing, this method should be resilient to such errors"
)
class
ComplexEncoderTest
(
unittest
.
TestCase
):
class
ComplexEncoderTest
(
unittest
.
TestCase
):
def
test_default
(
self
):
def
test_default
(
self
):
...
...
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