Commit ca1f76ce by David Ormsbee

Move more tests to use bulk_operations.

parent ae1853bc
...@@ -242,44 +242,45 @@ class ViewsTestCase(ModuleStoreTestCase): ...@@ -242,44 +242,45 @@ class ViewsTestCase(ModuleStoreTestCase):
def setUp(self): def setUp(self):
super(ViewsTestCase, self).setUp() super(ViewsTestCase, self).setUp()
self.course = CourseFactory.create(display_name=u'teꜱᴛ course', run="Testing_course") self.course = CourseFactory.create(display_name=u'teꜱᴛ course', run="Testing_course")
self.chapter = ItemFactory.create( with self.store.bulk_operations(self.course.id):
category='chapter', self.chapter = ItemFactory.create(
parent_location=self.course.location, category='chapter',
display_name="Chapter 1", parent_location=self.course.location,
) display_name="Chapter 1",
self.section = ItemFactory.create( )
category='sequential', self.section = ItemFactory.create(
parent_location=self.chapter.location, category='sequential',
due=datetime(2013, 9, 18, 11, 30, 00), parent_location=self.chapter.location,
display_name='Sequential 1', due=datetime(2013, 9, 18, 11, 30, 00),
format='Homework' display_name='Sequential 1',
) format='Homework'
self.vertical = ItemFactory.create( )
category='vertical', self.vertical = ItemFactory.create(
parent_location=self.section.location, category='vertical',
display_name='Vertical 1', parent_location=self.section.location,
) display_name='Vertical 1',
self.problem = ItemFactory.create( )
category='problem', self.problem = ItemFactory.create(
parent_location=self.vertical.location, category='problem',
display_name='Problem 1', parent_location=self.vertical.location,
) display_name='Problem 1',
)
self.section2 = ItemFactory.create( self.section2 = ItemFactory.create(
category='sequential', category='sequential',
parent_location=self.chapter.location, parent_location=self.chapter.location,
display_name='Sequential 2', display_name='Sequential 2',
) )
self.vertical2 = ItemFactory.create( self.vertical2 = ItemFactory.create(
category='vertical', category='vertical',
parent_location=self.section2.location, parent_location=self.section2.location,
display_name='Vertical 2', display_name='Vertical 2',
) )
self.problem2 = ItemFactory.create( self.problem2 = ItemFactory.create(
category='problem', category='problem',
parent_location=self.vertical2.location, parent_location=self.vertical2.location,
display_name='Problem 2', display_name='Problem 2',
) )
self.course_key = self.course.id self.course_key = self.course.id
self.password = '123456' self.password = '123456'
...@@ -989,15 +990,16 @@ class BaseDueDateTests(ModuleStoreTestCase): ...@@ -989,15 +990,16 @@ class BaseDueDateTests(ModuleStoreTestCase):
:param course_kwargs: All kwargs are passed to through to the :class:`CourseFactory` :param course_kwargs: All kwargs are passed to through to the :class:`CourseFactory`
""" """
course = CourseFactory.create(**course_kwargs) course = CourseFactory.create(**course_kwargs)
chapter = ItemFactory.create(category='chapter', parent_location=course.location) with self.store.bulk_operations(course.id):
section = ItemFactory.create( chapter = ItemFactory.create(category='chapter', parent_location=course.location)
category='sequential', section = ItemFactory.create(
parent_location=chapter.location, category='sequential',
due=datetime(2013, 9, 18, 11, 30, 00), parent_location=chapter.location,
format='homework' due=datetime(2013, 9, 18, 11, 30, 00),
) format='homework'
vertical = ItemFactory.create(category='vertical', parent_location=section.location) )
ItemFactory.create(category='problem', parent_location=vertical.location) vertical = ItemFactory.create(category='vertical', parent_location=section.location)
ItemFactory.create(category='problem', parent_location=vertical.location)
course = modulestore().get_course(course.id) course = modulestore().get_course(course.id)
self.assertIsNotNone(course.get_children()[0].get_children()[0].due) self.assertIsNotNone(course.get_children()[0].get_children()[0].due)
...@@ -1149,19 +1151,18 @@ class ProgressPageTests(ModuleStoreTestCase): ...@@ -1149,19 +1151,18 @@ class ProgressPageTests(ModuleStoreTestCase):
def setup_course(self, **options): def setup_course(self, **options):
"""Create the test course.""" """Create the test course."""
course = CourseFactory.create( self.course = CourseFactory.create(
start=datetime(2013, 9, 16, 7, 17, 28), start=datetime(2013, 9, 16, 7, 17, 28),
grade_cutoffs={u'çü†øƒƒ': 0.75, 'Pass': 0.5}, grade_cutoffs={u'çü†øƒƒ': 0.75, 'Pass': 0.5},
**options **options
) )
with self.store.bulk_operations(self.course.id):
self.chapter = ItemFactory.create(category='chapter', parent_location=self.course.location)
self.section = ItemFactory.create(category='sequential', parent_location=self.chapter.location)
self.vertical = ItemFactory.create(category='vertical', parent_location=self.section.location)
self.course = modulestore().get_course(course.id)
CourseEnrollmentFactory(user=self.user, course_id=self.course.id, mode=CourseMode.HONOR) CourseEnrollmentFactory(user=self.user, course_id=self.course.id, mode=CourseMode.HONOR)
self.chapter = ItemFactory.create(category='chapter', parent_location=self.course.location)
self.section = ItemFactory.create(category='sequential', parent_location=self.chapter.location)
self.vertical = ItemFactory.create(category='vertical', parent_location=self.section.location)
def _get_progress_page(self, expected_status_code=200): def _get_progress_page(self, expected_status_code=200):
""" """
Gets the progress page for the user in the course. Gets the progress page for the user in the course.
...@@ -1898,10 +1899,11 @@ class TestIndexView(ModuleStoreTestCase): ...@@ -1898,10 +1899,11 @@ class TestIndexView(ModuleStoreTestCase):
user = UserFactory() user = UserFactory()
course = CourseFactory.create() course = CourseFactory.create()
chapter = ItemFactory.create(parent=course, category='chapter') with self.store.bulk_operations(course.id):
section = ItemFactory.create(parent=chapter, category='sequential', display_name="Sequence") chapter = ItemFactory.create(parent=course, category='chapter')
vertical = ItemFactory.create(parent=section, category='vertical', display_name="Vertical") section = ItemFactory.create(parent=chapter, category='sequential', display_name="Sequence")
ItemFactory.create(parent=vertical, category='id_checker', display_name="ID Checker") vertical = ItemFactory.create(parent=section, category='vertical', display_name="Vertical")
ItemFactory.create(parent=vertical, category='id_checker', display_name="ID Checker")
CourseEnrollmentFactory(user=user, course_id=course.id) CourseEnrollmentFactory(user=user, course_id=course.id)
...@@ -1936,11 +1938,12 @@ class TestIndexViewWithVerticalPositions(ModuleStoreTestCase): ...@@ -1936,11 +1938,12 @@ class TestIndexViewWithVerticalPositions(ModuleStoreTestCase):
# create course with 3 positions # create course with 3 positions
self.course = CourseFactory.create() self.course = CourseFactory.create()
self.chapter = ItemFactory.create(parent=self.course, category='chapter') with self.store.bulk_operations(self.course.id):
self.section = ItemFactory.create(parent=self.chapter, category='sequential', display_name="Sequence") self.chapter = ItemFactory.create(parent=self.course, category='chapter')
ItemFactory.create(parent=self.section, category='vertical', display_name="Vertical1") self.section = ItemFactory.create(parent=self.chapter, category='sequential', display_name="Sequence")
ItemFactory.create(parent=self.section, category='vertical', display_name="Vertical2") ItemFactory.create(parent=self.section, category='vertical', display_name="Vertical1")
ItemFactory.create(parent=self.section, category='vertical', display_name="Vertical3") ItemFactory.create(parent=self.section, category='vertical', display_name="Vertical2")
ItemFactory.create(parent=self.section, category='vertical', display_name="Vertical3")
self.client.login(username=self.user, password='test') self.client.login(username=self.user, password='test')
CourseEnrollmentFactory(user=self.user, course_id=self.course.id) CourseEnrollmentFactory(user=self.user, course_id=self.course.id)
...@@ -1995,14 +1998,20 @@ class TestIndexViewWithGating(ModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -1995,14 +1998,20 @@ class TestIndexViewWithGating(ModuleStoreTestCase, MilestonesTestCaseMixin):
self.user = UserFactory() self.user = UserFactory()
self.course = CourseFactory.create() self.course = CourseFactory.create()
self.course.enable_subsection_gating = True with self.store.bulk_operations(self.course.id):
self.course.save() self.course.enable_subsection_gating = True
self.store.update_item(self.course, 0) self.course.save()
self.chapter = ItemFactory.create(parent=self.course, category="chapter", display_name="Chapter") self.store.update_item(self.course, 0)
self.open_seq = ItemFactory.create(parent=self.chapter, category='sequential', display_name="Open Sequential") self.chapter = ItemFactory.create(parent=self.course, category="chapter", display_name="Chapter")
ItemFactory.create(parent=self.open_seq, category='problem', display_name="Problem 1") self.open_seq = ItemFactory.create(
self.gated_seq = ItemFactory.create(parent=self.chapter, category='sequential', display_name="Gated Sequential") parent=self.chapter, category='sequential', display_name="Open Sequential"
ItemFactory.create(parent=self.gated_seq, category='problem', display_name="Problem 2") )
ItemFactory.create(parent=self.open_seq, category='problem', display_name="Problem 1")
self.gated_seq = ItemFactory.create(
parent=self.chapter, category='sequential', display_name="Gated Sequential"
)
ItemFactory.create(parent=self.gated_seq, category='problem', display_name="Problem 2")
gating_api.add_prerequisite(self.course.id, self.open_seq.location) gating_api.add_prerequisite(self.course.id, self.open_seq.location)
gating_api.set_required_content(self.course.id, self.gated_seq.location, self.open_seq.location, 100) gating_api.set_required_content(self.course.id, self.gated_seq.location, self.open_seq.location, 100)
......
...@@ -148,20 +148,21 @@ class TestWeightedProblems(SharedModuleStoreTestCase): ...@@ -148,20 +148,21 @@ class TestWeightedProblems(SharedModuleStoreTestCase):
def setUpClass(cls): def setUpClass(cls):
super(TestWeightedProblems, cls).setUpClass() super(TestWeightedProblems, cls).setUpClass()
cls.course = CourseFactory.create() cls.course = CourseFactory.create()
cls.chapter = ItemFactory.create(parent=cls.course, category="chapter", display_name="chapter") with cls.store.bulk_operations(cls.course.id):
cls.sequential = ItemFactory.create(parent=cls.chapter, category="sequential", display_name="sequential") cls.chapter = ItemFactory.create(parent=cls.course, category="chapter", display_name="chapter")
cls.vertical = ItemFactory.create(parent=cls.sequential, category="vertical", display_name="vertical1") cls.sequential = ItemFactory.create(parent=cls.chapter, category="sequential", display_name="sequential")
problem_xml = cls._create_problem_xml() cls.vertical = ItemFactory.create(parent=cls.sequential, category="vertical", display_name="vertical1")
cls.problems = [] problem_xml = cls._create_problem_xml()
for i in range(2): cls.problems = []
cls.problems.append( for i in range(2):
ItemFactory.create( cls.problems.append(
parent=cls.vertical, ItemFactory.create(
category="problem", parent=cls.vertical,
display_name="problem_{}".format(i), category="problem",
data=problem_xml, display_name="problem_{}".format(i),
data=problem_xml,
)
) )
)
def setUp(self): def setUp(self):
super(TestWeightedProblems, self).setUp() super(TestWeightedProblems, self).setUp()
...@@ -261,20 +262,21 @@ class TestScoreForModule(SharedModuleStoreTestCase): ...@@ -261,20 +262,21 @@ class TestScoreForModule(SharedModuleStoreTestCase):
def setUpClass(cls): def setUpClass(cls):
super(TestScoreForModule, cls).setUpClass() super(TestScoreForModule, cls).setUpClass()
cls.course = CourseFactory.create() cls.course = CourseFactory.create()
cls.a = ItemFactory.create(parent=cls.course, category="chapter", display_name="a") with cls.store.bulk_operations(cls.course.id):
cls.b = ItemFactory.create(parent=cls.a, category="sequential", display_name="b") cls.a = ItemFactory.create(parent=cls.course, category="chapter", display_name="a")
cls.c = ItemFactory.create(parent=cls.a, category="sequential", display_name="c") cls.b = ItemFactory.create(parent=cls.a, category="sequential", display_name="b")
cls.d = ItemFactory.create(parent=cls.b, category="vertical", display_name="d") cls.c = ItemFactory.create(parent=cls.a, category="sequential", display_name="c")
cls.e = ItemFactory.create(parent=cls.b, category="vertical", display_name="e") cls.d = ItemFactory.create(parent=cls.b, category="vertical", display_name="d")
cls.f = ItemFactory.create(parent=cls.b, category="vertical", display_name="f") cls.e = ItemFactory.create(parent=cls.b, category="vertical", display_name="e")
cls.g = ItemFactory.create(parent=cls.c, category="vertical", display_name="g") cls.f = ItemFactory.create(parent=cls.b, category="vertical", display_name="f")
cls.h = ItemFactory.create(parent=cls.d, category="problem", display_name="h") cls.g = ItemFactory.create(parent=cls.c, category="vertical", display_name="g")
cls.i = ItemFactory.create(parent=cls.d, category="problem", display_name="i") cls.h = ItemFactory.create(parent=cls.d, category="problem", display_name="h")
cls.j = ItemFactory.create(parent=cls.e, category="problem", display_name="j") cls.i = ItemFactory.create(parent=cls.d, category="problem", display_name="i")
cls.k = ItemFactory.create(parent=cls.e, category="html", display_name="k") cls.j = ItemFactory.create(parent=cls.e, category="problem", display_name="j")
cls.l = ItemFactory.create(parent=cls.e, category="problem", display_name="l") cls.k = ItemFactory.create(parent=cls.e, category="html", display_name="k")
cls.m = ItemFactory.create(parent=cls.f, category="html", display_name="m") cls.l = ItemFactory.create(parent=cls.e, category="problem", display_name="l")
cls.n = ItemFactory.create(parent=cls.g, category="problem", display_name="n") cls.m = ItemFactory.create(parent=cls.f, category="html", display_name="m")
cls.n = ItemFactory.create(parent=cls.g, category="problem", display_name="n")
cls.request = get_mock_request(UserFactory()) cls.request = get_mock_request(UserFactory())
CourseEnrollment.enroll(cls.request.user, cls.course.id) CourseEnrollment.enroll(cls.request.user, cls.course.id)
...@@ -341,96 +343,97 @@ class TestGetModuleScore(LoginEnrollmentTestCase, SharedModuleStoreTestCase): ...@@ -341,96 +343,97 @@ class TestGetModuleScore(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
def setUpClass(cls): def setUpClass(cls):
super(TestGetModuleScore, cls).setUpClass() super(TestGetModuleScore, cls).setUpClass()
cls.course = CourseFactory.create() cls.course = CourseFactory.create()
cls.chapter = ItemFactory.create( with cls.store.bulk_operations(cls.course.id):
parent=cls.course, cls.chapter = ItemFactory.create(
category="chapter", parent=cls.course,
display_name="Test Chapter" category="chapter",
) display_name="Test Chapter"
cls.seq1 = ItemFactory.create( )
parent=cls.chapter, cls.seq1 = ItemFactory.create(
category='sequential', parent=cls.chapter,
display_name="Test Sequential 1", category='sequential',
graded=True display_name="Test Sequential 1",
) graded=True
cls.seq2 = ItemFactory.create( )
parent=cls.chapter, cls.seq2 = ItemFactory.create(
category='sequential', parent=cls.chapter,
display_name="Test Sequential 2", category='sequential',
graded=True display_name="Test Sequential 2",
) graded=True
cls.seq3 = ItemFactory.create( )
parent=cls.chapter, cls.seq3 = ItemFactory.create(
category='sequential', parent=cls.chapter,
display_name="Test Sequential 3", category='sequential',
graded=True display_name="Test Sequential 3",
) graded=True
cls.vert1 = ItemFactory.create( )
parent=cls.seq1, cls.vert1 = ItemFactory.create(
category='vertical', parent=cls.seq1,
display_name='Test Vertical 1' category='vertical',
) display_name='Test Vertical 1'
cls.vert2 = ItemFactory.create( )
parent=cls.seq2, cls.vert2 = ItemFactory.create(
category='vertical', parent=cls.seq2,
display_name='Test Vertical 2' category='vertical',
) display_name='Test Vertical 2'
cls.vert3 = ItemFactory.create( )
parent=cls.seq3, cls.vert3 = ItemFactory.create(
category='vertical', parent=cls.seq3,
display_name='Test Vertical 3' category='vertical',
) display_name='Test Vertical 3'
cls.randomize = ItemFactory.create( )
parent=cls.vert2, cls.randomize = ItemFactory.create(
category='randomize', parent=cls.vert2,
display_name='Test Randomize' category='randomize',
) display_name='Test Randomize'
cls.library_content = ItemFactory.create( )
parent=cls.vert3, cls.library_content = ItemFactory.create(
category='library_content', parent=cls.vert3,
display_name='Test Library Content' category='library_content',
) display_name='Test Library Content'
problem_xml = MultipleChoiceResponseXMLFactory().build_xml( )
question_text='The correct answer is Choice 3', problem_xml = MultipleChoiceResponseXMLFactory().build_xml(
choices=[False, False, True, False], question_text='The correct answer is Choice 3',
choice_names=['choice_0', 'choice_1', 'choice_2', 'choice_3'] choices=[False, False, True, False],
) choice_names=['choice_0', 'choice_1', 'choice_2', 'choice_3']
cls.problem1 = ItemFactory.create( )
parent=cls.vert1, cls.problem1 = ItemFactory.create(
category="problem", parent=cls.vert1,
display_name="Test Problem 1", category="problem",
data=problem_xml display_name="Test Problem 1",
) data=problem_xml
cls.problem2 = ItemFactory.create( )
parent=cls.vert1, cls.problem2 = ItemFactory.create(
category="problem", parent=cls.vert1,
display_name="Test Problem 2", category="problem",
data=problem_xml display_name="Test Problem 2",
) data=problem_xml
cls.problem3 = ItemFactory.create( )
parent=cls.randomize, cls.problem3 = ItemFactory.create(
category="problem", parent=cls.randomize,
display_name="Test Problem 3", category="problem",
data=problem_xml display_name="Test Problem 3",
) data=problem_xml
cls.problem4 = ItemFactory.create( )
parent=cls.randomize, cls.problem4 = ItemFactory.create(
category="problem", parent=cls.randomize,
display_name="Test Problem 4", category="problem",
data=problem_xml display_name="Test Problem 4",
) data=problem_xml
)
cls.problem5 = ItemFactory.create( cls.problem5 = ItemFactory.create(
parent=cls.library_content, parent=cls.library_content,
category="problem", category="problem",
display_name="Test Problem 5", display_name="Test Problem 5",
data=problem_xml data=problem_xml
) )
cls.problem6 = ItemFactory.create( cls.problem6 = ItemFactory.create(
parent=cls.library_content, parent=cls.library_content,
category="problem", category="problem",
display_name="Test Problem 6", display_name="Test Problem 6",
data=problem_xml data=problem_xml
) )
def setUp(self): def setUp(self):
""" """
......
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