Commit 94c8d86a by Calen Pennington

Fix failing tests from merge with master

parent c72b0bb2
...@@ -157,7 +157,7 @@ class DashboardTest(TestCase): ...@@ -157,7 +157,7 @@ class DashboardTest(TestCase):
""" """
Check that the css class and the status message are in the dashboard html. Check that the css class and the status message are in the dashboard html.
""" """
CourseEnrollment.enroll(self.user, self.course.location.course_id, mode=mode) CourseEnrollment.enroll(self.user, self.course.location.course_key, mode=mode)
try: try:
response = self.client.get(reverse('dashboard')) response = self.client.get(reverse('dashboard'))
except NoReverseMatch: except NoReverseMatch:
...@@ -179,7 +179,7 @@ class DashboardTest(TestCase): ...@@ -179,7 +179,7 @@ class DashboardTest(TestCase):
""" """
Check that the css class and the status message are not in the dashboard html. Check that the css class and the status message are not in the dashboard html.
""" """
CourseEnrollment.enroll(self.user, self.course.location.course_id, mode=mode) CourseEnrollment.enroll(self.user, self.course.location.course_key, mode=mode)
try: try:
response = self.client.get(reverse('dashboard')) response = self.client.get(reverse('dashboard'))
except NoReverseMatch: except NoReverseMatch:
......
...@@ -194,8 +194,7 @@ class VideoStudentViewHandlers(object): ...@@ -194,8 +194,7 @@ class VideoStudentViewHandlers(object):
transcript_name = self.sub transcript_name = self.sub
if transcript_name: if transcript_name:
course_location = CourseDescriptor.id_to_location(self.course_id) course = self.descriptor.runtime.modulestore.get_course(self.course_id)
course = self.descriptor.runtime.modulestore.get_item(course_location)
if course.static_asset_path: if course.static_asset_path:
response = Response( response = Response(
status=307, status=307,
......
...@@ -79,7 +79,7 @@ class VideoFields(object): ...@@ -79,7 +79,7 @@ class VideoFields(object):
default=False default=False
) )
html5_sources = List( html5_sources = List(
help="The URL or URLs where youve posted non-YouTube versions of the video. Each URL must end in .mpeg, .mp4, .ogg, or .webm and cannot be a YouTube URL. Students will be able to view the first listed video that's compatible with the student's computer. To allow students to download these videos, set Video Download Allowed to True.", help="The URL or URLs where you've posted non-YouTube versions of the video. Each URL must end in .mpeg, .mp4, .ogg, or .webm and cannot be a YouTube URL. Students will be able to view the first listed video that's compatible with the student's computer. To allow students to download these videos, set Video Download Allowed to True.",
display_name="Video File URLs", display_name="Video File URLs",
scope=Scope.settings, scope=Scope.settings,
) )
......
...@@ -55,7 +55,7 @@ class TestOptoutCourseEmails(ModuleStoreTestCase): ...@@ -55,7 +55,7 @@ class TestOptoutCourseEmails(ModuleStoreTestCase):
# Select the Email view of the instructor dash # Select the Email view of the instructor dash
session = self.client.session session = self.client.session
session[u'idash_mode:{0}'.format(self.course.location.course_id)] = 'Email' session[u'idash_mode:{0}'.format(self.course.location.course_key.to_deprecated_string())] = 'Email'
session.save() session.save()
response = self.client.get(url) response = self.client.get(url)
selected_email_link = '<a href="#" onclick="goto(\'Email\')" class="selectedmode">Email</a>' selected_email_link = '<a href="#" onclick="goto(\'Email\')" class="selectedmode">Email</a>'
......
...@@ -77,7 +77,7 @@ class TestEmailSendFromDashboard(ModuleStoreTestCase): ...@@ -77,7 +77,7 @@ class TestEmailSendFromDashboard(ModuleStoreTestCase):
# Select the Email view of the instructor dash # Select the Email view of the instructor dash
session = self.client.session session = self.client.session
session[u'idash_mode:{0}'.format(self.course.location.course_id)] = 'Email' session[u'idash_mode:{0}'.format(self.course.location.course_key.to_deprecated_string())] = 'Email'
session.save() session.save()
response = self.client.get(self.url) response = self.client.get(self.url)
selected_email_link = '<a href="#" onclick="goto(\'Email\')" class="selectedmode">Email</a>' selected_email_link = '<a href="#" onclick="goto(\'Email\')" class="selectedmode">Email</a>'
......
...@@ -530,7 +530,7 @@ def get_module_for_descriptor_internal(user, descriptor, field_data_cache, cours ...@@ -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. # Do not check access when it's a noauth request.
if getattr(user, 'known', True): if getattr(user, 'known', True):
# Short circuit--if the user shouldn't have access, bail without doing any work # 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 return None
(system, student_data) = get_module_system_for_user( (system, student_data) = get_module_system_for_user(
......
...@@ -148,29 +148,18 @@ class TestLTIModuleListing(ModuleStoreTestCase): ...@@ -148,29 +148,18 @@ class TestLTIModuleListing(ModuleStoreTestCase):
display_name="section2", display_name="section2",
category='sequential') 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 # creates one draft and one published lti module, in different sections
self.lti_published = ItemFactory.create( self.lti_published = ItemFactory.create(
parent_location=self.section1.location, parent_location=self.section1.location,
display_name="lti published", display_name="lti published",
category="lti", category="lti",
location=Location(self.published_location_dict) location=self.course.id.make_usage_key('lti', 'lti_published'),
) )
self.lti_draft = ItemFactory.create( self.lti_draft = ItemFactory.create(
parent_location=self.section2.location, parent_location=self.section2.location,
display_name="lti draft", display_name="lti draft",
category="lti", 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): def expected_handler_url(self, handler):
...@@ -178,7 +167,7 @@ class TestLTIModuleListing(ModuleStoreTestCase): ...@@ -178,7 +167,7 @@ class TestLTIModuleListing(ModuleStoreTestCase):
return "https://{}{}".format(settings.SITE_NAME, reverse( return "https://{}{}".format(settings.SITE_NAME, reverse(
'courseware.module_render.handle_xblock_callback_noauth', 'courseware.module_render.handle_xblock_callback_noauth',
args=[ args=[
self.course.id, self.course.id.to_deprecated_string(),
quote_slashes(unicode(self.lti_published.scope_ids.usage_id).encode('utf-8')), quote_slashes(unicode(self.lti_published.scope_ids.usage_id).encode('utf-8')),
handler handler
] ]
...@@ -197,7 +186,7 @@ class TestLTIModuleListing(ModuleStoreTestCase): ...@@ -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""" """tests that the draft lti module is not a part of the endpoint response, but the published one is"""
request = mock.Mock() request = mock.Mock()
request.method = 'GET' 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(200, response.status_code)
self.assertEqual('application/json', response['Content-Type']) self.assertEqual('application/json', response['Content-Type'])
...@@ -216,5 +205,5 @@ class TestLTIModuleListing(ModuleStoreTestCase): ...@@ -216,5 +205,5 @@ class TestLTIModuleListing(ModuleStoreTestCase):
for method in DISALLOWED_METHODS: for method in DISALLOWED_METHODS:
request = mock.Mock() request = mock.Mock()
request.method = method 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) self.assertEqual(405, response.status_code)
...@@ -925,9 +925,10 @@ class TestXmoduleRuntimeEvent(TestSubmittingProblems): ...@@ -925,9 +925,10 @@ class TestXmoduleRuntimeEvent(TestSubmittingProblems):
return render.get_module( # pylint: disable=protected-access return render.get_module( # pylint: disable=protected-access
user, user,
mock_request, mock_request,
self.problem.id, self.problem.location,
field_data_cache, field_data_cache,
self.course.id)._xmodule self.course.id
)._xmodule
def set_module_grade_using_publish(self, grade_dict): def set_module_grade_using_publish(self, grade_dict):
"""Publish the user's grade, takes grade_dict as input""" """Publish the user's grade, takes grade_dict as input"""
...@@ -938,7 +939,7 @@ class TestXmoduleRuntimeEvent(TestSubmittingProblems): ...@@ -938,7 +939,7 @@ class TestXmoduleRuntimeEvent(TestSubmittingProblems):
def test_xmodule_runtime_publish(self): def test_xmodule_runtime_publish(self):
"""Tests the publish mechanism""" """Tests the publish mechanism"""
self.set_module_grade_using_publish(self.grade_dict) 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.grade, self.grade_dict['value'])
self.assertEqual(student_module.max_grade, self.grade_dict['max_value']) self.assertEqual(student_module.max_grade, self.grade_dict['max_value'])
...@@ -946,7 +947,7 @@ class TestXmoduleRuntimeEvent(TestSubmittingProblems): ...@@ -946,7 +947,7 @@ class TestXmoduleRuntimeEvent(TestSubmittingProblems):
"""Test deleting the grade using the publish mechanism""" """Test deleting the grade using the publish mechanism"""
module = self.set_module_grade_using_publish(self.grade_dict) module = self.set_module_grade_using_publish(self.grade_dict)
module.system.publish(module, 'grade', self.delete_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.grade)
self.assertIsNone(student_module.max_grade) self.assertIsNone(student_module.max_grade)
...@@ -973,7 +974,7 @@ class TestRebindModule(TestSubmittingProblems): ...@@ -973,7 +974,7 @@ class TestRebindModule(TestSubmittingProblems):
return render.get_module( # pylint: disable=protected-access return render.get_module( # pylint: disable=protected-access
user, user,
mock_request, mock_request,
self.lti.id, self.lti.location,
field_data_cache, field_data_cache,
self.course.id)._xmodule self.course.id)._xmodule
......
...@@ -853,13 +853,18 @@ def get_course_lti_endpoints(request, course_id): ...@@ -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. (django response object): HTTP response. 404 if course is not found, otherwise 200 with JSON body.
""" """
try: try:
course = get_course(course_id, depth=2) course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
except ValueError: # get_course raises ValueError if course_id is invalid or doesn't refer to a course except InvalidKeyError:
return HttpResponse(status=404)
try:
course = get_course(course_key, depth=2)
except ValueError:
return HttpResponse(status=404) return HttpResponse(status=404)
anonymous_user = AnonymousUser() anonymous_user = AnonymousUser()
anonymous_user.known = False # make these "noauth" requests like module_render.handle_xblock_callback_noauth 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 = [ lti_noauth_modules = [
get_module_for_descriptor( get_module_for_descriptor(
...@@ -867,11 +872,11 @@ def get_course_lti_endpoints(request, course_id): ...@@ -867,11 +872,11 @@ def get_course_lti_endpoints(request, course_id):
request, request,
descriptor, descriptor,
FieldDataCache.cache_for_descriptor_descendents( FieldDataCache.cache_for_descriptor_descendents(
course_id, course_key,
anonymous_user, anonymous_user,
descriptor descriptor
), ),
course_id course_key
) )
for descriptor in lti_descriptors for descriptor in lti_descriptors
] ]
......
...@@ -50,7 +50,7 @@ class TestInstructorDashboardEmailView(ModuleStoreTestCase): ...@@ -50,7 +50,7 @@ class TestInstructorDashboardEmailView(ModuleStoreTestCase):
# Select the Email view of the instructor dash # Select the Email view of the instructor dash
session = self.client.session session = self.client.session
session[u'idash_mode:{0}'.format(self.course.location.course_id)] = 'Email' session[u'idash_mode:{0}'.format(self.course.location.course_key)] = 'Email'
session.save() session.save()
response = self.client.get(self.url) response = self.client.get(self.url)
...@@ -131,7 +131,7 @@ class TestInstructorDashboardEmailView(ModuleStoreTestCase): ...@@ -131,7 +131,7 @@ class TestInstructorDashboardEmailView(ModuleStoreTestCase):
course_authorization.save() course_authorization.save()
session = self.client.session session = self.client.session
session[u'idash_mode:{0}'.format(self.course.location.course_id)] = 'Email' session[u'idash_mode:{0}'.format(self.course.location.course_key)] = 'Email'
session.save() session.save()
response = self.client.post( response = self.client.post(
......
...@@ -409,25 +409,25 @@ class CertificateItemTest(ModuleStoreTestCase): ...@@ -409,25 +409,25 @@ class CertificateItemTest(ModuleStoreTestCase):
def test_refund_cert_callback_before_expiration_email(self): def test_refund_cert_callback_before_expiration_email(self):
""" Test that refund emails are being sent correctly. """ """ Test that refund emails are being sent correctly. """
course_id = "refund_before_expiration/test/one" course = CourseFactory.create(org='refund_before_expiration', number='test', run='course', display_name='one')
course_key = course.id
many_days = datetime.timedelta(days=60) many_days = datetime.timedelta(days=60)
CourseFactory.create(org='refund_before_expiration', number='test', run='course', display_name='one') course_mode = CourseMode(course_id=course_key,
course_mode = CourseMode(course_id=course_id,
mode_slug="verified", mode_slug="verified",
mode_display_name="verified cert", mode_display_name="verified cert",
min_price=self.cost, min_price=self.cost,
expiration_datetime=datetime.datetime.now(pytz.utc) + many_days) expiration_datetime=datetime.datetime.now(pytz.utc) + many_days)
course_mode.save() course_mode.save()
CourseEnrollment.enroll(self.user, course_id, 'verified') CourseEnrollment.enroll(self.user, course_key, 'verified')
cart = Order.get_cart_for_user(user=self.user) cart = Order.get_cart_for_user(user=self.user)
CertificateItem.add_to_order(cart, course_id, self.cost, 'verified') CertificateItem.add_to_order(cart, course_key, self.cost, 'verified')
cart.purchase() cart.purchase()
mail.outbox = [] mail.outbox = []
with patch('shoppingcart.models.log.error') as mock_error_logger: with patch('shoppingcart.models.log.error') as mock_error_logger:
CourseEnrollment.unenroll(self.user, course_id) CourseEnrollment.unenroll(self.user, course_key)
self.assertFalse(mock_error_logger.called) self.assertFalse(mock_error_logger.called)
self.assertEquals(len(mail.outbox), 1) self.assertEquals(len(mail.outbox), 1)
self.assertEquals('[Refund] User-Requested Refund', mail.outbox[0].subject) self.assertEquals('[Refund] User-Requested Refund', mail.outbox[0].subject)
......
...@@ -89,14 +89,14 @@ class TestVerifiedView(TestCase): ...@@ -89,14 +89,14 @@ class TestVerifiedView(TestCase):
def setUp(self): def setUp(self):
self.user = UserFactory.create(username="abc", password="test") self.user = UserFactory.create(username="abc", password="test")
self.client.login(username="abc", password="test") self.client.login(username="abc", password="test")
self.course_id = "MITx/999.1x/Verified_Course"
self.course = CourseFactory.create(org='MITx', number='999.1x', display_name='Verified Course') self.course = CourseFactory.create(org='MITx', number='999.1x', display_name='Verified Course')
self.course_id = self.course.id
def test_verified_course_mode_none(self): def test_verified_course_mode_none(self):
""" """
Test VerifiedView when there is no active verified mode for course. Test VerifiedView when there is no active verified mode for course.
""" """
url = reverse('verify_student_verified', kwargs={"course_id": self.course_id}) url = reverse('verify_student_verified', kwargs={"course_id": self.course_id.to_deprecated_string()})
verify_mode = CourseMode.mode_for_course(self.course_id, "verified") verify_mode = CourseMode.mode_for_course(self.course_id, "verified")
# Verify mode should be None. # Verify mode should be None.
...@@ -161,8 +161,8 @@ class TestPhotoVerificationResultsCallback(TestCase): ...@@ -161,8 +161,8 @@ class TestPhotoVerificationResultsCallback(TestCase):
Tests for the results_callback view. Tests for the results_callback view.
""" """
def setUp(self): def setUp(self):
self.course_id = 'Robot/999/Test_Course' self.course = CourseFactory.create(org='Robot', number='999', display_name='Test Course')
CourseFactory.create(org='Robot', number='999', display_name='Test Course') self.course_id = self.course.id
self.user = UserFactory.create() self.user = UserFactory.create()
self.attempt = SoftwareSecurePhotoVerification( self.attempt = SoftwareSecurePhotoVerification(
status="submitted", status="submitted",
......
...@@ -271,7 +271,6 @@ def results_callback(request): ...@@ -271,7 +271,6 @@ def results_callback(request):
# If this is a reverification, log an event # If this is a reverification, log an event
if attempt.window: if attempt.window:
course_id = attempt.window.course_id course_id = attempt.window.course_id
course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)
course = course_from_id(course_id) course = course_from_id(course_id)
course_enrollment = CourseEnrollment.get_or_create_enrollment(attempt.user, course_id) course_enrollment = CourseEnrollment.get_or_create_enrollment(attempt.user, course_id)
course_enrollment.emit_event(EVENT_NAME_USER_REVERIFICATION_REVIEWED_BY_SOFTWARESECURE) course_enrollment.emit_event(EVENT_NAME_USER_REVERIFICATION_REVIEWED_BY_SOFTWARESECURE)
......
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