Commit b6a6e10b by Victor Shnayder

Fix max_attempts=''

That's what studio defaults to, and recent changes made it break.
Added a few tests to make sure it doesn't happen again.
parent 28e300c0
......@@ -11,6 +11,20 @@ from . import test_system
class CapaHtmlRenderTest(unittest.TestCase):
def test_blank_problem(self):
"""
It's important that blank problems don't break, since that's
what you start with in studio.
"""
xml_str = "<problem> </problem>"
# Create the problem
problem = LoncapaProblem(xml_str, '1', system=test_system)
# Render the HTML
rendered_html = etree.XML(problem.get_html())
# expect that we made it here without blowing up
def test_include_html(self):
# Create a test file to include
self._create_test_file('test_include.xml',
......
......@@ -135,8 +135,8 @@ class CapaModule(XModule):
self.grace_period = None
self.close_date = self.display_due_date
max_attempts = self.metadata.get('attempts', None)
if max_attempts is not None:
max_attempts = self.metadata.get('attempts')
if max_attempts is not None and max_attempts != '':
self.max_attempts = int(max_attempts)
else:
self.max_attempts = None
......
......@@ -144,6 +144,8 @@ class CapaModuleTest(unittest.TestCase):
"Factory should be creating unique names for each problem")
def test_correct(self):
"""
Check that the factory creates correct and incorrect problems properly.
......@@ -784,6 +786,12 @@ class CapaModuleTest(unittest.TestCase):
module.lcp.done = True
self.assertTrue(module.should_show_save_button())
def test_no_max_attempts(self):
module = CapaFactory.create(max_attempts='')
html = module.get_problem_html()
# assert that we got here without exploding
def test_get_problem_html(self):
module = CapaFactory.create()
......
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