Merge pull request #9488 from edx/dsjen/courses-via-overview

Optimize OpenID Course Claims for users.
This commit is contained in:
Dennis Jen
2015-09-17 13:35:49 -04:00
14 changed files with 246 additions and 95 deletions

View File

@@ -488,21 +488,18 @@ class DashboardTest(ModuleStoreTestCase):
self.assertContains(response, expected_url)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@ddt.data((ModuleStoreEnum.Type.mongo, 1), (ModuleStoreEnum.Type.split, 3))
@ddt.unpack
def test_dashboard_metadata_caching(self, modulestore_type, expected_mongo_calls):
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
def test_dashboard_metadata_caching(self, modulestore_type):
"""
Check that the student dashboard makes use of course metadata caching.
After enrolling a student in a course, that course's metadata should be
cached as a CourseOverview. The student dashboard should never have to make
calls to the modulestore.
After creating a course, that course's metadata should be cached as a
CourseOverview. The student dashboard should never have to make calls to
the modulestore.
Arguments:
modulestore_type (ModuleStoreEnum.Type): Type of modulestore to create
test course in.
expected_mongo_calls (int >=0): Number of MongoDB queries expected for
a single call to the module store.
Note to future developers:
If you break this test so that the "check_mongo_calls(0)" fails,
@@ -512,11 +509,11 @@ class DashboardTest(ModuleStoreTestCase):
CourseDescriptor isn't necessary.
"""
# Create a course and log in the user.
test_course = CourseFactory.create(default_store=modulestore_type)
# Creating a new course will trigger a publish event and the course will be cached
test_course = CourseFactory.create(default_store=modulestore_type, emit_signals=True)
self.client.login(username="jack", password="test")
# Enrolling the user in the course will result in a modulestore query.
with check_mongo_calls(expected_mongo_calls):
with check_mongo_calls(0):
CourseEnrollment.enroll(self.user, test_course.id)
# Subsequent requests will only result in SQL queries to load the