Commit 6af857b3 by Victor Shnayder

Merge pull request #1613 from MITx/victor/fix-blank-capa

Fix max_attempts=''
parents 28e300c0 b6a6e10b
...@@ -11,6 +11,20 @@ from . import test_system ...@@ -11,6 +11,20 @@ from . import test_system
class CapaHtmlRenderTest(unittest.TestCase): 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): def test_include_html(self):
# Create a test file to include # Create a test file to include
self._create_test_file('test_include.xml', self._create_test_file('test_include.xml',
......
...@@ -135,8 +135,8 @@ class CapaModule(XModule): ...@@ -135,8 +135,8 @@ class CapaModule(XModule):
self.grace_period = None self.grace_period = None
self.close_date = self.display_due_date self.close_date = self.display_due_date
max_attempts = self.metadata.get('attempts', None) max_attempts = self.metadata.get('attempts')
if max_attempts is not None: if max_attempts is not None and max_attempts != '':
self.max_attempts = int(max_attempts) self.max_attempts = int(max_attempts)
else: else:
self.max_attempts = None self.max_attempts = None
......
...@@ -144,6 +144,8 @@ class CapaModuleTest(unittest.TestCase): ...@@ -144,6 +144,8 @@ class CapaModuleTest(unittest.TestCase):
"Factory should be creating unique names for each problem") "Factory should be creating unique names for each problem")
def test_correct(self): def test_correct(self):
""" """
Check that the factory creates correct and incorrect problems properly. Check that the factory creates correct and incorrect problems properly.
...@@ -784,6 +786,12 @@ class CapaModuleTest(unittest.TestCase): ...@@ -784,6 +786,12 @@ class CapaModuleTest(unittest.TestCase):
module.lcp.done = True module.lcp.done = True
self.assertTrue(module.should_show_save_button()) 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): def test_get_problem_html(self):
module = CapaFactory.create() 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