Merge pull request #15750 from edx/christina/slash-the-slash
Remove SlashSeparatedCourseKey from tests
This commit is contained in:
@@ -4,7 +4,7 @@ or with filename which starts with "._")
|
||||
"""
|
||||
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.django import contentstore
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -44,7 +44,7 @@ class ExportAllCourses(ModuleStoreTestCase):
|
||||
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)
|
||||
|
||||
# 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
|
||||
|
||||
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.contrib.auth.models import User
|
||||
from contentstore.tests.utils import CourseTestCase
|
||||
@@ -54,14 +54,14 @@ class DeleteCourseTest(CourseTestCase):
|
||||
"""
|
||||
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
|
||||
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:
|
||||
patched_yes_no.return_value = True
|
||||
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):
|
||||
"""
|
||||
|
||||
@@ -18,7 +18,7 @@ from django.test.utils import override_settings
|
||||
from contentstore.tests.utils import CourseTestCase
|
||||
import contentstore.git_export_utils as git_export_utils
|
||||
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['ENABLE_EXPORT_GIT'] = True
|
||||
@@ -88,7 +88,7 @@ class TestGitExport(CourseTestCase):
|
||||
"""
|
||||
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)):
|
||||
git_export_utils.export_to_git(course_key, 'Sillyness')
|
||||
|
||||
@@ -105,7 +105,7 @@ class TestGitExport(CourseTestCase):
|
||||
"""
|
||||
test_repo_path = '{}/test_repo'.format(git_export_utils.GIT_REPO_EXPORT_DIR)
|
||||
self.assertFalse(os.path.isdir(test_repo_path))
|
||||
course_key = SlashSeparatedCourseKey('foo', 'blah', '100-')
|
||||
course_key = CourseLocator('foo', 'blah', '100-')
|
||||
# Test bad clones
|
||||
with self.assertRaisesRegexp(GitExportError,
|
||||
unicode(GitExportError.CANNOT_PULL)):
|
||||
|
||||
@@ -28,15 +28,6 @@ class CloneCourseTest(CourseTestCase):
|
||||
"""Tests cloning of a course as follows: XML -> Mongo (+ data) -> Mongo -> Split -> Split"""
|
||||
# 1. import and populate test toy 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
|
||||
|
||||
# 3. clone course (mongo -> split)
|
||||
|
||||
@@ -3,7 +3,7 @@ import collections
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from django.test import TestCase
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from pytz import UTC
|
||||
|
||||
from contentstore import utils
|
||||
@@ -21,26 +21,26 @@ class LMSLinksTestCase(TestCase):
|
||||
|
||||
def lms_link_test(self):
|
||||
""" 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')
|
||||
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
|
||||
link = utils.get_lms_link_for_item(location, True)
|
||||
self.assertEquals(
|
||||
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
|
||||
location = course_key.make_usage_key('course', 'test')
|
||||
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):
|
||||
""" 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
|
||||
mode = 'professional'
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.test.client import Client
|
||||
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 student.models import Registration
|
||||
@@ -129,7 +130,7 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase):
|
||||
"""
|
||||
content_store = contentstore()
|
||||
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
|
||||
# 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
|
||||
"""
|
||||
from django.contrib.auth.models import User
|
||||
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 student.auth import add_users
|
||||
@@ -22,7 +22,7 @@ class RolesTest(TestCase):
|
||||
self.global_admin = AdminFactory()
|
||||
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.course_key = SlashSeparatedCourseKey('mitX', '101', 'test')
|
||||
self.course_key = CourseLocator('mitX', '101', 'test')
|
||||
|
||||
def test_get_user_role_instructor(self):
|
||||
"""
|
||||
|
||||
@@ -10,7 +10,8 @@ from ddt import data, ddt
|
||||
from django.conf import settings
|
||||
from django.test.utils import override_settings
|
||||
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 pytz import UTC
|
||||
|
||||
@@ -80,7 +81,7 @@ class BasicAssetsTestCase(AssetsTestCase):
|
||||
|
||||
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')
|
||||
path = StaticContent.get_static_path_from_location(location)
|
||||
self.assertEquals(path, '/static/my_file_name.jpg')
|
||||
@@ -348,7 +349,7 @@ class AssetToJsonTestCase(AssetsTestCase):
|
||||
def test_basic(self):
|
||||
upload_date = datetime(2013, 6, 1, 10, 30, tzinfo=UTC)
|
||||
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')
|
||||
thumbnail_location = course_key.make_asset_key('thumbnail', 'my_file_name_thumb.jpg')
|
||||
|
||||
@@ -357,10 +358,10 @@ class AssetToJsonTestCase(AssetsTestCase):
|
||||
|
||||
self.assertEquals(output["display_name"], "my_file")
|
||||
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["external_url"], "lms_base_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/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["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['locked'], True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user