Commit 6f71706b by cahrens

Remove SlashSeparatedCourseKey from tests.

parent 198dbc1e
...@@ -4,7 +4,7 @@ or with filename which starts with "._") ...@@ -4,7 +4,7 @@ or with filename which starts with "._")
""" """
from django.core.management import call_command from django.core.management import call_command
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from xmodule.contentstore.content import XASSET_LOCATION_TAG from xmodule.contentstore.content import XASSET_LOCATION_TAG
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
...@@ -44,7 +44,7 @@ class ExportAllCourses(ModuleStoreTestCase): ...@@ -44,7 +44,7 @@ class ExportAllCourses(ModuleStoreTestCase):
verbose=True verbose=True
) )
course = self.module_store.get_course(SlashSeparatedCourseKey('edX', 'dot-underscore', '2014_Fall')) course = self.module_store.get_course(CourseKey.from_string('/'.join(['edX', 'dot-underscore', '2014_Fall'])))
self.assertIsNotNone(course) self.assertIsNotNone(course)
# check that there are two assets ['example.txt', '.example.txt'] in contentstore for imported course # check that there are two assets ['example.txt', '.example.txt'] in contentstore for imported course
......
...@@ -4,7 +4,7 @@ Unittests for deleting a course in an chosen modulestore ...@@ -4,7 +4,7 @@ Unittests for deleting a course in an chosen modulestore
import mock import mock
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from django.core.management import call_command, CommandError from django.core.management import call_command, CommandError
from django.contrib.auth.models import User from django.contrib.auth.models import User
from contentstore.tests.utils import CourseTestCase from contentstore.tests.utils import CourseTestCase
...@@ -54,14 +54,14 @@ class DeleteCourseTest(CourseTestCase): ...@@ -54,14 +54,14 @@ class DeleteCourseTest(CourseTestCase):
""" """
Testing if the entered course was deleted Testing if the entered course was deleted
""" """
course_key = CourseKey.from_string('/'.join(["TestX", "TS01", "2015_Q1"]))
#Test if the course that is about to be deleted exists #Test if the course that is about to be deleted exists
self.assertIsNotNone(modulestore().get_course(SlashSeparatedCourseKey("TestX", "TS01", "2015_Q1"))) self.assertIsNotNone(modulestore().get_course(course_key))
with mock.patch(self.YESNO_PATCH_LOCATION) as patched_yes_no: with mock.patch(self.YESNO_PATCH_LOCATION) as patched_yes_no:
patched_yes_no.return_value = True patched_yes_no.return_value = True
call_command('delete_course', 'TestX/TS01/2015_Q1') call_command('delete_course', 'TestX/TS01/2015_Q1')
self.assertIsNone(modulestore().get_course(SlashSeparatedCourseKey("TestX", "TS01", "2015_Q1"))) self.assertIsNone(modulestore().get_course(course_key))
def test_course_deletion_with_keep_instructors(self): def test_course_deletion_with_keep_instructors(self):
""" """
......
...@@ -18,7 +18,7 @@ from django.test.utils import override_settings ...@@ -18,7 +18,7 @@ from django.test.utils import override_settings
from contentstore.tests.utils import CourseTestCase from contentstore.tests.utils import CourseTestCase
import contentstore.git_export_utils as git_export_utils import contentstore.git_export_utils as git_export_utils
from contentstore.git_export_utils import GitExportError from contentstore.git_export_utils import GitExportError
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator
FEATURES_WITH_EXPORT_GIT = settings.FEATURES.copy() FEATURES_WITH_EXPORT_GIT = settings.FEATURES.copy()
FEATURES_WITH_EXPORT_GIT['ENABLE_EXPORT_GIT'] = True FEATURES_WITH_EXPORT_GIT['ENABLE_EXPORT_GIT'] = True
...@@ -88,7 +88,7 @@ class TestGitExport(CourseTestCase): ...@@ -88,7 +88,7 @@ class TestGitExport(CourseTestCase):
""" """
Test several bad URLs for validation Test several bad URLs for validation
""" """
course_key = SlashSeparatedCourseKey('org', 'course', 'run') course_key = CourseLocator('org', 'course', 'run')
with self.assertRaisesRegexp(GitExportError, unicode(GitExportError.URL_BAD)): with self.assertRaisesRegexp(GitExportError, unicode(GitExportError.URL_BAD)):
git_export_utils.export_to_git(course_key, 'Sillyness') git_export_utils.export_to_git(course_key, 'Sillyness')
...@@ -105,7 +105,7 @@ class TestGitExport(CourseTestCase): ...@@ -105,7 +105,7 @@ class TestGitExport(CourseTestCase):
""" """
test_repo_path = '{}/test_repo'.format(git_export_utils.GIT_REPO_EXPORT_DIR) test_repo_path = '{}/test_repo'.format(git_export_utils.GIT_REPO_EXPORT_DIR)
self.assertFalse(os.path.isdir(test_repo_path)) self.assertFalse(os.path.isdir(test_repo_path))
course_key = SlashSeparatedCourseKey('foo', 'blah', '100-') course_key = CourseLocator('foo', 'blah', '100-')
# Test bad clones # Test bad clones
with self.assertRaisesRegexp(GitExportError, with self.assertRaisesRegexp(GitExportError,
unicode(GitExportError.CANNOT_PULL)): unicode(GitExportError.CANNOT_PULL)):
......
...@@ -28,15 +28,6 @@ class CloneCourseTest(CourseTestCase): ...@@ -28,15 +28,6 @@ class CloneCourseTest(CourseTestCase):
"""Tests cloning of a course as follows: XML -> Mongo (+ data) -> Mongo -> Split -> Split""" """Tests cloning of a course as follows: XML -> Mongo (+ data) -> Mongo -> Split -> Split"""
# 1. import and populate test toy course # 1. import and populate test toy course
mongo_course1_id = self.import_and_populate_course() mongo_course1_id = self.import_and_populate_course()
# 2. clone course (mongo -> mongo)
# TODO - This is currently failing since clone_course doesn't handle Private content - fails on Publish
# mongo_course2_id = SlashSeparatedCourseKey('edX2', 'toy2', '2013_Fall')
# self.store.clone_course(mongo_course1_id, mongo_course2_id, self.user.id)
# self.assertCoursesEqual(mongo_course1_id, mongo_course2_id)
# self.check_populated_course(mongo_course2_id)
# NOTE: When the code above is uncommented this can be removed.
mongo_course2_id = mongo_course1_id mongo_course2_id = mongo_course1_id
# 3. clone course (mongo -> split) # 3. clone course (mongo -> split)
......
...@@ -3,7 +3,7 @@ import collections ...@@ -3,7 +3,7 @@ import collections
from datetime import datetime, timedelta from datetime import datetime, timedelta
from django.test import TestCase from django.test import TestCase
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator
from pytz import UTC from pytz import UTC
from contentstore import utils from contentstore import utils
...@@ -21,26 +21,26 @@ class LMSLinksTestCase(TestCase): ...@@ -21,26 +21,26 @@ class LMSLinksTestCase(TestCase):
def lms_link_test(self): def lms_link_test(self):
""" Tests get_lms_link_for_item. """ """ Tests get_lms_link_for_item. """
course_key = SlashSeparatedCourseKey('mitX', '101', 'test') course_key = CourseLocator('mitX', '101', 'test')
location = course_key.make_usage_key('vertical', 'contacting_us') location = course_key.make_usage_key('vertical', 'contacting_us')
link = utils.get_lms_link_for_item(location, False) link = utils.get_lms_link_for_item(location, False)
self.assertEquals(link, "//localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us") self.assertEquals(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type@vertical+block@contacting_us")
# test preview # test preview
link = utils.get_lms_link_for_item(location, True) link = utils.get_lms_link_for_item(location, True)
self.assertEquals( self.assertEquals(
link, link,
"//preview.localhost/courses/mitX/101/test/jump_to/i4x://mitX/101/vertical/contacting_us" "//preview.localhost/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type@vertical+block@contacting_us"
) )
# now test with the course' location # now test with the course' location
location = course_key.make_usage_key('course', 'test') location = course_key.make_usage_key('course', 'test')
link = utils.get_lms_link_for_item(location) link = utils.get_lms_link_for_item(location)
self.assertEquals(link, "//localhost:8000/courses/mitX/101/test/jump_to/i4x://mitX/101/course/test") self.assertEquals(link, "//localhost:8000/courses/course-v1:mitX+101+test/jump_to/block-v1:mitX+101+test+type@course+block@test")
def lms_link_for_certificate_web_view_test(self): def lms_link_for_certificate_web_view_test(self):
""" Tests get_lms_link_for_certificate_web_view. """ """ Tests get_lms_link_for_certificate_web_view. """
course_key = SlashSeparatedCourseKey('mitX', '101', 'test') course_key = CourseLocator('mitX', '101', 'test')
dummy_user = ModuleStoreEnum.UserID.test dummy_user = ModuleStoreEnum.UserID.test
mode = 'professional' mode = 'professional'
......
...@@ -8,7 +8,8 @@ from django.conf import settings ...@@ -8,7 +8,8 @@ from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.test.client import Client from django.test.client import Client
from mock import Mock from mock import Mock
from opaque_keys.edx.locations import AssetLocation, SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import AssetLocation
from contentstore.utils import reverse_url from contentstore.utils import reverse_url
from student.models import Registration from student.models import Registration
...@@ -129,7 +130,7 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase): ...@@ -129,7 +130,7 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase):
""" """
content_store = contentstore() content_store = contentstore()
import_course_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'], static_content_store=content_store) import_course_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'], static_content_store=content_store)
course_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') course_id = CourseKey.from_string('/'.join(['edX', 'toy', '2012_Fall']))
# create an Orphan # create an Orphan
# We had a bug where orphaned draft nodes caused export to fail. This is here to cover that case. # We had a bug where orphaned draft nodes caused export to fail. This is here to cover that case.
......
...@@ -3,7 +3,7 @@ Tests access.py ...@@ -3,7 +3,7 @@ Tests access.py
""" """
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.test import TestCase from django.test import TestCase
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator
from contentstore.views.access import get_user_role from contentstore.views.access import get_user_role
from student.auth import add_users from student.auth import add_users
...@@ -22,7 +22,7 @@ class RolesTest(TestCase): ...@@ -22,7 +22,7 @@ class RolesTest(TestCase):
self.global_admin = AdminFactory() self.global_admin = AdminFactory()
self.instructor = User.objects.create_user('testinstructor', 'testinstructor+courses@edx.org', 'foo') self.instructor = User.objects.create_user('testinstructor', 'testinstructor+courses@edx.org', 'foo')
self.staff = User.objects.create_user('teststaff', 'teststaff+courses@edx.org', 'foo') self.staff = User.objects.create_user('teststaff', 'teststaff+courses@edx.org', 'foo')
self.course_key = SlashSeparatedCourseKey('mitX', '101', 'test') self.course_key = CourseLocator('mitX', '101', 'test')
def test_get_user_role_instructor(self): def test_get_user_role_instructor(self):
""" """
......
...@@ -10,7 +10,8 @@ from ddt import data, ddt ...@@ -10,7 +10,8 @@ from ddt import data, ddt
from django.conf import settings from django.conf import settings
from django.test.utils import override_settings from django.test.utils import override_settings
from mock import patch from mock import patch
from opaque_keys.edx.locations import AssetLocation, SlashSeparatedCourseKey from opaque_keys.edx.locations import AssetLocation
from opaque_keys.edx.locator import CourseLocator
from PIL import Image from PIL import Image
from pytz import UTC from pytz import UTC
...@@ -80,7 +81,7 @@ class BasicAssetsTestCase(AssetsTestCase): ...@@ -80,7 +81,7 @@ class BasicAssetsTestCase(AssetsTestCase):
def test_static_url_generation(self): def test_static_url_generation(self):
course_key = SlashSeparatedCourseKey('org', 'class', 'run') course_key = CourseLocator('org', 'class', 'run')
location = course_key.make_asset_key('asset', 'my_file_name.jpg') location = course_key.make_asset_key('asset', 'my_file_name.jpg')
path = StaticContent.get_static_path_from_location(location) path = StaticContent.get_static_path_from_location(location)
self.assertEquals(path, '/static/my_file_name.jpg') self.assertEquals(path, '/static/my_file_name.jpg')
...@@ -348,7 +349,7 @@ class AssetToJsonTestCase(AssetsTestCase): ...@@ -348,7 +349,7 @@ class AssetToJsonTestCase(AssetsTestCase):
def test_basic(self): def test_basic(self):
upload_date = datetime(2013, 6, 1, 10, 30, tzinfo=UTC) upload_date = datetime(2013, 6, 1, 10, 30, tzinfo=UTC)
content_type = 'image/jpg' content_type = 'image/jpg'
course_key = SlashSeparatedCourseKey('org', 'class', 'run') course_key = CourseLocator('org', 'class', 'run')
location = course_key.make_asset_key('asset', 'my_file_name.jpg') location = course_key.make_asset_key('asset', 'my_file_name.jpg')
thumbnail_location = course_key.make_asset_key('thumbnail', 'my_file_name_thumb.jpg') thumbnail_location = course_key.make_asset_key('thumbnail', 'my_file_name_thumb.jpg')
...@@ -357,10 +358,10 @@ class AssetToJsonTestCase(AssetsTestCase): ...@@ -357,10 +358,10 @@ class AssetToJsonTestCase(AssetsTestCase):
self.assertEquals(output["display_name"], "my_file") self.assertEquals(output["display_name"], "my_file")
self.assertEquals(output["date_added"], "Jun 01, 2013 at 10:30 UTC") self.assertEquals(output["date_added"], "Jun 01, 2013 at 10:30 UTC")
self.assertEquals(output["url"], "/c4x/org/class/asset/my_file_name.jpg") self.assertEquals(output["url"], "/asset-v1:org+class+run+type@asset+block@my_file_name.jpg")
self.assertEquals(output["external_url"], "lms_base_url/c4x/org/class/asset/my_file_name.jpg") self.assertEquals(output["external_url"], "lms_base_url/asset-v1:org+class+run+type@asset+block@my_file_name.jpg")
self.assertEquals(output["portable_url"], "/static/my_file_name.jpg") self.assertEquals(output["portable_url"], "/static/my_file_name.jpg")
self.assertEquals(output["thumbnail"], "/c4x/org/class/thumbnail/my_file_name_thumb.jpg") self.assertEquals(output["thumbnail"], "/asset-v1:org+class+run+type@thumbnail+block@my_file_name_thumb.jpg")
self.assertEquals(output["id"], unicode(location)) self.assertEquals(output["id"], unicode(location))
self.assertEquals(output['locked'], True) self.assertEquals(output['locked'], True)
......
...@@ -5,7 +5,7 @@ import random ...@@ -5,7 +5,7 @@ import random
from factory import lazy_attribute from factory import lazy_attribute
from factory.django import DjangoModelFactory from factory.django import DjangoModelFactory
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator
from course_modes.models import CourseMode from course_modes.models import CourseMode
...@@ -16,7 +16,7 @@ class CourseModeFactory(DjangoModelFactory): ...@@ -16,7 +16,7 @@ class CourseModeFactory(DjangoModelFactory):
class Meta(object): class Meta(object):
model = CourseMode model = CourseMode
course_id = SlashSeparatedCourseKey('MITx', '999', 'Robot_Super_Course') course_id = CourseLocator('MITx', '999', 'Robot_Super_Course')
mode_slug = 'audit' mode_slug = 'audit'
currency = 'usd' currency = 'usd'
expiration_datetime = None expiration_datetime = None
......
...@@ -13,7 +13,6 @@ import pytz ...@@ -13,7 +13,6 @@ import pytz
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.test import TestCase, override_settings from django.test import TestCase, override_settings
from mock import patch from mock import patch
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.locator import CourseLocator from opaque_keys.edx.locator import CourseLocator
from course_modes.helpers import enrollment_mode_display from course_modes.helpers import enrollment_mode_display
...@@ -33,7 +32,7 @@ class CourseModeModelTest(TestCase): ...@@ -33,7 +32,7 @@ class CourseModeModelTest(TestCase):
def setUp(self): def setUp(self):
super(CourseModeModelTest, self).setUp() super(CourseModeModelTest, self).setUp()
self.course_key = SlashSeparatedCourseKey('Test', 'TestCourse', 'TestCourseRun') self.course_key = CourseLocator('Test', 'TestCourse', 'TestCourseRun')
CourseMode.objects.all().delete() CourseMode.objects.all().delete()
def tearDown(self): def tearDown(self):
...@@ -156,7 +155,7 @@ class CourseModeModelTest(TestCase): ...@@ -156,7 +155,7 @@ class CourseModeModelTest(TestCase):
modes = CourseMode.modes_for_course(self.course_key) modes = CourseMode.modes_for_course(self.course_key)
self.assertEqual([expired_mode_value, mode1], modes) self.assertEqual([expired_mode_value, mode1], modes)
modes = CourseMode.modes_for_course(SlashSeparatedCourseKey('TestOrg', 'TestCourse', 'TestRun')) modes = CourseMode.modes_for_course(CourseLocator('TestOrg', 'TestCourse', 'TestRun'))
self.assertEqual([CourseMode.DEFAULT_MODE], modes) self.assertEqual([CourseMode.DEFAULT_MODE], modes)
def test_verified_mode_for_course(self): def test_verified_mode_for_course(self):
......
...@@ -10,7 +10,7 @@ from django.test import override_settings ...@@ -10,7 +10,7 @@ from django.test import override_settings
from django.utils.http import urlencode, urlquote from django.utils.http import urlencode, urlquote
from mock import Mock, patch from mock import Mock, patch
from nose.tools import assert_equals, assert_false, assert_true # pylint: disable=no-name-in-module from nose.tools import assert_equals, assert_false, assert_true # pylint: disable=no-name-in-module
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from PIL import Image from PIL import Image
from static_replace import ( from static_replace import (
...@@ -32,7 +32,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, check_mongo_calls ...@@ -32,7 +32,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, check_mongo_calls
from xmodule.modulestore.xml import XMLModuleStore from xmodule.modulestore.xml import XMLModuleStore
DATA_DIRECTORY = 'data_dir' DATA_DIRECTORY = 'data_dir'
COURSE_KEY = SlashSeparatedCourseKey('org', 'course', 'run') COURSE_KEY = CourseKey.from_string('org/course/run')
STATIC_SOURCE = '"/static/file.png"' STATIC_SOURCE = '"/static/file.png"'
......
...@@ -4,8 +4,8 @@ Tests for sandboxing.py in util app ...@@ -4,8 +4,8 @@ Tests for sandboxing.py in util app
from django.test import TestCase from django.test import TestCase
from django.test.utils import override_settings from django.test.utils import override_settings
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import LibraryLocator from opaque_keys.edx.locator import CourseLocator, LibraryLocator
from util.sandboxing import can_execute_unsafe_code from util.sandboxing import can_execute_unsafe_code
...@@ -19,7 +19,7 @@ class SandboxingTest(TestCase): ...@@ -19,7 +19,7 @@ class SandboxingTest(TestCase):
""" """
Test to make sure that a non-match returns false Test to make sure that a non-match returns false
""" """
self.assertFalse(can_execute_unsafe_code(SlashSeparatedCourseKey('edX', 'notful', 'empty'))) self.assertFalse(can_execute_unsafe_code(CourseLocator('edX', 'notful', 'empty')))
self.assertFalse(can_execute_unsafe_code(LibraryLocator('edY', 'test_bank'))) self.assertFalse(can_execute_unsafe_code(LibraryLocator('edY', 'test_bank')))
@override_settings(COURSES_WITH_UNSAFE_CODE=['edX/full/.*']) @override_settings(COURSES_WITH_UNSAFE_CODE=['edX/full/.*'])
...@@ -27,14 +27,14 @@ class SandboxingTest(TestCase): ...@@ -27,14 +27,14 @@ class SandboxingTest(TestCase):
""" """
Test to make sure that a match works across course runs Test to make sure that a match works across course runs
""" """
self.assertTrue(can_execute_unsafe_code(SlashSeparatedCourseKey('edX', 'full', '2012_Fall'))) self.assertTrue(can_execute_unsafe_code(CourseKey.from_string('edX/full/2012_Fall')))
self.assertTrue(can_execute_unsafe_code(SlashSeparatedCourseKey('edX', 'full', '2013_Spring'))) self.assertTrue(can_execute_unsafe_code(CourseKey.from_string('edX/full/2013_Spring')))
self.assertFalse(can_execute_unsafe_code(LibraryLocator('edX', 'test_bank'))) self.assertFalse(can_execute_unsafe_code(LibraryLocator('edX', 'test_bank')))
def test_courselikes_with_unsafe_code_default(self): def test_courselikes_with_unsafe_code_default(self):
""" """
Test that the default setting for COURSES_WITH_UNSAFE_CODE is an empty setting, e.g. we don't use @override_settings in these tests Test that the default setting for COURSES_WITH_UNSAFE_CODE is an empty setting, e.g. we don't use @override_settings in these tests
""" """
self.assertFalse(can_execute_unsafe_code(SlashSeparatedCourseKey('edX', 'full', '2012_Fall'))) self.assertFalse(can_execute_unsafe_code(CourseLocator('edX', 'full', '2012_Fall')))
self.assertFalse(can_execute_unsafe_code(SlashSeparatedCourseKey('edX', 'full', '2013_Spring'))) self.assertFalse(can_execute_unsafe_code(CourseLocator('edX', 'full', '2013_Spring')))
self.assertFalse(can_execute_unsafe_code(LibraryLocator('edX', 'test_bank'))) self.assertFalse(can_execute_unsafe_code(LibraryLocator('edX', 'test_bank')))
...@@ -40,7 +40,7 @@ from xblock.test.tools import TestRuntime ...@@ -40,7 +40,7 @@ from xblock.test.tools import TestRuntime
if not settings.configured: if not settings.configured:
settings.configure() settings.configure()
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator, LibraryLocator from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator, LibraryLocator
from xmodule.exceptions import InvalidVersionError from xmodule.exceptions import InvalidVersionError
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
...@@ -323,7 +323,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup): ...@@ -323,7 +323,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
) )
# try an unknown mapping, it should be the 'default' store # try an unknown mapping, it should be the 'default' store
self.assertEqual(self.store.get_modulestore_type( self.assertEqual(self.store.get_modulestore_type(
SlashSeparatedCourseKey('foo', 'bar', '2012_Fall')), default_ms CourseKey.from_string('foo/bar/2012_Fall')), default_ms
) )
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
......
...@@ -29,7 +29,7 @@ from opaque_keys.edx.locations import Location ...@@ -29,7 +29,7 @@ from opaque_keys.edx.locations import Location
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.mongo import MongoKeyValueStore from xmodule.modulestore.mongo import MongoKeyValueStore
from xmodule.modulestore.draft import DraftModuleStore from xmodule.modulestore.draft import DraftModuleStore
from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation from opaque_keys.edx.locations import AssetLocation
from opaque_keys.edx.locator import LibraryLocator, CourseLocator from opaque_keys.edx.locator import LibraryLocator, CourseLocator
from opaque_keys.edx.keys import UsageKey from opaque_keys.edx.keys import UsageKey
from xmodule.modulestore.xml_exporter import export_course_to_xml from xmodule.modulestore.xml_exporter import export_course_to_xml
...@@ -160,7 +160,7 @@ class TestMongoModuleStoreBase(unittest.TestCase): ...@@ -160,7 +160,7 @@ class TestMongoModuleStoreBase(unittest.TestCase):
static_content_store=content_store, static_content_store=content_store,
do_import_static=False, do_import_static=False,
verbose=True, verbose=True,
target_id=SlashSeparatedCourseKey('guestx', 'foo', 'bar') target_id=CourseKey.from_string('guestx/foo/bar')
) )
return content_store, draft_store return content_store, draft_store
...@@ -216,7 +216,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -216,7 +216,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
for course_key in [ for course_key in [
SlashSeparatedCourseKey(*fields) CourseKey.from_string('/'.join(fields))
for fields in [ for fields in [
['edX', 'simple', '2012_Fall'], ['edX', 'simple', '2012_Fall'],
['edX', 'simple_with_draft', '2012_Fall'], ['edX', 'simple_with_draft', '2012_Fall'],
...@@ -230,8 +230,8 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -230,8 +230,8 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course = self.draft_store.get_course(course_key) course = self.draft_store.get_course(course_key)
assert_not_none(course) assert_not_none(course)
assert_true(self.draft_store.has_course(course_key)) assert_true(self.draft_store.has_course(course_key))
mix_cased = SlashSeparatedCourseKey( mix_cased = CourseKey.from_string(
course_key.org.upper(), course_key.course.upper(), course_key.run.lower() '/'.join([course_key.org.upper(), course_key.course.upper(), course_key.run.lower()])
) )
assert_false(self.draft_store.has_course(mix_cased)) assert_false(self.draft_store.has_course(mix_cased))
assert_true(self.draft_store.has_course(mix_cased, ignore_case=True)) assert_true(self.draft_store.has_course(mix_cased, ignore_case=True))
...@@ -247,7 +247,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -247,7 +247,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course_ids = [course.id for course in courses] course_ids = [course.id for course in courses]
for course_key in [ for course_key in [
SlashSeparatedCourseKey(*fields) CourseKey.from_string('/'.join(fields))
for fields in [ for fields in [
['guestx', 'foo', 'bar'] ['guestx', 'foo', 'bar']
] ]
...@@ -259,7 +259,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -259,7 +259,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course_ids = [course.id for course in courses] course_ids = [course.id for course in courses]
for course_key in [ for course_key in [
SlashSeparatedCourseKey(*fields) CourseKey.from_string('/'.join(fields))
for fields in [ for fields in [
['edX', 'simple', '2012_Fall'], ['edX', 'simple', '2012_Fall'],
['edX', 'simple_with_draft', '2012_Fall'], ['edX', 'simple_with_draft', '2012_Fall'],
...@@ -276,7 +276,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -276,7 +276,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
""" """
for course_key in [ for course_key in [
SlashSeparatedCourseKey(*fields) CourseKey.from_string('/'.join(fields))
for fields in [ for fields in [
['edX', 'simple', 'no_such_course'], ['edX', 'no_such_course', '2012_Fall'], ['edX', 'simple', 'no_such_course'], ['edX', 'no_such_course', '2012_Fall'],
['NO_SUCH_COURSE', 'Test_iMport_courSe', '2012_Fall'], ['NO_SUCH_COURSE', 'Test_iMport_courSe', '2012_Fall'],
...@@ -285,8 +285,8 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -285,8 +285,8 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course = self.draft_store.get_course(course_key) course = self.draft_store.get_course(course_key)
assert_is_none(course) assert_is_none(course)
assert_false(self.draft_store.has_course(course_key)) assert_false(self.draft_store.has_course(course_key))
mix_cased = SlashSeparatedCourseKey( mix_cased = CourseKey.from_string(
course_key.org.lower(), course_key.course.upper(), course_key.run.upper() '/'.join([course_key.org.lower(), course_key.course.upper(), course_key.run.upper()])
) )
assert_false(self.draft_store.has_course(mix_cased)) assert_false(self.draft_store.has_course(mix_cased))
assert_false(self.draft_store.has_course(mix_cased, ignore_case=True)) assert_false(self.draft_store.has_course(mix_cased, ignore_case=True))
...@@ -449,13 +449,13 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -449,13 +449,13 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
for course_number in self.courses: for course_number in self.courses:
course_locations = self.draft_store.get_courses_for_wiki(course_number) course_locations = self.draft_store.get_courses_for_wiki(course_number)
assert_equals(len(course_locations), 1) assert_equals(len(course_locations), 1)
assert_equals(SlashSeparatedCourseKey('edX', course_number, '2012_Fall'), course_locations[0]) assert_equals(CourseKey.from_string('/'.join(['edX', course_number, '2012_Fall'])), course_locations[0])
course_locations = self.draft_store.get_courses_for_wiki('no_such_wiki') course_locations = self.draft_store.get_courses_for_wiki('no_such_wiki')
assert_equals(len(course_locations), 0) assert_equals(len(course_locations), 0)
# set toy course to share the wiki with simple course # set toy course to share the wiki with simple course
toy_course = self.draft_store.get_course(SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')) toy_course = self.draft_store.get_course(CourseKey.from_string('edX/toy/2012_Fall'))
toy_course.wiki_slug = 'simple' toy_course.wiki_slug = 'simple'
self.draft_store.update_item(toy_course, ModuleStoreEnum.UserID.test) self.draft_store.update_item(toy_course, ModuleStoreEnum.UserID.test)
...@@ -467,23 +467,23 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -467,23 +467,23 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course_locations = self.draft_store.get_courses_for_wiki('simple') course_locations = self.draft_store.get_courses_for_wiki('simple')
assert_equals(len(course_locations), 2) assert_equals(len(course_locations), 2)
for course_number in ['toy', 'simple']: for course_number in ['toy', 'simple']:
assert_in(SlashSeparatedCourseKey('edX', course_number, '2012_Fall'), course_locations) assert_in(CourseKey.from_string('/'.join(['edX', course_number, '2012_Fall'])), course_locations)
# configure simple course to use unique wiki_slug. # configure simple course to use unique wiki_slug.
simple_course = self.draft_store.get_course(SlashSeparatedCourseKey('edX', 'simple', '2012_Fall')) simple_course = self.draft_store.get_course(CourseKey.from_string('edX/simple/2012_Fall'))
simple_course.wiki_slug = 'edX.simple.2012_Fall' simple_course.wiki_slug = 'edX.simple.2012_Fall'
self.draft_store.update_item(simple_course, ModuleStoreEnum.UserID.test) self.draft_store.update_item(simple_course, ModuleStoreEnum.UserID.test)
# it should be retrievable with its new wiki_slug # it should be retrievable with its new wiki_slug
course_locations = self.draft_store.get_courses_for_wiki('edX.simple.2012_Fall') course_locations = self.draft_store.get_courses_for_wiki('edX.simple.2012_Fall')
assert_equals(len(course_locations), 1) assert_equals(len(course_locations), 1)
assert_in(SlashSeparatedCourseKey('edX', 'simple', '2012_Fall'), course_locations) assert_in(CourseKey.from_string('edX/simple/2012_Fall'), course_locations)
@XBlock.register_temp_plugin(ReferenceTestXBlock, 'ref_test') @XBlock.register_temp_plugin(ReferenceTestXBlock, 'ref_test')
def test_reference_converters(self): def test_reference_converters(self):
""" """
Test that references types get deserialized correctly Test that references types get deserialized correctly
""" """
course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') course_key = CourseKey.from_string('edX/toy/2012_Fall')
def setup_test(): def setup_test():
course = self.draft_store.get_course(course_key) course = self.draft_store.get_course(course_key)
...@@ -563,7 +563,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -563,7 +563,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
Test to make sure that we have a course image in the contentstore, Test to make sure that we have a course image in the contentstore,
then export it to ensure it gets copied to both file locations. then export it to ensure it gets copied to both file locations.
""" """
course_key = SlashSeparatedCourseKey('edX', 'simple', '2012_Fall') course_key = CourseKey.from_string('edX/simple/2012_Fall')
location = course_key.make_asset_key('asset', 'images_course_image.jpg') location = course_key.make_asset_key('asset', 'images_course_image.jpg')
# This will raise if the course image is missing # This will raise if the course image is missing
...@@ -581,7 +581,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -581,7 +581,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
Make sure that if a non-default image path is specified that we Make sure that if a non-default image path is specified that we
don't export it to the static default location don't export it to the static default location
""" """
course = self.draft_store.get_course(SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')) course = self.draft_store.get_course(CourseKey.from_string('edX/toy/2012_Fall'))
assert_true(course.course_image, 'just_a_test.jpg') assert_true(course.course_image, 'just_a_test.jpg')
root_dir = path(mkdtemp()) root_dir = path(mkdtemp())
...@@ -595,7 +595,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -595,7 +595,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
Make sure we elegantly passover our code when there isn't a static Make sure we elegantly passover our code when there isn't a static
image image
""" """
course = self.draft_store.get_course(SlashSeparatedCourseKey('edX', 'simple_with_draft', '2012_Fall')) course = self.draft_store.get_course(CourseKey.from_string('edX/simple_with_draft/2012_Fall'))
root_dir = path(mkdtemp()) root_dir = path(mkdtemp())
self.addCleanup(shutil.rmtree, root_dir) self.addCleanup(shutil.rmtree, root_dir)
export_course_to_xml(self.draft_store, self.content_store, course.id, root_dir, 'test_export') export_course_to_xml(self.draft_store, self.content_store, course.id, root_dir, 'test_export')
...@@ -619,7 +619,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase): ...@@ -619,7 +619,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course = 'tree{}'.format(name) course = 'tree{}'.format(name)
run = name run = name
if not self.draft_store.has_course(SlashSeparatedCourseKey(org, course, run)): if not self.draft_store.has_course(CourseKey.from_string('/'.join[org, course, run])):
self.draft_store.create_course(org, course, run, user_id) self.draft_store.create_course(org, course, run, user_id)
locations = { locations = {
...@@ -755,7 +755,7 @@ class TestMongoKeyValueStore(unittest.TestCase): ...@@ -755,7 +755,7 @@ class TestMongoKeyValueStore(unittest.TestCase):
def setUp(self): def setUp(self):
super(TestMongoKeyValueStore, self).setUp() super(TestMongoKeyValueStore, self).setUp()
self.data = {'foo': 'foo_value'} self.data = {'foo': 'foo_value'}
self.course_id = SlashSeparatedCourseKey('org', 'course', 'run') self.course_id = CourseKey.from_string('org/course/run')
self.parent = self.course_id.make_usage_key('parent', 'p') self.parent = self.course_id.make_usage_key('parent', 'p')
self.children = [self.course_id.make_usage_key('child', 'a'), self.course_id.make_usage_key('child', 'b')] self.children = [self.course_id.make_usage_key('child', 'a'), self.course_id.make_usage_key('child', 'b')]
self.metadata = {'meta': 'meta_val'} self.metadata = {'meta': 'meta_val'}
......
...@@ -14,7 +14,7 @@ from django.core.urlresolvers import reverse ...@@ -14,7 +14,7 @@ from django.core.urlresolvers import reverse
from django.db import DatabaseError from django.db import DatabaseError
from mock import Mock, patch from mock import Mock, patch
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator
from bulk_email.models import SEND_TO_MYSELF, BulkEmailFlag, CourseEmail from bulk_email.models import SEND_TO_MYSELF, BulkEmailFlag, CourseEmail
from bulk_email.tasks import perform_delegate_email_batches, send_course_email from bulk_email.tasks import perform_delegate_email_batches, send_course_email
...@@ -193,7 +193,7 @@ class TestEmailErrors(ModuleStoreTestCase): ...@@ -193,7 +193,7 @@ class TestEmailErrors(ModuleStoreTestCase):
""" """
Tests exception when the course in the email doesn't exist Tests exception when the course in the email doesn't exist
""" """
course_id = SlashSeparatedCourseKey("I", "DONT", "EXIST") course_id = CourseLocator("I", "DONT", "EXIST")
email = CourseEmail(course_id=course_id) email = CourseEmail(course_id=course_id)
email.save() email.save()
entry = InstructorTask.create(course_id, "task_type", "task_key", "task_input", self.instructor) entry = InstructorTask.create(course_id, "task_type", "task_key", "task_input", self.instructor)
...@@ -250,7 +250,7 @@ class TestEmailErrors(ModuleStoreTestCase): ...@@ -250,7 +250,7 @@ class TestEmailErrors(ModuleStoreTestCase):
Tests exception when the course_id in CourseEmail is not the same as one explicitly passed in. Tests exception when the course_id in CourseEmail is not the same as one explicitly passed in.
""" """
email = CourseEmail.create( email = CourseEmail.create(
SlashSeparatedCourseKey("bogus", "course", "id"), CourseLocator("bogus", "course", "id"),
self.instructor, self.instructor,
[SEND_TO_MYSELF], [SEND_TO_MYSELF],
"re: subject", "re: subject",
......
...@@ -4,7 +4,7 @@ Unit tests for bulk-email-related forms. ...@@ -4,7 +4,7 @@ Unit tests for bulk-email-related forms.
""" """
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator
from bulk_email.forms import CourseAuthorizationAdminForm, CourseEmailTemplateForm from bulk_email.forms import CourseAuthorizationAdminForm, CourseEmailTemplateForm
from bulk_email.models import BulkEmailFlag, CourseEmailTemplate from bulk_email.models import BulkEmailFlag, CourseEmailTemplate
...@@ -70,7 +70,7 @@ class CourseAuthorizationFormTest(ModuleStoreTestCase): ...@@ -70,7 +70,7 @@ class CourseAuthorizationFormTest(ModuleStoreTestCase):
def test_form_typo(self): def test_form_typo(self):
# Munge course id # Munge course id
bad_id = SlashSeparatedCourseKey(u'Broken{}'.format(self.course.id.org), 'hello', self.course.id.run + '_typo') bad_id = CourseLocator(u'Broken{}'.format(self.course.id.org), 'hello', self.course.id.run + '_typo')
form_data = {'course_id': bad_id.to_deprecated_string(), 'email_enabled': True} form_data = {'course_id': bad_id.to_deprecated_string(), 'email_enabled': True}
form = CourseAuthorizationAdminForm(data=form_data) form = CourseAuthorizationAdminForm(data=form_data)
......
...@@ -28,7 +28,7 @@ from django.conf import settings ...@@ -28,7 +28,7 @@ from django.conf import settings
from django.core.management import call_command from django.core.management import call_command
from mock import Mock, patch from mock import Mock, patch
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator
from bulk_email.models import SEND_TO_LEARNERS, SEND_TO_MYSELF, SEND_TO_STAFF, CourseEmail, Optout from bulk_email.models import SEND_TO_LEARNERS, SEND_TO_MYSELF, SEND_TO_STAFF, CourseEmail, Optout
from bulk_email.tasks import _get_course_email_context from bulk_email.tasks import _get_course_email_context
...@@ -120,7 +120,7 @@ class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase): ...@@ -120,7 +120,7 @@ class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase):
def test_email_undefined_course(self): def test_email_undefined_course(self):
# Check that we fail when passing in a course that doesn't exist. # Check that we fail when passing in a course that doesn't exist.
task_entry = self._create_input_entry(course_id=SlashSeparatedCourseKey("bogus", "course", "id")) task_entry = self._create_input_entry(course_id=CourseLocator("bogus", "course", "id"))
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
self._run_task_with_mock_celery(send_bulk_course_email, task_entry.id, task_entry.task_id) self._run_task_with_mock_celery(send_bulk_course_email, task_entry.id, task_entry.task_id)
......
...@@ -5,7 +5,8 @@ from functools import partial ...@@ -5,7 +5,8 @@ from functools import partial
import factory import factory
from factory.django import DjangoModelFactory from factory.django import DjangoModelFactory
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import CourseLocator
from courseware.models import ( from courseware.models import (
StudentModule, StudentModule,
...@@ -27,7 +28,7 @@ from student.tests.factories import UserFactory # Imported to re-export ...@@ -27,7 +28,7 @@ from student.tests.factories import UserFactory # Imported to re-export
# TODO fix this (course_id and location are invalid names as constants, and course_id should really be COURSE_KEY) # TODO fix this (course_id and location are invalid names as constants, and course_id should really be COURSE_KEY)
# pylint: disable=invalid-name # pylint: disable=invalid-name
course_id = SlashSeparatedCourseKey(u'edX', u'test_course', u'test') course_id = CourseKey.from_string('edX/test_course/test')
location = partial(course_id.make_usage_key, u'problem') location = partial(course_id.make_usage_key, u'problem')
...@@ -128,7 +129,7 @@ class StudentModuleFactory(DjangoModelFactory): ...@@ -128,7 +129,7 @@ class StudentModuleFactory(DjangoModelFactory):
module_type = "problem" module_type = "problem"
student = factory.SubFactory(UserFactory) student = factory.SubFactory(UserFactory)
course_id = SlashSeparatedCourseKey("MITx", "999", "Robot_Super_Course") course_id = CourseLocator("MITx", "999", "Robot_Super_Course")
state = None state = None
grade = None grade = None
max_grade = None max_grade = None
......
...@@ -15,7 +15,7 @@ from django.test.client import RequestFactory ...@@ -15,7 +15,7 @@ from django.test.client import RequestFactory
from milestones.tests.utils import MilestonesTestCaseMixin from milestones.tests.utils import MilestonesTestCaseMixin
from mock import Mock, patch from mock import Mock, patch
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator
import courseware.access as access import courseware.access as access
import courseware.access_response as access_response import courseware.access_response as access_response
...@@ -500,7 +500,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes ...@@ -500,7 +500,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
user = UserFactory.create() user = UserFactory.create()
course = Mock( course = Mock(
enrollment_start=tomorrow, enrollment_end=tomorrow, enrollment_start=tomorrow, enrollment_end=tomorrow,
id=SlashSeparatedCourseKey('edX', 'test', '2012_Fall'), enrollment_domain='' id=CourseLocator('edX', 'test', '2012_Fall'), enrollment_domain=''
) )
CourseEnrollmentAllowedFactory(email=user.email, course_id=course.id) CourseEnrollmentAllowedFactory(email=user.email, course_id=course.id)
self.assertTrue(access._has_access_course(user, 'enroll', course)) self.assertTrue(access._has_access_course(user, 'enroll', course))
...@@ -513,7 +513,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes ...@@ -513,7 +513,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
# and not specifically allowed # and not specifically allowed
course = Mock( course = Mock(
enrollment_start=yesterday, enrollment_end=tomorrow, enrollment_start=yesterday, enrollment_end=tomorrow,
id=SlashSeparatedCourseKey('edX', 'test', '2012_Fall'), enrollment_domain='', id=CourseLocator('edX', 'test', '2012_Fall'), enrollment_domain='',
invitation_only=True invitation_only=True
) )
user = UserFactory.create() user = UserFactory.create()
...@@ -522,7 +522,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes ...@@ -522,7 +522,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
# Non-staff can enroll if it is between the start and end dates and not invitation only # Non-staff can enroll if it is between the start and end dates and not invitation only
course = Mock( course = Mock(
enrollment_start=yesterday, enrollment_end=tomorrow, enrollment_start=yesterday, enrollment_end=tomorrow,
id=SlashSeparatedCourseKey('edX', 'test', '2012_Fall'), enrollment_domain='', id=CourseLocator('edX', 'test', '2012_Fall'), enrollment_domain='',
invitation_only=False invitation_only=False
) )
self.assertTrue(access._has_access_course(user, 'enroll', course)) self.assertTrue(access._has_access_course(user, 'enroll', course))
...@@ -530,7 +530,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes ...@@ -530,7 +530,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
# Non-staff cannot enroll outside the open enrollment period if not specifically allowed # Non-staff cannot enroll outside the open enrollment period if not specifically allowed
course = Mock( course = Mock(
enrollment_start=tomorrow, enrollment_end=tomorrow, enrollment_start=tomorrow, enrollment_end=tomorrow,
id=SlashSeparatedCourseKey('edX', 'test', '2012_Fall'), enrollment_domain='', id=CourseLocator('edX', 'test', '2012_Fall'), enrollment_domain='',
invitation_only=False invitation_only=False
) )
self.assertFalse(access._has_access_course(user, 'enroll', course)) self.assertFalse(access._has_access_course(user, 'enroll', course))
...@@ -544,7 +544,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes ...@@ -544,7 +544,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
Tests the catalog visibility tri-states Tests the catalog visibility tri-states
""" """
user = UserFactory.create() user = UserFactory.create()
course_id = SlashSeparatedCourseKey('edX', 'test', '2012_Fall') course_id = CourseLocator('edX', 'test', '2012_Fall')
staff = StaffFactory.create(course_key=course_id) staff = StaffFactory.create(course_key=course_id)
course = Mock( course = Mock(
...@@ -558,7 +558,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes ...@@ -558,7 +558,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
# Now set visibility to just about page # Now set visibility to just about page
course = Mock( course = Mock(
id=SlashSeparatedCourseKey('edX', 'test', '2012_Fall'), id=CourseLocator('edX', 'test', '2012_Fall'),
catalog_visibility=CATALOG_VISIBILITY_ABOUT catalog_visibility=CATALOG_VISIBILITY_ABOUT
) )
self.assertFalse(access._has_access_course(user, 'see_in_catalog', course)) self.assertFalse(access._has_access_course(user, 'see_in_catalog', course))
...@@ -568,7 +568,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes ...@@ -568,7 +568,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
# Now set visibility to none, which means neither in catalog nor about pages # Now set visibility to none, which means neither in catalog nor about pages
course = Mock( course = Mock(
id=SlashSeparatedCourseKey('edX', 'test', '2012_Fall'), id=CourseLocator('edX', 'test', '2012_Fall'),
catalog_visibility=CATALOG_VISIBILITY_NONE catalog_visibility=CATALOG_VISIBILITY_NONE
) )
self.assertFalse(access._has_access_course(user, 'see_in_catalog', course)) self.assertFalse(access._has_access_course(user, 'see_in_catalog', course))
...@@ -675,7 +675,7 @@ class UserRoleTestCase(TestCase): ...@@ -675,7 +675,7 @@ class UserRoleTestCase(TestCase):
def setUp(self): def setUp(self):
super(UserRoleTestCase, self).setUp() super(UserRoleTestCase, self).setUp()
self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') self.course_key = CourseLocator('edX', 'toy', '2012_Fall')
self.anonymous_user = AnonymousUserFactory() self.anonymous_user = AnonymousUserFactory()
self.student = UserFactory() self.student = UserFactory()
self.global_staff = UserFactory(is_staff=True) self.global_staff = UserFactory(is_staff=True)
......
from django.test import TestCase from django.test import TestCase
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
...@@ -14,7 +14,7 @@ class TestDraftModuleStore(TestCase): ...@@ -14,7 +14,7 @@ class TestDraftModuleStore(TestCase):
store = modulestore() store = modulestore()
# fix was to allow get_items() to take the course_id parameter # fix was to allow get_items() to take the course_id parameter
store.get_items(SlashSeparatedCourseKey('a', 'b', 'c'), qualifiers={'category': 'vertical'}) store.get_items(CourseKey.from_string('a/b/c'), qualifiers={'category': 'vertical'})
# test success is just getting through the above statement. # test success is just getting through the above statement.
# The bug was that 'course_id' argument was # The bug was that 'course_id' argument was
......
...@@ -24,7 +24,6 @@ from milestones.tests.utils import MilestonesTestCaseMixin ...@@ -24,7 +24,6 @@ from milestones.tests.utils import MilestonesTestCaseMixin
from mock import MagicMock, Mock, patch from mock import MagicMock, Mock, patch
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.keys import CourseKey, UsageKey from opaque_keys.edx.keys import CourseKey, UsageKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from pyquery import PyQuery from pyquery import PyQuery
from xblock.core import XBlock, XBlockAside from xblock.core import XBlock, XBlockAside
from xblock.field_data import FieldData from xblock.field_data import FieldData
...@@ -1645,14 +1644,14 @@ class TestAnonymousStudentId(SharedModuleStoreTestCase, LoginEnrollmentTestCase) ...@@ -1645,14 +1644,14 @@ class TestAnonymousStudentId(SharedModuleStoreTestCase, LoginEnrollmentTestCase)
# This value is set by observation, so that later changes to the student # This value is set by observation, so that later changes to the student
# id computation don't break old data # id computation don't break old data
'e3b0b940318df9c14be59acb08e78af5', 'e3b0b940318df9c14be59acb08e78af5',
self._get_anonymous_id(SlashSeparatedCourseKey('MITx', '6.00x', '2012_Fall'), descriptor_class) self._get_anonymous_id(CourseKey.from_string('MITx/6.00x/2012_Fall'), descriptor_class)
) )
self.assertEquals( self.assertEquals(
# This value is set by observation, so that later changes to the student # This value is set by observation, so that later changes to the student
# id computation don't break old data # id computation don't break old data
'f82b5416c9f54b5ce33989511bb5ef2e', 'f82b5416c9f54b5ce33989511bb5ef2e',
self._get_anonymous_id(SlashSeparatedCourseKey('MITx', '6.00x', '2013_Spring'), descriptor_class) self._get_anonymous_id(CourseKey.from_string('MITx/6.00x/2013_Spring'), descriptor_class)
) )
......
...@@ -41,7 +41,8 @@ from lms.djangoapps.grades.config.waffle import ASSUME_ZERO_GRADE_IF_ABSENT ...@@ -41,7 +41,8 @@ from lms.djangoapps.grades.config.waffle import ASSUME_ZERO_GRADE_IF_ABSENT
from milestones.tests.utils import MilestonesTestCaseMixin from milestones.tests.utils import MilestonesTestCaseMixin
from mock import MagicMock, PropertyMock, create_autospec, patch from mock import MagicMock, PropertyMock, create_autospec, patch
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import Location, SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import Location
from openedx.core.djangoapps.catalog.tests.factories import CourseFactory as CatalogCourseFactory from openedx.core.djangoapps.catalog.tests.factories import CourseFactory as CatalogCourseFactory
from openedx.core.djangoapps.catalog.tests.factories import CourseRunFactory, ProgramFactory from openedx.core.djangoapps.catalog.tests.factories import CourseRunFactory, ProgramFactory
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
...@@ -86,7 +87,7 @@ class TestJumpTo(ModuleStoreTestCase): ...@@ -86,7 +87,7 @@ class TestJumpTo(ModuleStoreTestCase):
def setUp(self): def setUp(self):
super(TestJumpTo, self).setUp() super(TestJumpTo, self).setUp()
# Use toy course from XML # Use toy course from XML
self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') self.course_key = CourseKey.from_string('edX/toy/2012_Fall')
def test_jumpto_invalid_location(self): def test_jumpto_invalid_location(self):
location = self.course_key.make_usage_key(None, 'NoSuchPlace') location = self.course_key.make_usage_key(None, 'NoSuchPlace')
...@@ -1187,7 +1188,7 @@ class StartDateTests(ModuleStoreTestCase): ...@@ -1187,7 +1188,7 @@ class StartDateTests(ModuleStoreTestCase):
) )
@unittest.skip @unittest.skip
def test_format_localized_in_xml_course(self): def test_format_localized_in_xml_course(self):
response = self.get_about_response(SlashSeparatedCourseKey('edX', 'toy', 'TT_2012_Fall')) response = self.get_about_response(CourseKey.fron_string('edX/toy/TT_2012_Fall'))
# The start date is set in common/test/data/two_toys/policies/TT_2012_Fall/policy.json # The start date is set in common/test/data/two_toys/policies/TT_2012_Fall/policy.json
self.assertContains(response, "2015-JULY-17") self.assertContains(response, "2015-JULY-17")
......
...@@ -7,7 +7,7 @@ from unittest import TestCase ...@@ -7,7 +7,7 @@ from unittest import TestCase
import mock import mock
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from courseware.tests.helpers import LoginEnrollmentTestCase from courseware.tests.helpers import LoginEnrollmentTestCase
from lms.djangoapps.lms_xblock.field_data import LmsFieldData from lms.djangoapps.lms_xblock.field_data import LmsFieldData
...@@ -151,7 +151,7 @@ class TestDraftModuleStore(ModuleStoreTestCase): ...@@ -151,7 +151,7 @@ class TestDraftModuleStore(ModuleStoreTestCase):
store = modulestore() store = modulestore()
# fix was to allow get_items() to take the course_id parameter # fix was to allow get_items() to take the course_id parameter
store.get_items(SlashSeparatedCourseKey('abc', 'def', 'ghi'), qualifiers={'category': 'vertical'}) store.get_items(CourseKey.from_string('abc/def/ghi'), qualifiers={'category': 'vertical'})
# test success is just getting through the above statement. # test success is just getting through the above statement.
# The bug was that 'course_id' argument was # The bug was that 'course_id' argument was
......
...@@ -14,7 +14,7 @@ from django.core.management import call_command ...@@ -14,7 +14,7 @@ from django.core.management import call_command
from django.core.management.base import CommandError from django.core.management.base import CommandError
from django.test.utils import override_settings from django.test.utils import override_settings
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
import dashboard.git_import as git_import import dashboard.git_import as git_import
from dashboard.git_import import ( from dashboard.git_import import (
...@@ -57,7 +57,7 @@ class TestGitAddCourse(SharedModuleStoreTestCase): ...@@ -57,7 +57,7 @@ class TestGitAddCourse(SharedModuleStoreTestCase):
TEST_REPO = 'https://github.com/mitocw/edx4edx_lite.git' TEST_REPO = 'https://github.com/mitocw/edx4edx_lite.git'
TEST_COURSE = 'MITx/edx4edx/edx4edx' TEST_COURSE = 'MITx/edx4edx/edx4edx'
TEST_BRANCH = 'testing_do_not_delete' TEST_BRANCH = 'testing_do_not_delete'
TEST_BRANCH_COURSE = SlashSeparatedCourseKey('MITx', 'edx4edx_branch', 'edx4edx') TEST_BRANCH_COURSE = CourseKey.from_string('MITx/edx4edx_branch/edx4edx')
ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache'] ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache']
...@@ -183,7 +183,7 @@ class TestGitAddCourse(SharedModuleStoreTestCase): ...@@ -183,7 +183,7 @@ class TestGitAddCourse(SharedModuleStoreTestCase):
repo_dir / 'edx4edx_lite', repo_dir / 'edx4edx_lite',
'master') 'master')
self.assertIsNone(def_ms.get_course(self.TEST_BRANCH_COURSE)) self.assertIsNone(def_ms.get_course(self.TEST_BRANCH_COURSE))
self.assertIsNotNone(def_ms.get_course(SlashSeparatedCourseKey.from_deprecated_string(self.TEST_COURSE))) self.assertIsNotNone(def_ms.get_course(CourseKey.from_string(self.TEST_COURSE)))
def test_branch_exceptions(self): def test_branch_exceptions(self):
""" """
......
...@@ -16,7 +16,7 @@ from django.test.client import Client ...@@ -16,7 +16,7 @@ from django.test.client import Client
from django.test.utils import override_settings from django.test.utils import override_settings
from django.utils.timezone import utc as UTC from django.utils.timezone import utc as UTC
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from dashboard.git_import import GitImportErrorNoDir from dashboard.git_import import GitImportErrorNoDir
from dashboard.models import CourseImportLog from dashboard.models import CourseImportLog
...@@ -46,7 +46,7 @@ class SysadminBaseTestCase(SharedModuleStoreTestCase): ...@@ -46,7 +46,7 @@ class SysadminBaseTestCase(SharedModuleStoreTestCase):
TEST_REPO = 'https://github.com/mitocw/edx4edx_lite.git' TEST_REPO = 'https://github.com/mitocw/edx4edx_lite.git'
TEST_BRANCH = 'testing_do_not_delete' TEST_BRANCH = 'testing_do_not_delete'
TEST_BRANCH_COURSE = SlashSeparatedCourseKey('MITx', 'edx4edx_branch', 'edx4edx') TEST_BRANCH_COURSE = CourseKey.from_string('MITx/edx4edx_branch/edx4edx')
def setUp(self): def setUp(self):
"""Setup test case by adding primary user.""" """Setup test case by adding primary user."""
...@@ -78,7 +78,7 @@ class SysadminBaseTestCase(SharedModuleStoreTestCase): ...@@ -78,7 +78,7 @@ class SysadminBaseTestCase(SharedModuleStoreTestCase):
course = def_ms.courses.get(course_path, None) course = def_ms.courses.get(course_path, None)
except AttributeError: except AttributeError:
# Using mongo store # Using mongo store
course = def_ms.get_course(SlashSeparatedCourseKey('MITx', 'edx4edx', 'edx4edx')) course = def_ms.get_course(CourseKey.from_string('MITx/edx4edx/edx4edx'))
# Delete git loaded course # Delete git loaded course
response = self.client.post( response = self.client.post(
...@@ -168,11 +168,11 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase): ...@@ -168,11 +168,11 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase):
self.assertNotEqual('xml', def_ms.get_modulestore_type(None)) self.assertNotEqual('xml', def_ms.get_modulestore_type(None))
self._add_edx4edx() self._add_edx4edx()
course = def_ms.get_course(SlashSeparatedCourseKey('MITx', 'edx4edx', 'edx4edx')) course = def_ms.get_course(CourseKey.from_string('MITx/edx4edx/edx4edx'))
self.assertIsNotNone(course) self.assertIsNotNone(course)
self._rm_edx4edx() self._rm_edx4edx()
course = def_ms.get_course(SlashSeparatedCourseKey('MITx', 'edx4edx', 'edx4edx')) course = def_ms.get_course(CourseKey.from_string('MITx/edx4edx/edx4edx'))
self.assertIsNone(course) self.assertIsNone(course)
def test_course_info(self): def test_course_info(self):
...@@ -301,7 +301,7 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase): ...@@ -301,7 +301,7 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase):
for _ in xrange(15): for _ in xrange(15):
CourseImportLog( CourseImportLog(
course_id=SlashSeparatedCourseKey("test", "test", "test"), course_id=CourseKey.from_string("test/test/test"),
location="location", location="location",
import_log="import_log", import_log="import_log",
git_log="git_log", git_log="git_log",
...@@ -347,7 +347,7 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase): ...@@ -347,7 +347,7 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase):
# Add user as staff in course team # Add user as staff in course team
def_ms = modulestore() def_ms = modulestore()
course = def_ms.get_course(SlashSeparatedCourseKey('MITx', 'edx4edx', 'edx4edx')) course = def_ms.get_course(CourseKey.from_string('MITx/edx4edx/edx4edx'))
CourseStaffRole(course.id).add_users(self.user) CourseStaffRole(course.id).add_users(self.user)
self.assertTrue(CourseStaffRole(course.id).has_user(self.user)) self.assertTrue(CourseStaffRole(course.id).has_user(self.user))
......
...@@ -25,7 +25,7 @@ from django.utils.translation import ugettext as _ ...@@ -25,7 +25,7 @@ from django.utils.translation import ugettext as _
from mock import Mock, patch from mock import Mock, patch
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from nose.tools import raises from nose.tools import raises
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import UsageKey from opaque_keys.edx.locator import UsageKey
import lms.djangoapps.instructor.views.api import lms.djangoapps.instructor.views.api
...@@ -4075,10 +4075,10 @@ class TestInstructorAPIHelpers(TestCase): ...@@ -4075,10 +4075,10 @@ class TestInstructorAPIHelpers(TestCase):
self.assertEqual(_split_input_list(scary_unistuff), [scary_unistuff]) self.assertEqual(_split_input_list(scary_unistuff), [scary_unistuff])
def test_msk_from_problem_urlname(self): def test_msk_from_problem_urlname(self):
course_id = SlashSeparatedCourseKey('MITx', '6.002x', '2013_Spring') course_id = CourseKey.from_string('MITx/6.002x/2013_Spring')
name = 'L2Node1' name = 'L2Node1'
output = 'i4x://MITx/6.002x/problem/L2Node1' output = 'i4x://MITx/6.002x/problem/L2Node1'
self.assertEqual(msk_from_problem_urlname(course_id, name).to_deprecated_string(), output) self.assertEqual(unicode(msk_from_problem_urlname(course_id, name)), output)
@raises(ValueError) @raises(ValueError)
def test_msk_from_problem_urlname_error(self): def test_msk_from_problem_urlname_error(self):
......
...@@ -7,7 +7,7 @@ that the view is conditionally available when Course Auth is turned on. ...@@ -7,7 +7,7 @@ that the view is conditionally available when Course Auth is turned on.
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from bulk_email.models import BulkEmailFlag, CourseAuthorization from bulk_email.models import BulkEmailFlag, CourseAuthorization
from student.tests.factories import AdminFactory from student.tests.factories import AdminFactory
...@@ -119,10 +119,10 @@ class TestNewInstructorDashboardEmailViewXMLBacked(SharedModuleStoreTestCase): ...@@ -119,10 +119,10 @@ class TestNewInstructorDashboardEmailViewXMLBacked(SharedModuleStoreTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(TestNewInstructorDashboardEmailViewXMLBacked, cls).setUpClass() super(TestNewInstructorDashboardEmailViewXMLBacked, cls).setUpClass()
cls.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') cls.course_key = CourseKey.from_string('edX/toy/2012_Fall')
# URL for instructor dash # URL for instructor dash
cls.url = reverse('instructor_dashboard', kwargs={'course_id': cls.course_key.to_deprecated_string()}) cls.url = reverse('instructor_dashboard', kwargs={'course_id': unicode(cls.course_key)})
# URL for email view # URL for email view
cls.email_link = '<button type="button" class="btn-link send_email" data-section="send_email">Email</button>' cls.email_link = '<button type="button" class="btn-link send_email" data-section="send_email">Email</button>'
......
...@@ -13,7 +13,7 @@ from django.utils.translation import override as override_language ...@@ -13,7 +13,7 @@ from django.utils.translation import override as override_language
from django.utils.translation import get_language from django.utils.translation import get_language
from mock import patch from mock import patch
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator
from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory from capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory
from courseware.models import StudentModule from courseware.models import StudentModule
...@@ -44,7 +44,7 @@ class TestSettableEnrollmentState(CacheIsolationTestCase): ...@@ -44,7 +44,7 @@ class TestSettableEnrollmentState(CacheIsolationTestCase):
""" Test the basis class for enrollment tests. """ """ Test the basis class for enrollment tests. """
def setUp(self): def setUp(self):
super(TestSettableEnrollmentState, self).setUp() super(TestSettableEnrollmentState, self).setUp()
self.course_key = SlashSeparatedCourseKey('Robot', 'fAKE', 'C-%-se-%-ID') self.course_key = CourseLocator('Robot', 'fAKE', 'C--se--ID')
def test_mes_create(self): def test_mes_create(self):
""" """
...@@ -75,7 +75,7 @@ class TestEnrollmentChangeBase(CacheIsolationTestCase): ...@@ -75,7 +75,7 @@ class TestEnrollmentChangeBase(CacheIsolationTestCase):
def setUp(self): def setUp(self):
super(TestEnrollmentChangeBase, self).setUp() super(TestEnrollmentChangeBase, self).setUp()
self.course_key = SlashSeparatedCourseKey('Robot', 'fAKE', 'C-%-se-%-ID') self.course_key = CourseLocator('Robot', 'fAKE', 'C--se--ID')
def _run_state_change_test(self, before_ideal, after_ideal, action): def _run_state_change_test(self, before_ideal, after_ideal, action):
""" """
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
from django.test import TestCase from django.test import TestCase
from nose.tools import raises from nose.tools import raises
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator
from instructor_analytics.distributions import AVAILABLE_PROFILE_FEATURES, profile_distribution from instructor_analytics.distributions import AVAILABLE_PROFILE_FEATURES, profile_distribution
from student.models import CourseEnrollment from student.models import CourseEnrollment
...@@ -14,7 +14,7 @@ class TestAnalyticsDistributions(TestCase): ...@@ -14,7 +14,7 @@ class TestAnalyticsDistributions(TestCase):
def setUp(self): def setUp(self):
super(TestAnalyticsDistributions, self).setUp() super(TestAnalyticsDistributions, self).setUp()
self.course_id = SlashSeparatedCourseKey('robot', 'course', 'id') self.course_id = CourseLocator('robot', 'course', 'id')
self.users = [UserFactory( self.users = [UserFactory(
profile__gender=['m', 'f', 'o'][i % 3], profile__gender=['m', 'f', 'o'][i % 3],
...@@ -77,7 +77,7 @@ class TestAnalyticsDistributionsNoData(TestCase): ...@@ -77,7 +77,7 @@ class TestAnalyticsDistributionsNoData(TestCase):
def setUp(self): def setUp(self):
super(TestAnalyticsDistributionsNoData, self).setUp() super(TestAnalyticsDistributionsNoData, self).setUp()
self.course_id = SlashSeparatedCourseKey('robot', 'course', 'id') self.course_id = CourseLocator('robot', 'course', 'id')
self.users = [UserFactory( self.users = [UserFactory(
profile__year_of_birth=i + 1930, profile__year_of_birth=i + 1930,
......
...@@ -3,7 +3,7 @@ import json ...@@ -3,7 +3,7 @@ import json
import factory import factory
from celery.states import PENDING from celery.states import PENDING
from factory.django import DjangoModelFactory from factory.django import DjangoModelFactory
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locator import CourseLocator
from lms.djangoapps.instructor_task.models import InstructorTask from lms.djangoapps.instructor_task.models import InstructorTask
from student.tests.factories import UserFactory as StudentUserFactory from student.tests.factories import UserFactory as StudentUserFactory
...@@ -14,7 +14,7 @@ class InstructorTaskFactory(DjangoModelFactory): ...@@ -14,7 +14,7 @@ class InstructorTaskFactory(DjangoModelFactory):
model = InstructorTask model = InstructorTask
task_type = 'rescore_problem' task_type = 'rescore_problem'
course_id = SlashSeparatedCourseKey("MITx", "999", "Robot_Super_Course") course_id = CourseLocator("MITx", "999", "Robot_Super_Course")
task_input = json.dumps({}) task_input = json.dumps({})
task_key = None task_key = None
task_id = None task_id = None
......
...@@ -14,7 +14,8 @@ from celery.states import FAILURE, SUCCESS ...@@ -14,7 +14,8 @@ from celery.states import FAILURE, SUCCESS
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from mock import Mock, patch from mock import Mock, patch
from opaque_keys.edx.locations import Location, SlashSeparatedCourseKey from opaque_keys.edx.locations import Location
from opaque_keys.edx.keys import CourseKey
from capa.tests.response_xml_factory import OptionResponseXMLFactory from capa.tests.response_xml_factory import OptionResponseXMLFactory
from courseware.model_data import StudentModule from courseware.model_data import StudentModule
...@@ -34,7 +35,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory ...@@ -34,7 +35,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
TEST_COURSE_ORG = 'edx' TEST_COURSE_ORG = 'edx'
TEST_COURSE_NAME = 'test_course' TEST_COURSE_NAME = 'test_course'
TEST_COURSE_NUMBER = '1.23x' TEST_COURSE_NUMBER = '1.23x'
TEST_COURSE_KEY = SlashSeparatedCourseKey(TEST_COURSE_ORG, TEST_COURSE_NUMBER, TEST_COURSE_NAME) TEST_COURSE_KEY = CourseKey.from_string('/'.join([TEST_COURSE_ORG, TEST_COURSE_NUMBER, TEST_COURSE_NAME]))
TEST_CHAPTER_NAME = "Section" TEST_CHAPTER_NAME = "Section"
TEST_SECTION_NAME = "Subsection" TEST_SECTION_NAME = "Subsection"
......
...@@ -9,7 +9,7 @@ from django.conf import settings ...@@ -9,7 +9,7 @@ from django.conf import settings
from django.test import TestCase from django.test import TestCase
from mock import Mock, patch from mock import Mock, patch
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locations import BlockUsageLocator, CourseLocator, SlashSeparatedCourseKey from opaque_keys.edx.locations import BlockUsageLocator, CourseLocator
from xblock.exceptions import NoSuchServiceError from xblock.exceptions import NoSuchServiceError
from xblock.fields import ScopeIds from xblock.fields import ScopeIds
...@@ -56,7 +56,7 @@ class TestHandlerUrl(TestCase): ...@@ -56,7 +56,7 @@ class TestHandlerUrl(TestCase):
def setUp(self): def setUp(self):
super(TestHandlerUrl, self).setUp() super(TestHandlerUrl, self).setUp()
self.block = BlockMock(name='block', scope_ids=ScopeIds(None, None, None, 'dummy')) self.block = BlockMock(name='block', scope_ids=ScopeIds(None, None, None, 'dummy'))
self.course_key = SlashSeparatedCourseKey("org", "course", "run") self.course_key = CourseLocator("org", "course", "run")
self.runtime = LmsModuleSystem( self.runtime = LmsModuleSystem(
static_url='/static', static_url='/static',
track_function=Mock(), track_function=Mock(),
...@@ -120,7 +120,7 @@ class TestUserServiceAPI(TestCase): ...@@ -120,7 +120,7 @@ class TestUserServiceAPI(TestCase):
def setUp(self): def setUp(self):
super(TestUserServiceAPI, self).setUp() super(TestUserServiceAPI, self).setUp()
self.course_id = SlashSeparatedCourseKey("org", "course", "run") self.course_id = CourseLocator("org", "course", "run")
self.user = UserFactory.create() self.user = UserFactory.create()
def mock_get_real_user(_anon_id): def mock_get_real_user(_anon_id):
......
...@@ -24,7 +24,7 @@ from django.test.client import Client, RequestFactory ...@@ -24,7 +24,7 @@ from django.test.client import Client, RequestFactory
from django.test.utils import override_settings from django.test.utils import override_settings
from mock import Mock, patch from mock import Mock, patch
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import CourseLocator from opaque_keys.edx.locator import CourseLocator
from waffle.testutils import override_switch from waffle.testutils import override_switch
...@@ -1310,7 +1310,7 @@ class TestCreateOrderView(ModuleStoreTestCase): ...@@ -1310,7 +1310,7 @@ class TestCreateOrderView(ModuleStoreTestCase):
self.course_id = 'Robot/999/Test_Course' self.course_id = 'Robot/999/Test_Course'
self.course = CourseFactory.create(org='Robot', number='999', display_name='Test Course') self.course = CourseFactory.create(org='Robot', number='999', display_name='Test Course')
verified_mode = CourseMode( verified_mode = CourseMode(
course_id=SlashSeparatedCourseKey("Robot", "999", 'Test_Course'), course_id=CourseKey.from_string("Robot/999/Test_Course"),
mode_slug="verified", mode_slug="verified",
mode_display_name="Verified Certificate", mode_display_name="Verified Certificate",
min_price=50 min_price=50
......
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