Commit 87d135a4 by Usman Khalid

Added tests for unparsable matlab grader response.

TNL-388
parent 10bd2b00
......@@ -26,6 +26,7 @@ import xml.sax.saxutils as saxutils
from . import test_capa_system
from capa import inputtypes
from capa.checker import DemoSystem
from mock import ANY, patch
from pyparsing import ParseException
......@@ -727,6 +728,34 @@ class MatlabTest(unittest.TestCase):
received = fromstring(context['queue_msg'])
html_tree_equal(received, expected)
def test_rendering_with_invalid_queue_msg(self):
self.the_input.queue_msg = (u"<div class='matlabResponse'><div style='white-space:pre' class='commandWindowOutput'>"
u"\nans =\n\n\u0002\n\n</div><ul></ul></div>")
context = self.the_input._get_render_context() # pylint: disable=protected-access
self.maxDiff = None
expected = {
'STATIC_URL': '/dummy-static/',
'id': 'prob_1_2',
'value': 'print "good evening"',
'status': inputtypes.Status('queued'),
'msg': self.the_input.submitted_msg,
'mode': self.mode,
'rows': self.rows,
'cols': self.cols,
'queue_msg': "<span>Error running code.</span>",
'linenumbers': 'true',
'hidden': '',
'tabsize': int(self.tabsize),
'button_enabled': True,
'queue_len': '3',
'matlab_editor_js': '/dummy-static/js/vendor/CodeMirror/octave.js',
}
self.assertEqual(context, expected)
self.the_input.capa_system.render_template = DemoSystem().render_template
self.the_input.get_html() # Should not raise an exception
def test_matlab_queue_message_allowed_tags(self):
"""
Test allowed tags.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment