Commit 1b71ace4 by Mat Peterson Committed by Diana Huang

studio new style assumption corrections

parent e39cc5df
......@@ -311,7 +311,6 @@ class ContentStoreToyCourseTest(ContentStoreTestCase):
direct_store = self.store
_, course_items = import_from_xml(direct_store, self.user.id, 'common/test/data/', ['toy'])
usage_key = course_items[0].id.make_usage_key('vertical', 'vertical_test')
# also try a custom response which will trigger the 'is this course in whitelist' logic
resp = self.client.get_json(
get_url('xblock_view_handler', usage_key, kwargs={'view_name': 'container_preview'})
......@@ -319,10 +318,10 @@ class ContentStoreToyCourseTest(ContentStoreTestCase):
self.assertEqual(resp.status_code, 200)
# These are the data-ids of the xblocks contained in the vertical.
self.assertContains(resp, 'edX+toy+2012_Fall+video+sample_video')
self.assertContains(resp, 'edX+toy+2012_Fall+video+separate_file_video')
self.assertContains(resp, 'edX+toy+2012_Fall+video+video_with_end_time')
self.assertContains(resp, 'edX+toy+2012_Fall+poll_question+T1_changemind_poll_foo_2')
self.assertContains(resp, 'edX/toy/video/sample_video')
self.assertContains(resp, 'edX/toy/video/separate_file_video')
self.assertContains(resp, 'edX/toy/video/video_with_end_time')
self.assertContains(resp, 'edX/toy/poll_question/T1_changemind_poll_foo_2')
def test_delete(self):
store = self.store
......@@ -1217,7 +1216,7 @@ class ContentStoreTest(ContentStoreTestCase):
resp = self._show_course_overview(course.id)
self.assertContains(
resp,
'<article class="courseware-overview" data-locator="location:MITx+999+Robot_Super_Course+course+Robot_Super_Course" data-course-key="slashes:MITx+999+Robot_Super_Course">',
'<article class="courseware-overview" data-locator="i4x://MITx/999/course/Robot_Super_Course" data-course-key="MITx/999/Robot_Super_Course">',
status_code=200,
html=True
)
......@@ -1238,7 +1237,7 @@ class ContentStoreTest(ContentStoreTestCase):
data = parse_json(resp)
self.assertRegexpMatches(
data['locator'],
r"location:MITx\+999\+Robot_Super_Course\+chapter\+([0-9]|[a-f]){3,}$"
r"MITx/999/chapter/([0-9]|[a-f]){3,}$"
)
def test_capa_module(self):
......
......@@ -43,7 +43,7 @@ class ChecklistTestCase(CourseTestCase):
response = self.client.get(self.checklists_url)
self.assertContains(response, "Getting Started With Studio")
# Verify expansion of action URL happened.
self.assertContains(response, 'course_team/slashes:mitX+333+Checklists_Course')
self.assertContains(response, 'course_team/mitX/333/Checklists_Course')
# Verify persisted checklist does NOT have expanded URL.
checklist_0 = self.get_persisted_checklists()[0]
self.assertEqual('ManageUsers', get_action_url(checklist_0, 0))
......@@ -136,8 +136,8 @@ class ChecklistTestCase(CourseTestCase):
# Verify no side effect in the original list.
self.assertEqual(get_action_url(checklist, index), stored)
test_expansion(self.course.checklists[0], 0, 'ManageUsers', '/course_team/slashes:mitX+333+Checklists_Course/')
test_expansion(self.course.checklists[1], 1, 'CourseOutline', '/course/slashes:mitX+333+Checklists_Course')
test_expansion(self.course.checklists[0], 0, 'ManageUsers', '/course_team/mitX/333/Checklists_Course/')
test_expansion(self.course.checklists[1], 1, 'CourseOutline', '/course/mitX/333/Checklists_Course')
test_expansion(self.course.checklists[2], 0, 'http://help.edge.edx.org/', 'http://help.edge.edx.org/')
......
......@@ -96,7 +96,7 @@ class TestCourseIndex(CourseTestCase):
# First spot check some values in the root response
self.assertEqual(json_response['category'], 'course')
self.assertEqual(json_response['id'], 'location:MITx+999+Robot_Super_Course+course+Robot_Super_Course')
self.assertEqual(json_response['id'], 'i4x://MITx/999/course/Robot_Super_Course')
self.assertEqual(json_response['display_name'], 'Robot Super Course')
self.assertTrue(json_response['is_container'])
self.assertFalse(json_response['is_draft'])
......@@ -106,7 +106,7 @@ class TestCourseIndex(CourseTestCase):
self.assertTrue(len(children) > 0)
first_child_response = children[0]
self.assertEqual(first_child_response['category'], 'chapter')
self.assertEqual(first_child_response['id'], 'location:MITx+999+Robot_Super_Course+chapter+Week_1')
self.assertEqual(first_child_response['id'], 'i4x://MITx/999/chapter/Week_1')
self.assertEqual(first_child_response['display_name'], 'Week 1')
self.assertTrue(first_child_response['is_container'])
self.assertFalse(first_child_response['is_draft'])
......
......@@ -5,7 +5,8 @@ import json
from contentstore.tests.test_course_settings import CourseTestCase
from contentstore.utils import reverse_course_url, reverse_usage_url
from opaque_keys.edx.locations import Location, SlashSeparatedCourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.keys import UsageKey
from xmodule.modulestore.django import modulestore
......@@ -246,7 +247,7 @@ class CourseUpdateTest(CourseTestCase):
self.assertHTMLEqual(payload['content'], content)
updates_location = self.course.id.make_usage_key('course_info', 'updates')
self.assertTrue(isinstance(updates_location, Location))
self.assertTrue(isinstance(updates_location, UsageKey))
self.assertEqual(updates_location.name, block)
# check posting on handouts
......
......@@ -15,7 +15,7 @@ class HelpersTestCase(CourseTestCase):
# Verify course URL
self.assertEqual(xblock_studio_url(self.course),
u'/course/slashes:MITx+999+Robot_Super_Course')
u'/course/MITx/999/Robot_Super_Course')
# Verify chapter URL
chapter = ItemFactory.create(parent_location=self.course.location, category='chapter',
......@@ -31,13 +31,13 @@ class HelpersTestCase(CourseTestCase):
vertical = ItemFactory.create(parent_location=sequential.location, category='vertical',
display_name='Unit')
self.assertEqual(xblock_studio_url(vertical),
u'/unit/location:MITx+999+Robot_Super_Course+vertical+Unit')
u'/unit/i4x://MITx/999/vertical/Unit')
# Verify child vertical URL
child_vertical = ItemFactory.create(parent_location=vertical.location, category='vertical',
display_name='Child Vertical')
self.assertEqual(xblock_studio_url(child_vertical),
u'/container/location:MITx+999+Robot_Super_Course+vertical+Child_Vertical')
u'/container/i4x://MITx/999/vertical/Child_Vertical')
# Verify video URL
video = ItemFactory.create(parent_location=child_vertical.location, category="video",
......
......@@ -296,7 +296,7 @@ class ExportTestCase(CourseTestCase):
"""
fake_xblock = ItemFactory.create(parent_location=self.course.location, category='aawefawef')
self.store.publish(fake_xblock.location, self.user.id)
self._verify_export_failure(u'/unit/location:MITx+999+Robot_Super_Course+course+Robot_Super_Course')
self._verify_export_failure(u'/unit/i4x://MITx/999/course/Robot_Super_Course')
def test_export_failure_subsection_level(self):
"""
......@@ -308,7 +308,7 @@ class ExportTestCase(CourseTestCase):
category='aawefawef'
)
self._verify_export_failure(u'/unit/location:MITx+999+Robot_Super_Course+vertical+foo')
self._verify_export_failure(u'/unit/i4x://MITx/999/vertical/foo')
def _verify_export_failure(self, expectedText):
""" Export failure helper method. """
......
......@@ -158,7 +158,7 @@ class GetItem(ItemTest):
html,
# The instance of the wrapper class will have an auto-generated ID. Allow any
# characters after wrapper.
(r'"/container/location:MITx\+999\+Robot_Super_Course\+wrapper\+\w+" class="action-button">\s*'
(r'"/container/i4x://MITx/999/wrapper/\w+" class="action-button">\s*'
'<span class="action-button-text">View</span>')
)
......
......@@ -43,6 +43,6 @@ class GetPreviewHtmlTestCase(TestCase):
# Verify student view html is returned, and the usage ID is as expected.
self.assertRegexpMatches(
html,
'data-usage-id="location:MITx\+999\+Robot_Super_Course\+html\+html_[0-9]*"'
'data-usage-id="i4x://MITx/999/html/html_[0-9]*"'
)
self.assertRegexpMatches(html, '<html>foobar</html>')
......@@ -40,33 +40,34 @@ def check_has_course_method(modulestore, locator, locator_key_fields):
assert_true(modulestore.has_course(locator, ignore_case))
for key_field in locator_key_fields:
locator_changes_that_should_not_be_found = [ # pylint: disable=invalid-name
# replace value for one of the keys
{key_field: 'fake'},
# add a character at the end
{key_field: getattr(locator, key_field) + 'X'},
# add a character in the beginning
{key_field: 'X' + getattr(locator, key_field)},
]
for changes in locator_changes_that_should_not_be_found:
search_locator = locator.replace(**changes)
assert_false(
modulestore.has_course(search_locator),
error_message.format(search_locator, ignore_case)
)
if getattr(locator, key_field):
locator_changes_that_should_not_be_found = [ # pylint: disable=invalid-name
# replace value for one of the keys
{key_field: 'fake'},
# add a character at the end
{key_field: getattr(locator, key_field) + 'X'},
# add a character in the beginning
{key_field: 'X' + getattr(locator, key_field)},
]
for changes in locator_changes_that_should_not_be_found:
search_locator = locator.replace(**changes)
assert_false(
modulestore.has_course(search_locator),
error_message.format(search_locator, ignore_case)
)
# test case [in]sensitivity
locator_case_changes = [
{key_field: getattr(locator, key_field).upper()},
{key_field: getattr(locator, key_field).capitalize()},
{key_field: getattr(locator, key_field).capitalize().swapcase()},
]
for changes in locator_case_changes:
search_locator = locator.replace(**changes)
# if ignore_case is true, the course would be found with a different-cased course locator.
# if ignore_case is false, the course should NOT found given an incorrectly-cased locator.
assert_equals(
modulestore.has_course(search_locator, ignore_case) is not None,
ignore_case,
error_message.format(search_locator, ignore_case)
)
# test case [in]sensitivity
locator_case_changes = [
{key_field: getattr(locator, key_field).upper()},
{key_field: getattr(locator, key_field).capitalize()},
{key_field: getattr(locator, key_field).capitalize().swapcase()},
]
for changes in locator_case_changes:
search_locator = locator.replace(**changes)
# if ignore_case is true, the course would be found with a different-cased course locator.
# if ignore_case is false, the course should NOT found given an incorrectly-cased locator.
assert_equals(
modulestore.has_course(search_locator, ignore_case) is not None,
ignore_case,
error_message.format(search_locator, ignore_case)
)
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