Merge pull request #15770 from edx/christina/slash-the-slash
Remove usages of deprecated SlashSeparatedCourseKey.
This commit is contained in:
@@ -7,10 +7,10 @@ from factory.django import DjangoModelFactory
|
||||
from functools import partial
|
||||
|
||||
from student.tests.factories import UserFactory
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from ..models import Bookmark, XBlockCache
|
||||
|
||||
COURSE_KEY = SlashSeparatedCourseKey(u'edX', u'test_course', u'test')
|
||||
COURSE_KEY = CourseLocator(u'edX', u'test_course', u'test')
|
||||
LOCATION = partial(COURSE_KEY.make_usage_key, u'problem')
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ from django_comment_common.models import CourseDiscussionSettings
|
||||
from django_comment_common.utils import set_course_discussion_settings
|
||||
from factory import Sequence, post_generation
|
||||
from factory.django import DjangoModelFactory
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
@@ -24,7 +24,7 @@ class CohortFactory(DjangoModelFactory):
|
||||
model = CourseUserGroup
|
||||
|
||||
name = Sequence("cohort{}".format)
|
||||
course_id = SlashSeparatedCourseKey("dummy", "dummy", "dummy")
|
||||
course_id = CourseLocator("dummy", "dummy", "dummy")
|
||||
group_type = CourseUserGroup.COHORT
|
||||
|
||||
@post_generation
|
||||
@@ -57,7 +57,7 @@ class CourseCohortSettingsFactory(DjangoModelFactory):
|
||||
model = CourseCohortsSettings
|
||||
|
||||
is_cohorted = False
|
||||
course_id = SlashSeparatedCourseKey("dummy", "dummy", "dummy")
|
||||
course_id = CourseLocator("dummy", "dummy", "dummy")
|
||||
cohorted_discussions = json.dumps([])
|
||||
# pylint: disable=invalid-name
|
||||
always_cohort_inline_discussions = False
|
||||
|
||||
@@ -11,7 +11,7 @@ from django.contrib.auth.models import User
|
||||
from django.db import IntegrityError
|
||||
from django.http import Http404
|
||||
from django.test import TestCase
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from student.models import CourseEnrollment
|
||||
from student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -32,7 +32,7 @@ class TestCohortSignals(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestCohortSignals, self).setUp()
|
||||
self.course_key = SlashSeparatedCourseKey("dummy", "dummy", "dummy")
|
||||
self.course_key = CourseLocator("dummy", "dummy", "dummy")
|
||||
|
||||
def test_cohort_added(self, mock_tracker):
|
||||
# Add cohort
|
||||
@@ -164,7 +164,7 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
self.assertTrue(cohorts.is_course_cohorted(course.id))
|
||||
|
||||
# Make sure we get a Http404 if there's no course
|
||||
fake_key = SlashSeparatedCourseKey('a', 'b', 'c')
|
||||
fake_key = CourseLocator('a', 'b', 'c')
|
||||
self.assertRaises(Http404, lambda: cohorts.is_course_cohorted(fake_key))
|
||||
|
||||
def test_get_cohort_id(self):
|
||||
@@ -184,7 +184,7 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
|
||||
self.assertRaises(
|
||||
Http404,
|
||||
lambda: cohorts.get_cohort_id(user, SlashSeparatedCourseKey("course", "does_not", "exist"))
|
||||
lambda: cohorts.get_cohort_id(user, CourseLocator("course", "does_not", "exist"))
|
||||
)
|
||||
|
||||
def test_assignment_type(self):
|
||||
@@ -545,7 +545,7 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
|
||||
self.assertRaises(
|
||||
CourseUserGroup.DoesNotExist,
|
||||
lambda: cohorts.get_cohort_by_name(SlashSeparatedCourseKey("course", "does_not", "exist"), cohort)
|
||||
lambda: cohorts.get_cohort_by_name(CourseLocator("course", "does_not", "exist"), cohort)
|
||||
)
|
||||
|
||||
def test_get_cohort_by_id(self):
|
||||
@@ -584,7 +584,7 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
ValueError,
|
||||
lambda: cohorts.add_cohort(course.id, "My Cohort", assignment_type)
|
||||
)
|
||||
does_not_exist_course_key = SlashSeparatedCourseKey("course", "does_not", "exist")
|
||||
does_not_exist_course_key = CourseLocator("course", "does_not", "exist")
|
||||
self.assertRaises(
|
||||
ValueError,
|
||||
lambda: cohorts.add_cohort(does_not_exist_course_key, "My Cohort", assignment_type)
|
||||
|
||||
@@ -13,7 +13,7 @@ from django.http import Http404
|
||||
from django.test.client import RequestFactory
|
||||
from django_comment_common.models import CourseDiscussionSettings
|
||||
from django_comment_common.utils import get_course_discussion_settings
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from student.models import CourseEnrollment
|
||||
from student.tests.factories import UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
@@ -1101,7 +1101,7 @@ class AddUsersToCohortTestCase(CohortViewsTestCase):
|
||||
"""
|
||||
users = [UserFactory(username="user{0}".format(i)) for i in range(3)]
|
||||
usernames = [user.username for user in users]
|
||||
wrong_course_key = SlashSeparatedCourseKey("some", "arbitrary", "course")
|
||||
wrong_course_key = CourseLocator("some", "arbitrary", "course")
|
||||
wrong_course_cohort = CohortFactory(name="wrong_cohort", course_id=wrong_course_key, users=[])
|
||||
self.request_add_users_to_cohort(
|
||||
",".join(usernames),
|
||||
|
||||
@@ -6,7 +6,7 @@ from django.test import TestCase
|
||||
from student.tests.factories import UserFactory
|
||||
from nose.plugins.attrib import attr
|
||||
from openedx.core.djangoapps.user_api.course_tag import api as course_tag_api
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
|
||||
|
||||
@attr(shard=2)
|
||||
@@ -17,7 +17,7 @@ class TestCourseTagAPI(TestCase):
|
||||
def setUp(self):
|
||||
super(TestCourseTagAPI, self).setUp()
|
||||
self.user = UserFactory.create()
|
||||
self.course_id = SlashSeparatedCourseKey('test_org', 'test_course_number', 'test_run')
|
||||
self.course_id = CourseLocator('test_org', 'test_course_number', 'test_run')
|
||||
self.test_key = 'test_key'
|
||||
|
||||
def test_get_set_course_tag(self):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
from factory.django import DjangoModelFactory
|
||||
from factory import SubFactory
|
||||
from student.tests.factories import UserFactory
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
|
||||
from ..models import UserPreference, UserCourseTag, UserOrgTag
|
||||
|
||||
@@ -23,7 +23,7 @@ class UserCourseTagFactory(DjangoModelFactory):
|
||||
model = UserCourseTag
|
||||
|
||||
user = SubFactory(UserFactory)
|
||||
course_id = SlashSeparatedCourseKey('org', 'course', 'run')
|
||||
course_id = CourseLocator('org', 'course', 'run')
|
||||
key = None
|
||||
value = None
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from django.core.urlresolvers import reverse
|
||||
from django.test.client import RequestFactory
|
||||
from django.test.testcases import TransactionTestCase
|
||||
from django.test.utils import override_settings
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from pytz import common_timezones_set, UTC
|
||||
from social_django.models import UserSocialAuth, Partial
|
||||
|
||||
@@ -99,8 +99,8 @@ class EmptyUserTestCase(UserAPITestCase):
|
||||
|
||||
class EmptyRoleTestCase(UserAPITestCase):
|
||||
"""Test that the endpoint supports empty result sets"""
|
||||
course_id = SlashSeparatedCourseKey.from_deprecated_string("org/course/run")
|
||||
LIST_URI = ROLE_LIST_URI + "?course_id=" + course_id.to_deprecated_string()
|
||||
course_id = CourseKey.from_string("org/course/run")
|
||||
LIST_URI = ROLE_LIST_URI + "?course_id=" + unicode(course_id)
|
||||
|
||||
def test_get_list_empty(self):
|
||||
"""Test that the endpoint properly returns empty result sets"""
|
||||
@@ -135,8 +135,8 @@ class RoleTestCase(UserApiTestCase):
|
||||
"""
|
||||
Test cases covering Role-related views and their behaviors
|
||||
"""
|
||||
course_id = SlashSeparatedCourseKey.from_deprecated_string("org/course/run")
|
||||
LIST_URI = ROLE_LIST_URI + "?course_id=" + course_id.to_deprecated_string()
|
||||
course_id = CourseKey.from_string("org/course/run")
|
||||
LIST_URI = ROLE_LIST_URI + "?course_id=" + unicode(course_id)
|
||||
|
||||
def setUp(self):
|
||||
super(RoleTestCase, self).setUp()
|
||||
|
||||
Reference in New Issue
Block a user