Fix failing tests from merge with master

This commit is contained in:
Calen Pennington
2014-05-09 16:37:17 -04:00
parent c72b0bb293
commit 94c8d86a42
13 changed files with 40 additions and 47 deletions

View File

@@ -530,7 +530,7 @@ def get_module_for_descriptor_internal(user, descriptor, field_data_cache, cours
# Do not check access when it's a noauth request.
if getattr(user, 'known', True):
# Short circuit--if the user shouldn't have access, bail without doing any work
if not has_access(user, descriptor, 'load', course_id):
if not has_access(user, 'load', descriptor, course_id):
return None
(system, student_data) = get_module_system_for_user(

View File

@@ -148,29 +148,18 @@ class TestLTIModuleListing(ModuleStoreTestCase):
display_name="section2",
category='sequential')
self.published_location_dict = {'tag': 'i4x',
'org': self.course.location.org,
'category': 'lti',
'course': self.course.location.course,
'name': 'lti_published'}
self.draft_location_dict = {'tag': 'i4x',
'org': self.course.location.org,
'category': 'lti',
'course': self.course.location.course,
'name': 'lti_draft',
'revision': 'draft'}
# creates one draft and one published lti module, in different sections
self.lti_published = ItemFactory.create(
parent_location=self.section1.location,
display_name="lti published",
category="lti",
location=Location(self.published_location_dict)
location=self.course.id.make_usage_key('lti', 'lti_published'),
)
self.lti_draft = ItemFactory.create(
parent_location=self.section2.location,
display_name="lti draft",
category="lti",
location=Location(self.draft_location_dict)
location=self.course.id.make_usage_key('lti', 'lti_published').replace(revision='draft'),
)
def expected_handler_url(self, handler):
@@ -178,7 +167,7 @@ class TestLTIModuleListing(ModuleStoreTestCase):
return "https://{}{}".format(settings.SITE_NAME, reverse(
'courseware.module_render.handle_xblock_callback_noauth',
args=[
self.course.id,
self.course.id.to_deprecated_string(),
quote_slashes(unicode(self.lti_published.scope_ids.usage_id).encode('utf-8')),
handler
]
@@ -197,7 +186,7 @@ class TestLTIModuleListing(ModuleStoreTestCase):
"""tests that the draft lti module is not a part of the endpoint response, but the published one is"""
request = mock.Mock()
request.method = 'GET'
response = get_course_lti_endpoints(request, self.course.id)
response = get_course_lti_endpoints(request, self.course.id.to_deprecated_string())
self.assertEqual(200, response.status_code)
self.assertEqual('application/json', response['Content-Type'])
@@ -216,5 +205,5 @@ class TestLTIModuleListing(ModuleStoreTestCase):
for method in DISALLOWED_METHODS:
request = mock.Mock()
request.method = method
response = get_course_lti_endpoints(request, self.course.id)
response = get_course_lti_endpoints(request, self.course.id.to_deprecated_string())
self.assertEqual(405, response.status_code)

View File

@@ -925,9 +925,10 @@ class TestXmoduleRuntimeEvent(TestSubmittingProblems):
return render.get_module( # pylint: disable=protected-access
user,
mock_request,
self.problem.id,
self.problem.location,
field_data_cache,
self.course.id)._xmodule
self.course.id
)._xmodule
def set_module_grade_using_publish(self, grade_dict):
"""Publish the user's grade, takes grade_dict as input"""
@@ -938,7 +939,7 @@ class TestXmoduleRuntimeEvent(TestSubmittingProblems):
def test_xmodule_runtime_publish(self):
"""Tests the publish mechanism"""
self.set_module_grade_using_publish(self.grade_dict)
student_module = StudentModule.objects.get(student=self.student_user, module_state_key=self.problem.id)
student_module = StudentModule.objects.get(student=self.student_user, module_state_key=self.problem.location)
self.assertEqual(student_module.grade, self.grade_dict['value'])
self.assertEqual(student_module.max_grade, self.grade_dict['max_value'])
@@ -946,7 +947,7 @@ class TestXmoduleRuntimeEvent(TestSubmittingProblems):
"""Test deleting the grade using the publish mechanism"""
module = self.set_module_grade_using_publish(self.grade_dict)
module.system.publish(module, 'grade', self.delete_dict)
student_module = StudentModule.objects.get(student=self.student_user, module_state_key=self.problem.id)
student_module = StudentModule.objects.get(student=self.student_user, module_state_key=self.problem.location)
self.assertIsNone(student_module.grade)
self.assertIsNone(student_module.max_grade)
@@ -973,7 +974,7 @@ class TestRebindModule(TestSubmittingProblems):
return render.get_module( # pylint: disable=protected-access
user,
mock_request,
self.lti.id,
self.lti.location,
field_data_cache,
self.course.id)._xmodule

View File

@@ -853,13 +853,18 @@ def get_course_lti_endpoints(request, course_id):
(django response object): HTTP response. 404 if course is not found, otherwise 200 with JSON body.
"""
try:
course = get_course(course_id, depth=2)
except ValueError: # get_course raises ValueError if course_id is invalid or doesn't refer to a course
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
except InvalidKeyError:
return HttpResponse(status=404)
try:
course = get_course(course_key, depth=2)
except ValueError:
return HttpResponse(status=404)
anonymous_user = AnonymousUser()
anonymous_user.known = False # make these "noauth" requests like module_render.handle_xblock_callback_noauth
lti_descriptors = modulestore().get_items(Location("i4x", course.org, course.number, "lti", None), course.id)
lti_descriptors = modulestore().get_items(course.id, category='lti')
lti_noauth_modules = [
get_module_for_descriptor(
@@ -867,11 +872,11 @@ def get_course_lti_endpoints(request, course_id):
request,
descriptor,
FieldDataCache.cache_for_descriptor_descendents(
course_id,
course_key,
anonymous_user,
descriptor
),
course_id
course_key
)
for descriptor in lti_descriptors
]