Commit 87596152 by Jonathan Piacenti

Make CCX tests work with post-save signal.

parent b9c0b654
......@@ -12,6 +12,7 @@ from nose.plugins.attrib import attr
from capa.tests.response_xml_factory import StringResponseXMLFactory
from courseware.courses import get_course_by_id # pyline: disable=import-error
from courseware.field_overrides import OverrideFieldData # pylint: disable=import-error
from courseware.models import StudentModule
from courseware.tests.factories import StudentModuleFactory # pylint: disable=import-error
from courseware.tests.helpers import LoginEnrollmentTestCase # pylint: disable=import-error
from courseware.tabs import get_course_tab_list
......@@ -547,13 +548,23 @@ class TestCCXGrades(ModuleStoreTestCase, LoginEnrollmentTestCase):
for chapter in self.course.get_children():
for i, section in enumerate(chapter.get_children()):
for j, problem in enumerate(section.get_children()):
# if not problem.visible_to_staff_only:
StudentModuleFactory.create(
grade=1 if i < j else 0,
max_grade=1,
if not j:
# First iteration. Post-save signal will make the rest.
StudentModuleFactory.create(
grade=1 if i < j else 0,
max_grade=1,
student=self.student,
course_id=self.course.id,
module_state_key=problem.location
)
continue
StudentModule.objects.filter(
student=self.student,
course_id=self.course.id,
module_state_key=problem.location
).update(
grade=1 if i < j else 0,
max_grade=1
)
self.client.login(username=coach.username, password="test")
......
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