Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
6f71706b
Commit
6f71706b
authored
Aug 04, 2017
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove SlashSeparatedCourseKey from tests.
parent
198dbc1e
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
125 additions
and
131 deletions
+125
-131
cms/djangoapps/contentstore/management/commands/tests/test_cleanup_assets.py
+2
-2
cms/djangoapps/contentstore/management/commands/tests/test_delete_course.py
+4
-4
cms/djangoapps/contentstore/management/commands/tests/test_git_export.py
+3
-3
cms/djangoapps/contentstore/tests/test_clone_course.py
+0
-9
cms/djangoapps/contentstore/tests/test_utils.py
+6
-6
cms/djangoapps/contentstore/tests/utils.py
+3
-2
cms/djangoapps/contentstore/views/tests/test_access.py
+2
-2
cms/djangoapps/contentstore/views/tests/test_assets.py
+7
-6
common/djangoapps/course_modes/tests/factories.py
+2
-2
common/djangoapps/course_modes/tests/test_models.py
+2
-3
common/djangoapps/static_replace/test/test_static_replace.py
+2
-2
common/djangoapps/util/tests/test_sandboxing.py
+7
-7
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+2
-2
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+21
-21
lms/djangoapps/bulk_email/tests/test_err_handling.py
+3
-3
lms/djangoapps/bulk_email/tests/test_forms.py
+2
-2
lms/djangoapps/bulk_email/tests/test_tasks.py
+2
-2
lms/djangoapps/courseware/tests/factories.py
+4
-3
lms/djangoapps/courseware/tests/test_access.py
+9
-9
lms/djangoapps/courseware/tests/test_draft_modulestore.py
+2
-2
lms/djangoapps/courseware/tests/test_module_render.py
+2
-3
lms/djangoapps/courseware/tests/test_views.py
+4
-3
lms/djangoapps/courseware/tests/tests.py
+2
-2
lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py
+3
-3
lms/djangoapps/dashboard/tests/test_sysadmin.py
+7
-7
lms/djangoapps/instructor/tests/test_api.py
+3
-3
lms/djangoapps/instructor/tests/test_email.py
+3
-3
lms/djangoapps/instructor/tests/test_enrollment.py
+3
-3
lms/djangoapps/instructor_analytics/tests/test_distributions.py
+3
-3
lms/djangoapps/instructor_task/tests/factories.py
+2
-2
lms/djangoapps/instructor_task/tests/test_base.py
+3
-2
lms/djangoapps/lms_xblock/test/test_runtime.py
+3
-3
lms/djangoapps/verify_student/tests/test_views.py
+2
-2
No files found.
cms/djangoapps/contentstore/management/commands/tests/test_cleanup_assets.py
View file @
6f71706b
...
...
@@ -4,7 +4,7 @@ or with filename which starts with "._")
"""
from
django.core.management
import
call_command
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
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
...
...
cms/djangoapps/contentstore/management/commands/tests/test_delete_course.py
View file @
6f71706b
...
...
@@ -4,7 +4,7 @@ Unittests for deleting a course in an chosen modulestore
import
mock
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
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
):
"""
...
...
cms/djangoapps/contentstore/management/commands/tests/test_git_export.py
View file @
6f71706b
...
...
@@ -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.locat
ions
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locat
or
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
)):
...
...
cms/djangoapps/contentstore/tests/test_clone_course.py
View file @
6f71706b
...
...
@@ -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)
...
...
cms/djangoapps/contentstore/tests/test_utils.py
View file @
6f71706b
...
...
@@ -3,7 +3,7 @@ import collections
from
datetime
import
datetime
,
timedelta
from
django.test
import
TestCase
from
opaque_keys.edx.locat
ions
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locat
or
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'
...
...
cms/djangoapps/contentstore/tests/utils.py
View file @
6f71706b
...
...
@@ -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.
...
...
cms/djangoapps/contentstore/views/tests/test_access.py
View file @
6f71706b
...
...
@@ -3,7 +3,7 @@ Tests access.py
"""
from
django.contrib.auth.models
import
User
from
django.test
import
TestCase
from
opaque_keys.edx.locat
ions
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locat
or
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
):
"""
...
...
cms/djangoapps/contentstore/views/tests/test_assets.py
View file @
6f71706b
...
...
@@ -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
)
...
...
common/djangoapps/course_modes/tests/factories.py
View file @
6f71706b
...
...
@@ -5,7 +5,7 @@ import random
from
factory
import
lazy_attribute
from
factory.django
import
DjangoModelFactory
from
opaque_keys.edx.locat
ions
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locat
or
import
CourseLocator
from
course_modes.models
import
CourseMode
...
...
@@ -16,7 +16,7 @@ class CourseModeFactory(DjangoModelFactory):
class
Meta
(
object
):
model
=
CourseMode
course_id
=
SlashSeparatedCourseKey
(
'MITx'
,
'999'
,
'Robot_Super_Course'
)
course_id
=
CourseLocator
(
'MITx'
,
'999'
,
'Robot_Super_Course'
)
mode_slug
=
'audit'
currency
=
'usd'
expiration_datetime
=
None
...
...
common/djangoapps/course_modes/tests/test_models.py
View file @
6f71706b
...
...
@@ -13,7 +13,6 @@ import pytz
from
django.core.exceptions
import
ValidationError
from
django.test
import
TestCase
,
override_settings
from
mock
import
patch
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locator
import
CourseLocator
from
course_modes.helpers
import
enrollment_mode_display
...
...
@@ -33,7 +32,7 @@ class CourseModeModelTest(TestCase):
def
setUp
(
self
):
super
(
CourseModeModelTest
,
self
)
.
setUp
()
self
.
course_key
=
SlashSeparatedCourseKey
(
'Test'
,
'TestCourse'
,
'TestCourseRun'
)
self
.
course_key
=
CourseLocator
(
'Test'
,
'TestCourse'
,
'TestCourseRun'
)
CourseMode
.
objects
.
all
()
.
delete
()
def
tearDown
(
self
):
...
...
@@ -156,7 +155,7 @@ class CourseModeModelTest(TestCase):
modes
=
CourseMode
.
modes_for_course
(
self
.
course_key
)
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
)
def
test_verified_mode_for_course
(
self
):
...
...
common/djangoapps/static_replace/test/test_static_replace.py
View file @
6f71706b
...
...
@@ -10,7 +10,7 @@ from django.test import override_settings
from
django.utils.http
import
urlencode
,
urlquote
from
mock
import
Mock
,
patch
from
nose.tools
import
assert_equals
,
assert_false
,
assert_true
# pylint: disable=no-name-in-module
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.
keys
import
CourseKey
from
PIL
import
Image
from
static_replace
import
(
...
...
@@ -32,7 +32,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, check_mongo_calls
from
xmodule.modulestore.xml
import
XMLModuleStore
DATA_DIRECTORY
=
'data_dir'
COURSE_KEY
=
SlashSeparatedCourseKey
(
'org'
,
'course'
,
'
run'
)
COURSE_KEY
=
CourseKey
.
from_string
(
'org/course/
run'
)
STATIC_SOURCE
=
'"/static/file.png"'
...
...
common/djangoapps/util/tests/test_sandboxing.py
View file @
6f71706b
...
...
@@ -4,8 +4,8 @@ Tests for sandboxing.py in util app
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.locator
import
LibraryLocator
from
opaque_keys.edx.
keys
import
CourseKey
from
opaque_keys.edx.locator
import
CourseLocator
,
LibraryLocator
from
util.sandboxing
import
can_execute_unsafe_code
...
...
@@ -19,7 +19,7 @@ class SandboxingTest(TestCase):
"""
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'
)))
@override_settings
(
COURSES_WITH_UNSAFE_CODE
=
[
'edX/full/.*'
])
...
...
@@ -27,14 +27,14 @@ class SandboxingTest(TestCase):
"""
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
(
SlashSeparatedCourseKey
(
'edX'
,
'full'
,
'
2013_Spring'
)))
self
.
assertTrue
(
can_execute_unsafe_code
(
CourseKey
.
from_string
(
'edX/full/
2012_Fall'
)))
self
.
assertTrue
(
can_execute_unsafe_code
(
CourseKey
.
from_string
(
'edX/full/
2013_Spring'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
LibraryLocator
(
'edX'
,
'test_bank'
)))
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
"""
self
.
assertFalse
(
can_execute_unsafe_code
(
SlashSeparatedCourseKey
(
'edX'
,
'full'
,
'2012_Fall'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
SlashSeparatedCourseKey
(
'edX'
,
'full'
,
'2013_Spring'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
CourseLocator
(
'edX'
,
'full'
,
'2012_Fall'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
CourseLocator
(
'edX'
,
'full'
,
'2013_Spring'
)))
self
.
assertFalse
(
can_execute_unsafe_code
(
LibraryLocator
(
'edX'
,
'test_bank'
)))
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
6f71706b
...
...
@@ -40,7 +40,7 @@ from xblock.test.tools import TestRuntime
if
not
settings
.
configured
:
settings
.
configure
()
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.
keys
import
CourseKey
from
opaque_keys.edx.locator
import
BlockUsageLocator
,
CourseLocator
,
LibraryLocator
from
xmodule.exceptions
import
InvalidVersionError
from
xmodule.modulestore
import
ModuleStoreEnum
...
...
@@ -323,7 +323,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
)
# try an unknown mapping, it should be the 'default' store
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
)
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
View file @
6f71706b
...
...
@@ -29,7 +29,7 @@ from opaque_keys.edx.locations import Location
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.mongo
import
MongoKeyValueStore
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.keys
import
UsageKey
from
xmodule.modulestore.xml_exporter
import
export_course_to_xml
...
...
@@ -160,7 +160,7 @@ class TestMongoModuleStoreBase(unittest.TestCase):
static_content_store
=
content_store
,
do_import_static
=
False
,
verbose
=
True
,
target_id
=
SlashSeparatedCourseKey
(
'guestx'
,
'foo'
,
'
bar'
)
target_id
=
CourseKey
.
from_string
(
'guestx/foo/
bar'
)
)
return
content_store
,
draft_store
...
...
@@ -216,7 +216,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
for
course_key
in
[
SlashSeparatedCourseKey
(
*
fields
)
CourseKey
.
from_string
(
'/'
.
join
(
fields
)
)
for
fields
in
[
[
'edX'
,
'simple'
,
'2012_Fall'
],
[
'edX'
,
'simple_with_draft'
,
'2012_Fall'
],
...
...
@@ -230,8 +230,8 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course
=
self
.
draft_store
.
get_course
(
course_key
)
assert_not_none
(
course
)
assert_true
(
self
.
draft_store
.
has_course
(
course_key
))
mix_cased
=
SlashSeparatedCourseKey
(
course_key
.
org
.
upper
(),
course_key
.
course
.
upper
(),
course_key
.
run
.
lower
(
)
mix_cased
=
CourseKey
.
from_string
(
'/'
.
join
([
course_key
.
org
.
upper
(),
course_key
.
course
.
upper
(),
course_key
.
run
.
lower
()]
)
)
assert_false
(
self
.
draft_store
.
has_course
(
mix_cased
))
assert_true
(
self
.
draft_store
.
has_course
(
mix_cased
,
ignore_case
=
True
))
...
...
@@ -247,7 +247,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course_ids
=
[
course
.
id
for
course
in
courses
]
for
course_key
in
[
SlashSeparatedCourseKey
(
*
fields
)
CourseKey
.
from_string
(
'/'
.
join
(
fields
)
)
for
fields
in
[
[
'guestx'
,
'foo'
,
'bar'
]
]
...
...
@@ -259,7 +259,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course_ids
=
[
course
.
id
for
course
in
courses
]
for
course_key
in
[
SlashSeparatedCourseKey
(
*
fields
)
CourseKey
.
from_string
(
'/'
.
join
(
fields
)
)
for
fields
in
[
[
'edX'
,
'simple'
,
'2012_Fall'
],
[
'edX'
,
'simple_with_draft'
,
'2012_Fall'
],
...
...
@@ -276,7 +276,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
"""
for
course_key
in
[
SlashSeparatedCourseKey
(
*
fields
)
CourseKey
.
from_string
(
'/'
.
join
(
fields
)
)
for
fields
in
[
[
'edX'
,
'simple'
,
'no_such_course'
],
[
'edX'
,
'no_such_course'
,
'2012_Fall'
],
[
'NO_SUCH_COURSE'
,
'Test_iMport_courSe'
,
'2012_Fall'
],
...
...
@@ -285,8 +285,8 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course
=
self
.
draft_store
.
get_course
(
course_key
)
assert_is_none
(
course
)
assert_false
(
self
.
draft_store
.
has_course
(
course_key
))
mix_cased
=
SlashSeparatedCourseKey
(
course_key
.
org
.
lower
(),
course_key
.
course
.
upper
(),
course_key
.
run
.
upper
(
)
mix_cased
=
CourseKey
.
from_string
(
'/'
.
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
,
ignore_case
=
True
))
...
...
@@ -449,13 +449,13 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
for
course_number
in
self
.
courses
:
course_locations
=
self
.
draft_store
.
get_courses_for_wiki
(
course_number
)
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'
)
assert_equals
(
len
(
course_locations
),
0
)
# 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'
self
.
draft_store
.
update_item
(
toy_course
,
ModuleStoreEnum
.
UserID
.
test
)
...
...
@@ -467,23 +467,23 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course_locations
=
self
.
draft_store
.
get_courses_for_wiki
(
'simple'
)
assert_equals
(
len
(
course_locations
),
2
)
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.
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'
self
.
draft_store
.
update_item
(
simple_course
,
ModuleStoreEnum
.
UserID
.
test
)
# it should be retrievable with its new wiki_slug
course_locations
=
self
.
draft_store
.
get_courses_for_wiki
(
'edX.simple.2012_Fall'
)
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'
)
def
test_reference_converters
(
self
):
"""
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
():
course
=
self
.
draft_store
.
get_course
(
course_key
)
...
...
@@ -563,7 +563,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
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.
"""
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'
)
# This will raise if the course image is missing
...
...
@@ -581,7 +581,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
Make sure that if a non-default image path is specified that we
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'
)
root_dir
=
path
(
mkdtemp
())
...
...
@@ -595,7 +595,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
Make sure we elegantly passover our code when there isn't a static
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
())
self
.
addCleanup
(
shutil
.
rmtree
,
root_dir
)
export_course_to_xml
(
self
.
draft_store
,
self
.
content_store
,
course
.
id
,
root_dir
,
'test_export'
)
...
...
@@ -619,7 +619,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
course
=
'tree{}'
.
format
(
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
)
locations
=
{
...
...
@@ -755,7 +755,7 @@ class TestMongoKeyValueStore(unittest.TestCase):
def
setUp
(
self
):
super
(
TestMongoKeyValueStore
,
self
)
.
setUp
()
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
.
children
=
[
self
.
course_id
.
make_usage_key
(
'child'
,
'a'
),
self
.
course_id
.
make_usage_key
(
'child'
,
'b'
)]
self
.
metadata
=
{
'meta'
:
'meta_val'
}
...
...
lms/djangoapps/bulk_email/tests/test_err_handling.py
View file @
6f71706b
...
...
@@ -14,7 +14,7 @@ from django.core.urlresolvers import reverse
from
django.db
import
DatabaseError
from
mock
import
Mock
,
patch
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.locat
ions
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locat
or
import
CourseLocator
from
bulk_email.models
import
SEND_TO_MYSELF
,
BulkEmailFlag
,
CourseEmail
from
bulk_email.tasks
import
perform_delegate_email_batches
,
send_course_email
...
...
@@ -193,7 +193,7 @@ class TestEmailErrors(ModuleStoreTestCase):
"""
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
.
save
()
entry
=
InstructorTask
.
create
(
course_id
,
"task_type"
,
"task_key"
,
"task_input"
,
self
.
instructor
)
...
...
@@ -250,7 +250,7 @@ class TestEmailErrors(ModuleStoreTestCase):
Tests exception when the course_id in CourseEmail is not the same as one explicitly passed in.
"""
email
=
CourseEmail
.
create
(
SlashSeparatedCourseKey
(
"bogus"
,
"course"
,
"id"
),
CourseLocator
(
"bogus"
,
"course"
,
"id"
),
self
.
instructor
,
[
SEND_TO_MYSELF
],
"re: subject"
,
...
...
lms/djangoapps/bulk_email/tests/test_forms.py
View file @
6f71706b
...
...
@@ -4,7 +4,7 @@ Unit tests for bulk-email-related forms.
"""
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.locat
ions
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locat
or
import
CourseLocator
from
bulk_email.forms
import
CourseAuthorizationAdminForm
,
CourseEmailTemplateForm
from
bulk_email.models
import
BulkEmailFlag
,
CourseEmailTemplate
...
...
@@ -70,7 +70,7 @@ class CourseAuthorizationFormTest(ModuleStoreTestCase):
def
test_form_typo
(
self
):
# 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
=
CourseAuthorizationAdminForm
(
data
=
form_data
)
...
...
lms/djangoapps/bulk_email/tests/test_tasks.py
View file @
6f71706b
...
...
@@ -28,7 +28,7 @@ from django.conf import settings
from
django.core.management
import
call_command
from
mock
import
Mock
,
patch
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.locat
ions
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locat
or
import
CourseLocator
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
...
...
@@ -120,7 +120,7 @@ class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase):
def
test_email_undefined_course
(
self
):
# 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
):
self
.
_run_task_with_mock_celery
(
send_bulk_course_email
,
task_entry
.
id
,
task_entry
.
task_id
)
...
...
lms/djangoapps/courseware/tests/factories.py
View file @
6f71706b
...
...
@@ -5,7 +5,8 @@ from functools import partial
import
factory
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
(
StudentModule
,
...
...
@@ -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)
# 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'
)
...
...
@@ -128,7 +129,7 @@ class StudentModuleFactory(DjangoModelFactory):
module_type
=
"problem"
student
=
factory
.
SubFactory
(
UserFactory
)
course_id
=
SlashSeparatedCourseKey
(
"MITx"
,
"999"
,
"Robot_Super_Course"
)
course_id
=
CourseLocator
(
"MITx"
,
"999"
,
"Robot_Super_Course"
)
state
=
None
grade
=
None
max_grade
=
None
...
...
lms/djangoapps/courseware/tests/test_access.py
View file @
6f71706b
...
...
@@ -15,7 +15,7 @@ from django.test.client import RequestFactory
from
milestones.tests.utils
import
MilestonesTestCaseMixin
from
mock
import
Mock
,
patch
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.locat
ions
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locat
or
import
CourseLocator
import
courseware.access
as
access
import
courseware.access_response
as
access_response
...
...
@@ -500,7 +500,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
user
=
UserFactory
.
create
()
course
=
Mock
(
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
)
self
.
assertTrue
(
access
.
_has_access_course
(
user
,
'enroll'
,
course
))
...
...
@@ -513,7 +513,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
# and not specifically allowed
course
=
Mock
(
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
)
user
=
UserFactory
.
create
()
...
...
@@ -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
course
=
Mock
(
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
)
self
.
assertTrue
(
access
.
_has_access_course
(
user
,
'enroll'
,
course
))
...
...
@@ -530,7 +530,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
# Non-staff cannot enroll outside the open enrollment period if not specifically allowed
course
=
Mock
(
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
)
self
.
assertFalse
(
access
.
_has_access_course
(
user
,
'enroll'
,
course
))
...
...
@@ -544,7 +544,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
Tests the catalog visibility tri-states
"""
user
=
UserFactory
.
create
()
course_id
=
SlashSeparatedCourseKey
(
'edX'
,
'test'
,
'2012_Fall'
)
course_id
=
CourseLocator
(
'edX'
,
'test'
,
'2012_Fall'
)
staff
=
StaffFactory
.
create
(
course_key
=
course_id
)
course
=
Mock
(
...
...
@@ -558,7 +558,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
# Now set visibility to just about page
course
=
Mock
(
id
=
SlashSeparatedCourseKey
(
'edX'
,
'test'
,
'2012_Fall'
),
id
=
CourseLocator
(
'edX'
,
'test'
,
'2012_Fall'
),
catalog_visibility
=
CATALOG_VISIBILITY_ABOUT
)
self
.
assertFalse
(
access
.
_has_access_course
(
user
,
'see_in_catalog'
,
course
))
...
...
@@ -568,7 +568,7 @@ class AccessTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase, MilestonesTes
# Now set visibility to none, which means neither in catalog nor about pages
course
=
Mock
(
id
=
SlashSeparatedCourseKey
(
'edX'
,
'test'
,
'2012_Fall'
),
id
=
CourseLocator
(
'edX'
,
'test'
,
'2012_Fall'
),
catalog_visibility
=
CATALOG_VISIBILITY_NONE
)
self
.
assertFalse
(
access
.
_has_access_course
(
user
,
'see_in_catalog'
,
course
))
...
...
@@ -675,7 +675,7 @@ class UserRoleTestCase(TestCase):
def
setUp
(
self
):
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
.
student
=
UserFactory
()
self
.
global_staff
=
UserFactory
(
is_staff
=
True
)
...
...
lms/djangoapps/courseware/tests/test_draft_modulestore.py
View file @
6f71706b
from
django.test
import
TestCase
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.
keys
import
CourseKey
from
xmodule.modulestore.django
import
modulestore
...
...
@@ -14,7 +14,7 @@ class TestDraftModuleStore(TestCase):
store
=
modulestore
()
# 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.
# The bug was that 'course_id' argument was
...
...
lms/djangoapps/courseware/tests/test_module_render.py
View file @
6f71706b
...
...
@@ -24,7 +24,6 @@ from milestones.tests.utils import MilestonesTestCaseMixin
from
mock
import
MagicMock
,
Mock
,
patch
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.keys
import
CourseKey
,
UsageKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
pyquery
import
PyQuery
from
xblock.core
import
XBlock
,
XBlockAside
from
xblock.field_data
import
FieldData
...
...
@@ -1645,14 +1644,14 @@ class TestAnonymousStudentId(SharedModuleStoreTestCase, LoginEnrollmentTestCase)
# This value is set by observation, so that later changes to the student
# id computation don't break old data
'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
(
# This value is set by observation, so that later changes to the student
# id computation don't break old data
'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
)
)
...
...
lms/djangoapps/courseware/tests/test_views.py
View file @
6f71706b
...
...
@@ -41,7 +41,8 @@ from lms.djangoapps.grades.config.waffle import ASSUME_ZERO_GRADE_IF_ABSENT
from
milestones.tests.utils
import
MilestonesTestCaseMixin
from
mock
import
MagicMock
,
PropertyMock
,
create_autospec
,
patch
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
CourseRunFactory
,
ProgramFactory
from
openedx.core.djangoapps.content.course_overviews.models
import
CourseOverview
...
...
@@ -86,7 +87,7 @@ class TestJumpTo(ModuleStoreTestCase):
def
setUp
(
self
):
super
(
TestJumpTo
,
self
)
.
setUp
()
# 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
):
location
=
self
.
course_key
.
make_usage_key
(
None
,
'NoSuchPlace'
)
...
...
@@ -1187,7 +1188,7 @@ class StartDateTests(ModuleStoreTestCase):
)
@unittest.skip
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
self
.
assertContains
(
response
,
"2015-JULY-17"
)
...
...
lms/djangoapps/courseware/tests/tests.py
View file @
6f71706b
...
...
@@ -7,7 +7,7 @@ from unittest import TestCase
import
mock
from
django.core.urlresolvers
import
reverse
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.
keys
import
CourseKey
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
lms.djangoapps.lms_xblock.field_data
import
LmsFieldData
...
...
@@ -151,7 +151,7 @@ class TestDraftModuleStore(ModuleStoreTestCase):
store
=
modulestore
()
# 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.
# The bug was that 'course_id' argument was
...
...
lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py
View file @
6f71706b
...
...
@@ -14,7 +14,7 @@ from django.core.management import call_command
from
django.core.management.base
import
CommandError
from
django.test.utils
import
override_settings
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.
keys
import
CourseKey
import
dashboard.git_import
as
git_import
from
dashboard.git_import
import
(
...
...
@@ -57,7 +57,7 @@ class TestGitAddCourse(SharedModuleStoreTestCase):
TEST_REPO
=
'https://github.com/mitocw/edx4edx_lite.git'
TEST_COURSE
=
'MITx/edx4edx/edx4edx'
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'
]
...
...
@@ -183,7 +183,7 @@ class TestGitAddCourse(SharedModuleStoreTestCase):
repo_dir
/
'edx4edx_lite'
,
'master'
)
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
):
"""
...
...
lms/djangoapps/dashboard/tests/test_sysadmin.py
View file @
6f71706b
...
...
@@ -16,7 +16,7 @@ from django.test.client import Client
from
django.test.utils
import
override_settings
from
django.utils.timezone
import
utc
as
UTC
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.
keys
import
CourseKey
from
dashboard.git_import
import
GitImportErrorNoDir
from
dashboard.models
import
CourseImportLog
...
...
@@ -46,7 +46,7 @@ class SysadminBaseTestCase(SharedModuleStoreTestCase):
TEST_REPO
=
'https://github.com/mitocw/edx4edx_lite.git'
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
):
"""Setup test case by adding primary user."""
...
...
@@ -78,7 +78,7 @@ class SysadminBaseTestCase(SharedModuleStoreTestCase):
course
=
def_ms
.
courses
.
get
(
course_path
,
None
)
except
AttributeError
:
# 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
response
=
self
.
client
.
post
(
...
...
@@ -168,11 +168,11 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase):
self
.
assertNotEqual
(
'xml'
,
def_ms
.
get_modulestore_type
(
None
))
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
.
_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
)
def
test_course_info
(
self
):
...
...
@@ -301,7 +301,7 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase):
for
_
in
xrange
(
15
):
CourseImportLog
(
course_id
=
SlashSeparatedCourseKey
(
"test"
,
"test"
,
"
test"
),
course_id
=
CourseKey
.
from_string
(
"test/test/
test"
),
location
=
"location"
,
import_log
=
"import_log"
,
git_log
=
"git_log"
,
...
...
@@ -347,7 +347,7 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase):
# Add user as staff in course team
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
)
self
.
assertTrue
(
CourseStaffRole
(
course
.
id
)
.
has_user
(
self
.
user
))
...
...
lms/djangoapps/instructor/tests/test_api.py
View file @
6f71706b
...
...
@@ -25,7 +25,7 @@ from django.utils.translation import ugettext as _
from
mock
import
Mock
,
patch
from
nose.plugins.attrib
import
attr
from
nose.tools
import
raises
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.
keys
import
CourseKey
from
opaque_keys.edx.locator
import
UsageKey
import
lms.djangoapps.instructor.views.api
...
...
@@ -4075,10 +4075,10 @@ class TestInstructorAPIHelpers(TestCase):
self
.
assertEqual
(
_split_input_list
(
scary_unistuff
),
[
scary_unistuff
])
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'
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
)
def
test_msk_from_problem_urlname_error
(
self
):
...
...
lms/djangoapps/instructor/tests/test_email.py
View file @
6f71706b
...
...
@@ -7,7 +7,7 @@ that the view is conditionally available when Course Auth is turned on.
from
django.core.urlresolvers
import
reverse
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.
keys
import
CourseKey
from
bulk_email.models
import
BulkEmailFlag
,
CourseAuthorization
from
student.tests.factories
import
AdminFactory
...
...
@@ -119,10 +119,10 @@ class TestNewInstructorDashboardEmailViewXMLBacked(SharedModuleStoreTestCase):
@classmethod
def
setUpClass
(
cls
):
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
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
cls
.
email_link
=
'<button type="button" class="btn-link send_email" data-section="send_email">Email</button>'
...
...
lms/djangoapps/instructor/tests/test_enrollment.py
View file @
6f71706b
...
...
@@ -13,7 +13,7 @@ from django.utils.translation import override as override_language
from
django.utils.translation
import
get_language
from
mock
import
patch
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.locat
ions
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locat
or
import
CourseLocator
from
capa.tests.response_xml_factory
import
MultipleChoiceResponseXMLFactory
from
courseware.models
import
StudentModule
...
...
@@ -44,7 +44,7 @@ class TestSettableEnrollmentState(CacheIsolationTestCase):
""" Test the basis class for enrollment tests. """
def
setUp
(
self
):
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
):
"""
...
...
@@ -75,7 +75,7 @@ class TestEnrollmentChangeBase(CacheIsolationTestCase):
def
setUp
(
self
):
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
):
"""
...
...
lms/djangoapps/instructor_analytics/tests/test_distributions.py
View file @
6f71706b
...
...
@@ -2,7 +2,7 @@
from
django.test
import
TestCase
from
nose.tools
import
raises
from
opaque_keys.edx.locat
ions
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locat
or
import
CourseLocator
from
instructor_analytics.distributions
import
AVAILABLE_PROFILE_FEATURES
,
profile_distribution
from
student.models
import
CourseEnrollment
...
...
@@ -14,7 +14,7 @@ class TestAnalyticsDistributions(TestCase):
def
setUp
(
self
):
super
(
TestAnalyticsDistributions
,
self
)
.
setUp
()
self
.
course_id
=
SlashSeparatedCourseKey
(
'robot'
,
'course'
,
'id'
)
self
.
course_id
=
CourseLocator
(
'robot'
,
'course'
,
'id'
)
self
.
users
=
[
UserFactory
(
profile__gender
=
[
'm'
,
'f'
,
'o'
][
i
%
3
],
...
...
@@ -77,7 +77,7 @@ class TestAnalyticsDistributionsNoData(TestCase):
def
setUp
(
self
):
super
(
TestAnalyticsDistributionsNoData
,
self
)
.
setUp
()
self
.
course_id
=
SlashSeparatedCourseKey
(
'robot'
,
'course'
,
'id'
)
self
.
course_id
=
CourseLocator
(
'robot'
,
'course'
,
'id'
)
self
.
users
=
[
UserFactory
(
profile__year_of_birth
=
i
+
1930
,
...
...
lms/djangoapps/instructor_task/tests/factories.py
View file @
6f71706b
...
...
@@ -3,7 +3,7 @@ import json
import
factory
from
celery.states
import
PENDING
from
factory.django
import
DjangoModelFactory
from
opaque_keys.edx.locat
ions
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locat
or
import
CourseLocator
from
lms.djangoapps.instructor_task.models
import
InstructorTask
from
student.tests.factories
import
UserFactory
as
StudentUserFactory
...
...
@@ -14,7 +14,7 @@ class InstructorTaskFactory(DjangoModelFactory):
model
=
InstructorTask
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_key
=
None
task_id
=
None
...
...
lms/djangoapps/instructor_task/tests/test_base.py
View file @
6f71706b
...
...
@@ -14,7 +14,8 @@ from celery.states import FAILURE, SUCCESS
from
django.contrib.auth.models
import
User
from
django.core.urlresolvers
import
reverse
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
courseware.model_data
import
StudentModule
...
...
@@ -34,7 +35,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
TEST_COURSE_ORG
=
'edx'
TEST_COURSE_NAME
=
'test_course'
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_SECTION_NAME
=
"Subsection"
...
...
lms/djangoapps/lms_xblock/test/test_runtime.py
View file @
6f71706b
...
...
@@ -9,7 +9,7 @@ from django.conf import settings
from
django.test
import
TestCase
from
mock
import
Mock
,
patch
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.fields
import
ScopeIds
...
...
@@ -56,7 +56,7 @@ class TestHandlerUrl(TestCase):
def
setUp
(
self
):
super
(
TestHandlerUrl
,
self
)
.
setUp
()
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
(
static_url
=
'/static'
,
track_function
=
Mock
(),
...
...
@@ -120,7 +120,7 @@ class TestUserServiceAPI(TestCase):
def
setUp
(
self
):
super
(
TestUserServiceAPI
,
self
)
.
setUp
()
self
.
course_id
=
SlashSeparatedCourseKey
(
"org"
,
"course"
,
"run"
)
self
.
course_id
=
CourseLocator
(
"org"
,
"course"
,
"run"
)
self
.
user
=
UserFactory
.
create
()
def
mock_get_real_user
(
_anon_id
):
...
...
lms/djangoapps/verify_student/tests/test_views.py
View file @
6f71706b
...
...
@@ -24,7 +24,7 @@ from django.test.client import Client, RequestFactory
from
django.test.utils
import
override_settings
from
mock
import
Mock
,
patch
from
nose.plugins.attrib
import
attr
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.
keys
import
CourseKey
from
opaque_keys.edx.locator
import
CourseLocator
from
waffle.testutils
import
override_switch
...
...
@@ -1310,7 +1310,7 @@ class TestCreateOrderView(ModuleStoreTestCase):
self
.
course_id
=
'Robot/999/Test_Course'
self
.
course
=
CourseFactory
.
create
(
org
=
'Robot'
,
number
=
'999'
,
display_name
=
'Test Course'
)
verified_mode
=
CourseMode
(
course_id
=
SlashSeparatedCourseKey
(
"Robot"
,
"999"
,
'Test_Course'
),
course_id
=
CourseKey
.
from_string
(
"Robot/999/Test_Course"
),
mode_slug
=
"verified"
,
mode_display_name
=
"Verified Certificate"
,
min_price
=
50
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment