Merge pull request #15770 from edx/christina/slash-the-slash

Remove usages of deprecated SlashSeparatedCourseKey.
This commit is contained in:
Christina Roberts
2017-08-08 16:36:49 -04:00
committed by GitHub
20 changed files with 69 additions and 67 deletions

View File

@@ -12,7 +12,8 @@ from xmodule.modulestore import ModuleStoreEnum
from xmodule.x_module import XModuleMixin
from xmodule.tests import DATA_DIR
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import CourseLocator
from xmodule.modulestore.tests.test_modulestore import check_has_course_method
@@ -51,13 +52,13 @@ class TestXMLModuleStore(unittest.TestCase):
load_error_modules=False)
# Look up the errors during load. There should be none.
errors = modulestore.get_course_errors(SlashSeparatedCourseKey("edX", "toy", "2012_Fall"))
errors = modulestore.get_course_errors(CourseKey.from_string("edX/toy/2012_Fall"))
assert errors == []
@patch("xmodule.modulestore.xml.glob.glob", side_effect=glob_tildes_at_end)
def test_tilde_files_ignored(self, _fake_glob):
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['tilde'], load_error_modules=False)
about_location = SlashSeparatedCourseKey('edX', 'tilde', '2012_Fall').make_usage_key(
about_location = CourseKey.from_string('edX/tilde/2012_Fall').make_usage_key(
'about', 'index',
)
about_module = modulestore.get_item(about_location)
@@ -78,7 +79,7 @@ class TestXMLModuleStore(unittest.TestCase):
self.assertEqual(len(course_locations), 0)
# now set toy course to share the wiki with simple course
toy_course = store.get_course(SlashSeparatedCourseKey('edX', 'toy', '2012_Fall'))
toy_course = store.get_course(CourseKey.from_string('edX/toy/2012_Fall'))
toy_course.wiki_slug = 'simple'
course_locations = store.get_courses_for_wiki('toy')
@@ -87,7 +88,7 @@ class TestXMLModuleStore(unittest.TestCase):
course_locations = store.get_courses_for_wiki('simple')
self.assertEqual(len(course_locations), 2)
for course_number in ['toy', 'simple']:
self.assertIn(SlashSeparatedCourseKey('edX', course_number, '2012_Fall'), course_locations)
self.assertIn(CourseKey.from_string('/'.join(['edX', course_number, '2012_Fall'])), course_locations)
def test_has_course(self):
"""
@@ -95,8 +96,8 @@ class TestXMLModuleStore(unittest.TestCase):
"""
check_has_course_method(
XMLModuleStore(DATA_DIR, source_dirs=['toy', 'simple']),
SlashSeparatedCourseKey('edX', 'toy', '2012_Fall'),
locator_key_fields=SlashSeparatedCourseKey.KEY_FIELDS
CourseKey.from_string('edX/toy/2012_Fall'),
locator_key_fields=CourseLocator.KEY_FIELDS
)
def test_branch_setting(self):

View File

@@ -11,7 +11,7 @@ from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.inheritance import InheritanceMixin
from xmodule.modulestore.xml_importer import _update_and_import_module, _update_module_location
from xmodule.modulestore.tests.mongo_connection import MONGO_PORT_NUM, MONGO_HOST
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.keys import CourseKey
from xmodule.tests import DATA_DIR
from uuid import uuid4
import unittest
@@ -143,7 +143,7 @@ class RemapNamespaceTest(ModuleStoreNoSettings):
self.xblock.save()
# Move to different runtime w/ different course id
target_location_namespace = SlashSeparatedCourseKey("org", "course", "run")
target_location_namespace = CourseKey.from_string("org/course/run")
new_version = _update_and_import_module(
self.xblock,
modulestore(),

View File

@@ -5,7 +5,8 @@ import unittest
from xmodule.tests import get_test_system
from xmodule.error_module import ErrorDescriptor, ErrorModule, NonStaffErrorDescriptor
from xmodule.modulestore.xml import CourseLocationManager
from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location
from opaque_keys.edx.locator import CourseLocator
from opaque_keys.edx.locations import Location
from xmodule.x_module import XModuleDescriptor, XModule, STUDENT_VIEW
from mock import MagicMock, Mock, patch
from xblock.runtime import Runtime, IdReader
@@ -19,7 +20,7 @@ class SetupTestErrorModules(unittest.TestCase):
def setUp(self):
super(SetupTestErrorModules, self).setUp()
self.system = get_test_system()
self.course_id = SlashSeparatedCourseKey('org', 'course', 'run')
self.course_id = CourseLocator('org', 'course', 'run')
self.location = self.course_id.make_usage_key('foo', 'bar')
self.valid_xml = u"<problem>ABC \N{SNOWMAN}</problem>"
self.error_msg = "Error"

View File

@@ -1,7 +1,7 @@
import unittest
from mock import Mock
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.locator import CourseLocator
from xblock.field_data import DictFieldData
from xblock.fields import ScopeIds
@@ -15,7 +15,7 @@ def instantiate_descriptor(**field_data):
Instantiate descriptor with most properties.
"""
system = get_test_descriptor_system()
course_key = SlashSeparatedCourseKey('org', 'course', 'run')
course_key = CourseLocator('org', 'course', 'run')
usage_key = course_key.make_usage_key('html', 'SampleHtml')
return system.construct_xblock_from_class(
HtmlDescriptor,

View File

@@ -19,6 +19,7 @@ from xmodule.x_module import XModuleMixin
from xmodule.fields import Date
from xmodule.tests import DATA_DIR
from xmodule.modulestore.inheritance import InheritanceMixin
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xblock.core import XBlock
@@ -576,7 +577,7 @@ class ImportTestCase(BaseCourseTestCase):
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'])
toy_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
toy_id = CourseKey.from_string('edX/toy/2012_Fall')
course = modulestore.get_course(toy_id)
chapters = course.get_children()
@@ -654,7 +655,7 @@ class ImportTestCase(BaseCourseTestCase):
"""
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'])
toy_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
toy_id = CourseKey.from_string('edX/toy/2012_Fall')
course = modulestore.get_course(toy_id)

View File

@@ -4,7 +4,7 @@ Tests that check that we ignore the appropriate files when importing courses.
import unittest
from mock import Mock
from xmodule.modulestore.xml_importer import import_static_content
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.locator import CourseLocator
from xmodule.tests import DATA_DIR
@@ -12,7 +12,7 @@ class IgnoredFilesTestCase(unittest.TestCase):
"Tests for ignored files"
def test_ignore_tilde_static_files(self):
course_dir = DATA_DIR / "tilde"
course_id = SlashSeparatedCourseKey("edX", "tilde", "Fall_2012")
course_id = CourseLocator("edX", "tilde", "Fall_2012")
content_store = Mock()
content_store.generate_thumbnail.return_value = ("content", "location")
import_static_content(course_dir, content_store, course_id)
@@ -27,7 +27,7 @@ class IgnoredFilesTestCase(unittest.TestCase):
Test for ignored Mac OS metadata files (filename starts with "._")
"""
course_dir = DATA_DIR / "dot-underscore"
course_id = SlashSeparatedCourseKey("edX", "dot-underscore", "2014_Fall")
course_id = CourseLocator("edX", "dot-underscore", "2014_Fall")
content_store = Mock()
content_store.generate_thumbnail.return_value = ("content", "location")
import_static_content(course_dir, content_store, course_id)

View File

@@ -24,7 +24,7 @@ import ddt
from django.conf import settings
from django.test.utils import override_settings
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.locator import CourseLocator
from opaque_keys.edx.keys import CourseKey
from xblock.field_data import DictFieldData
from xblock.fields import ScopeIds
@@ -92,7 +92,7 @@ def instantiate_descriptor(**field_data):
Instantiate descriptor with most properties.
"""
system = get_test_descriptor_system()
course_key = SlashSeparatedCourseKey('org', 'course', 'run')
course_key = CourseLocator('org', 'course', 'run')
usage_key = course_key.make_usage_key('video', 'SampleProblem')
return system.construct_xblock_from_class(
VideoDescriptor,

View File

@@ -9,7 +9,7 @@ from unittest import TestCase
from xmodule.x_module import XMLParsingSystem, policy_key
from xmodule.mako_module import MakoDescriptorSystem
from xmodule.modulestore.xml import CourseLocationManager
from opaque_keys.edx.locations import SlashSeparatedCourseKey, Location
from opaque_keys.edx.keys import CourseKey
from xblock.runtime import KvsFieldData, DictKeyValueStore
@@ -19,7 +19,7 @@ class InMemorySystem(XMLParsingSystem, MakoDescriptorSystem): # pylint: disable
The simplest possible XMLParsingSystem
"""
def __init__(self, xml_import_data):
self.course_id = SlashSeparatedCourseKey.from_deprecated_string(xml_import_data.course_id)
self.course_id = CourseKey.from_string(xml_import_data.course_id)
self.default_class = xml_import_data.default_class
self._descriptors = {}