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
79df5456
Commit
79df5456
authored
Jul 21, 2016
by
Syed Hassan Raza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mongo courses wrong course_key restriction
parent
18a2b535
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
2 deletions
+29
-2
cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py
+14
-2
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+5
-0
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+10
-0
No files found.
cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py
View file @
79df5456
...
...
@@ -9,6 +9,7 @@ from xmodule.modulestore import ModuleStoreEnum
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
class
TestArgParsing
(
unittest
.
TestCase
):
...
...
@@ -107,6 +108,17 @@ class TestMigrateToSplit(ModuleStoreTestCase):
"org.dept"
,
"name"
,
"run"
,
)
split_store
=
modulestore
()
.
_get_modulestore_by_type
(
ModuleStoreEnum
.
Type
.
split
)
locator
=
split_store
.
make_course_key
(
self
.
course
.
id
.
org
,
self
.
course
.
id
.
course
,
self
.
course
.
id
.
run
)
course_from_split
=
modulestore
()
.
get_course
(
locator
)
locator
=
split_store
.
make_course_key
(
"org.dept"
,
"name"
,
"run"
)
course_from_split
=
split_store
.
get_course
(
locator
)
self
.
assertIsNotNone
(
course_from_split
)
# Getting the original course with mongo course_id
mongo_store
=
modulestore
()
.
_get_modulestore_by_type
(
ModuleStoreEnum
.
Type
.
mongo
)
mongo_locator
=
mongo_store
.
make_course_key
(
self
.
course
.
id
.
org
,
self
.
course
.
id
.
course
,
self
.
course
.
id
.
run
)
course_from_mongo
=
mongo_store
.
get_course
(
mongo_locator
)
self
.
assertIsNotNone
(
course_from_mongo
)
# Throws ItemNotFoundError when try to access original course with split course_id
split_locator
=
split_store
.
make_course_key
(
self
.
course
.
id
.
org
,
self
.
course
.
id
.
course
,
self
.
course
.
id
.
run
)
with
self
.
assertRaises
(
ItemNotFoundError
):
mongo_store
.
get_course
(
split_locator
)
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
79df5456
...
...
@@ -1088,6 +1088,11 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
Get the course with the given courseid (org/course/run)
"""
assert
isinstance
(
course_key
,
CourseKey
)
if
not
course_key
.
deprecated
:
# split course_key
# The supplied CourseKey is of the wrong type, so it can't possibly be stored in this modulestore.
raise
ItemNotFoundError
(
course_key
)
course_key
=
self
.
fill_in_run
(
course_key
)
location
=
course_key
.
make_usage_key
(
'course'
,
course_key
.
run
)
try
:
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
View file @
79df5456
...
...
@@ -24,6 +24,7 @@ from xblock.runtime import KeyValueStore
from
xblock.exceptions
import
InvalidScopeError
from
xmodule.tests
import
DATA_DIR
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.locations
import
Location
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.mongo
import
MongoKeyValueStore
...
...
@@ -290,6 +291,15 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
assert_false
(
self
.
draft_store
.
has_course
(
mix_cased
))
assert_false
(
self
.
draft_store
.
has_course
(
mix_cased
,
ignore_case
=
True
))
def
test_get_mongo_course_with_split_course_key
(
self
):
"""
Test mongo course using split course_key will not able to access it.
"""
course_key
=
CourseKey
.
from_string
(
'course-v1:edX+simple+2012_Fall'
)
with
self
.
assertRaises
(
ItemNotFoundError
):
self
.
draft_store
.
get_course
(
course_key
)
def
test_has_course_with_library
(
self
):
"""
Test that has_course() returns False when called with a LibraryLocator.
...
...
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