Commit b78fb8df by Victor Shnayder

Refactored the rest of the input types

parent 3a099970
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<div style="display:none;" name="${hidden}" inputid="input_${id}" /> <div style="display:none;" name="${hidden}" inputid="input_${id}" />
% endif % endif
<input type="text" name="input_${id}" id="input_${id}" value="${value}" <input type="text" name="input_${id}" id="input_${id}" value="${value|h}"
% if size: % if size:
size="${size}" size="${size}"
% endif % endif
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<div class="incorrect" id="status_${id}"> <div class="incorrect" id="status_${id}">
% endif % endif
<input type="text" name="input_${id}" id="input_${id}" value="${value}" <input type="text" name="input_${id}" id="input_${id}" value="${value|h}"
style="display:none;" style="display:none;"
/> />
......
...@@ -2,9 +2,18 @@ ...@@ -2,9 +2,18 @@
Tests of input types. Tests of input types.
TODO: TODO:
- refactor: so much repetive code (have factory methods that build xml elements directly, etc)
- test error cases
- check rendering -- e.g. msg should appear in the rendered output. If possible, test that
templates are escaping things properly.
- test unicode in values, parameters, etc. - test unicode in values, parameters, etc.
- test various html escapes - test various html escapes
- test funny xml chars -- should never get xml parse error if things are escaped properly. - test funny xml chars -- should never get xml parse error if things are escaped properly.
""" """
from lxml import etree from lxml import etree
...@@ -267,14 +276,15 @@ class CodeInputTest(unittest.TestCase): ...@@ -267,14 +276,15 @@ class CodeInputTest(unittest.TestCase):
'status': 'incomplete', 'status': 'incomplete',
'feedback' : {'message': '3'}, } 'feedback' : {'message': '3'}, }
the_input = lookup_tag('codeinput')(test_system, element, state) input_class = lookup_tag('codeinput')
the_input = input_class(test_system, element, state)
context = the_input._get_render_context() context = the_input._get_render_context()
expected = {'id': 'prob_1_2', expected = {'id': 'prob_1_2',
'value': 'print "good evening"', 'value': 'print "good evening"',
'status': 'queued', 'status': 'queued',
'msg': 'Submitted to grader.', 'msg': input_class.submitted_msg,
'mode': mode, 'mode': mode,
'linenumbers': linenumbers, 'linenumbers': linenumbers,
'rows': rows, 'rows': rows,
...@@ -323,8 +333,9 @@ class SchematicTest(unittest.TestCase): ...@@ -323,8 +333,9 @@ class SchematicTest(unittest.TestCase):
expected = {'id': 'prob_1_2', expected = {'id': 'prob_1_2',
'value': value, 'value': value,
'initial_value': initial_value,
'status': 'unsubmitted', 'status': 'unsubmitted',
'msg': '',
'initial_value': initial_value,
'width': width, 'width': width,
'height': height, 'height': height,
'parts': parts, 'parts': parts,
...@@ -488,6 +499,7 @@ class ChemicalEquationTest(unittest.TestCase): ...@@ -488,6 +499,7 @@ class ChemicalEquationTest(unittest.TestCase):
expected = {'id': 'prob_1_2', expected = {'id': 'prob_1_2',
'value': 'H2OYeah', 'value': 'H2OYeah',
'status': 'unanswered', 'status': 'unanswered',
'msg': '',
'size': size, 'size': size,
'previewer': '/static/js/capa/chemical_equation_preview.js', 'previewer': '/static/js/capa/chemical_equation_preview.js',
} }
......
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