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
ec13ba43
Commit
ec13ba43
authored
Aug 24, 2016
by
Mushtaq Ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix when checking in mongo store, `has_course` with a split course key returns False.
parent
2dc4f5d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
cms/djangoapps/maintenance/tests.py
+17
-0
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+5
-0
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+8
-0
No files found.
cms/djangoapps/maintenance/tests.py
View file @
ec13ba43
...
...
@@ -182,6 +182,23 @@ class TestForcePublish(MaintenanceViewTestCase):
error_message
=
'Force publishing course is not supported with old mongo courses.'
)
def
test_mongo_course_with_split_course_key
(
self
):
"""
Test that we get an error message `course_key_not_found` for a provided split course key
if we already have an old mongo course.
"""
# validate non split error message
course
=
CourseFactory
.
create
(
org
=
'e'
,
number
=
'd'
,
run
=
'X'
,
default_store
=
ModuleStoreEnum
.
Type
.
mongo
)
self
.
verify_error_message
(
data
=
{
'course-id'
:
unicode
(
course
.
id
)},
error_message
=
'Force publishing course is not supported with old mongo courses.'
)
# Now search for the course key in split version.
self
.
verify_error_message
(
data
=
{
'course-id'
:
'course-v1:e+d+X'
},
error_message
=
COURSE_KEY_ERROR_MESSAGES
[
'course_key_not_found'
]
)
def
test_already_published
(
self
):
"""
Test that when a course is forcefully publish, we get a 'course is already published' message.
...
...
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
ec13ba43
...
...
@@ -1118,6 +1118,11 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
otherwise, do a case sensitive search
"""
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.
return
False
if
isinstance
(
course_key
,
LibraryLocator
):
return
None
# Libraries require split mongo
course_key
=
self
.
fill_in_run
(
course_key
)
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
View file @
ec13ba43
...
...
@@ -300,6 +300,14 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
with
self
.
assertRaises
(
ItemNotFoundError
):
self
.
draft_store
.
get_course
(
course_key
)
def
test_has_mongo_course_with_split_course_key
(
self
):
"""
Test `has course` using split course key would return False.
"""
course_key
=
CourseKey
.
from_string
(
'course-v1:edX+simple+2012_Fall'
)
self
.
assertFalse
(
self
.
draft_store
.
has_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