Commit 65e26e3e by John Eskew

Move user/admin model creation to class level.

Wrap whole test with several publish/unpublish in same bulk_op.
parent 14ad8cd7
...@@ -25,16 +25,12 @@ class TestCCXModulestoreWrapper(SharedModuleStoreTestCase): ...@@ -25,16 +25,12 @@ class TestCCXModulestoreWrapper(SharedModuleStoreTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(TestCCXModulestoreWrapper, cls).setUpClass() super(TestCCXModulestoreWrapper, cls).setUpClass()
cls.course = course = CourseFactory.create() cls.course = CourseFactory.create()
cls.mooc_start = start = datetime.datetime( start = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=pytz.UTC)
2010, 5, 12, 2, 42, tzinfo=pytz.UTC due = datetime.datetime(2010, 7, 7, 0, 0, tzinfo=pytz.UTC)
)
cls.mooc_due = due = datetime.datetime(
2010, 7, 7, 0, 0, tzinfo=pytz.UTC
)
# Create a course outline # Create a course outline
cls.chapters = chapters = [ cls.chapters = chapters = [
ItemFactory.create(start=start, parent=course) for _ in xrange(2) ItemFactory.create(start=start, parent=cls.course) for _ in xrange(2)
] ]
cls.sequentials = sequentials = [ cls.sequentials = sequentials = [
ItemFactory.create(parent=c) for _ in xrange(2) for c in chapters ItemFactory.create(parent=c) for _ in xrange(2) for c in chapters
...@@ -48,20 +44,24 @@ class TestCCXModulestoreWrapper(SharedModuleStoreTestCase): ...@@ -48,20 +44,24 @@ class TestCCXModulestoreWrapper(SharedModuleStoreTestCase):
ItemFactory.create(parent=v, category='html') for _ in xrange(2) for v in verticals ItemFactory.create(parent=v, category='html') for _ in xrange(2) for v in verticals
] ]
@classmethod
def setUpTestData(cls):
"""
Set up models for the whole TestCase.
"""
cls.user = UserFactory.create()
# Create instructor account
cls.coach = AdminFactory.create()
def setUp(self): def setUp(self):
""" """
Set up tests Set up tests
""" """
super(TestCCXModulestoreWrapper, self).setUp() super(TestCCXModulestoreWrapper, self).setUp()
self.user = UserFactory.create()
# Create instructor account
coach = AdminFactory.create()
self.ccx = ccx = CustomCourseForEdX( self.ccx = ccx = CustomCourseForEdX(
course_id=self.course.id, course_id=self.course.id,
display_name='Test CCX', display_name='Test CCX',
coach=coach coach=self.coach
) )
ccx.save() ccx.save()
...@@ -132,12 +132,13 @@ class TestCCXModulestoreWrapper(SharedModuleStoreTestCase): ...@@ -132,12 +132,13 @@ class TestCCXModulestoreWrapper(SharedModuleStoreTestCase):
def test_publication_api(self): def test_publication_api(self):
"""verify that we can correctly discern a published item by ccx key""" """verify that we can correctly discern a published item by ccx key"""
for expected in self.blocks: with self.store.bulk_operations(self.ccx_locator):
block_key = self.ccx_locator.make_usage_key( for expected in self.blocks:
expected.location.block_type, expected.location.block_id block_key = self.ccx_locator.make_usage_key(
) expected.location.block_type, expected.location.block_id
self.assertTrue(self.store.has_published_version(expected)) )
self.store.unpublish(block_key, self.user.id) self.assertTrue(self.store.has_published_version(expected))
self.assertFalse(self.store.has_published_version(expected)) self.store.unpublish(block_key, self.user.id)
self.store.publish(block_key, self.user.id) self.assertFalse(self.store.has_published_version(expected))
self.assertTrue(self.store.has_published_version(expected)) self.store.publish(block_key, self.user.id)
self.assertTrue(self.store.has_published_version(expected))
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