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
025f046b
Commit
025f046b
authored
Jan 15, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix errors with libraries when old mongo is default (first) modulestore
parent
e6e443c7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
14 deletions
+50
-14
cms/djangoapps/contentstore/management/commands/fix_not_found.py
+1
-1
cms/djangoapps/contentstore/management/commands/tests/test_create_course.py
+1
-1
cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py
+1
-1
cms/djangoapps/contentstore/tests/utils.py
+1
-1
common/lib/xmodule/xmodule/modulestore/mixed.py
+0
-0
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+15
-0
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+30
-9
lms/djangoapps/courseware/tests/test_module_render.py
+1
-1
No files found.
cms/djangoapps/contentstore/management/commands/fix_not_found.py
View file @
025f046b
...
...
@@ -21,7 +21,7 @@ class Command(BaseCommand):
course_key
=
CourseKey
.
from_string
(
args
[
0
])
# for now only support on split mongo
# pylint: disable=protected-access
owning_store
=
modulestore
()
.
_get_modulestore_for_course
id
(
course_key
)
owning_store
=
modulestore
()
.
_get_modulestore_for_course
like
(
course_key
)
if
hasattr
(
owning_store
,
'fix_not_found'
):
owning_store
.
fix_not_found
(
course_key
,
ModuleStoreEnum
.
UserID
.
mgmt_command
)
else
:
...
...
cms/djangoapps/contentstore/management/commands/tests/test_create_course.py
View file @
025f046b
...
...
@@ -65,4 +65,4 @@ class TestCreateCourse(ModuleStoreTestCase):
"Could not find course in {}"
.
format
(
store
)
)
# pylint: disable=protected-access
self
.
assertEqual
(
store
,
modulestore
()
.
_get_modulestore_for_course
id
(
new_key
)
.
get_modulestore_type
())
self
.
assertEqual
(
store
,
modulestore
()
.
_get_modulestore_for_course
like
(
new_key
)
.
get_modulestore_type
())
cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py
View file @
025f046b
...
...
@@ -81,7 +81,7 @@ class TestMigrateToSplit(ModuleStoreTestCase):
# default mapping in mixed modulestore. I left the test here so we can debate what it ought to do.
# self.assertEqual(
# ModuleStoreEnum.Type.split,
# modulestore()._get_modulestore_for_course
id
(new_key).get_modulestore_type(),
# modulestore()._get_modulestore_for_course
like
(new_key).get_modulestore_type(),
# "Split is not the new default for the course"
# )
...
...
cms/djangoapps/contentstore/tests/utils.py
View file @
025f046b
...
...
@@ -316,7 +316,7 @@ class CourseTestCase(ModuleStoreTestCase):
course2_item_loc
=
course2_id
.
make_usage_key
(
course1_item_loc
.
block_type
,
course1_item_loc
.
block_id
)
if
course1_item_loc
.
block_type
==
'course'
:
# mongo uses the run as the name, split uses 'course'
store
=
self
.
store
.
_get_modulestore_for_course
id
(
course2_id
)
# pylint: disable=protected-access
store
=
self
.
store
.
_get_modulestore_for_course
like
(
course2_id
)
# pylint: disable=protected-access
new_name
=
'course'
if
isinstance
(
store
,
SplitMongoModuleStore
)
else
course2_item_loc
.
run
course2_item_loc
=
course2_item_loc
.
replace
(
name
=
new_name
)
course2_item
=
self
.
store
.
get_item
(
course2_item_loc
)
...
...
common/lib/xmodule/xmodule/modulestore/mixed.py
View file @
025f046b
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
025f046b
...
...
@@ -944,6 +944,21 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
course_index
=
self
.
get_course_index
(
course_id
,
ignore_case
)
return
CourseLocator
(
course_index
[
'org'
],
course_index
[
'course'
],
course_index
[
'run'
],
course_id
.
branch
)
if
course_index
else
None
def
has_library
(
self
,
library_id
,
ignore_case
=
False
,
**
kwargs
):
'''
Does this library exist in this modulestore. This method does not verify that the branch &/or
version in the library_id exists.
Returns the library_id of the course if it was found, else None.
'''
if
not
isinstance
(
library_id
,
LibraryLocator
):
return
None
index
=
self
.
get_course_index
(
library_id
,
ignore_case
)
if
index
:
return
LibraryLocator
(
index
[
'org'
],
index
[
'course'
],
library_id
.
branch
)
return
None
def
has_item
(
self
,
usage_key
):
"""
Returns True if usage_key exists in its course. Returns false if
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
025f046b
...
...
@@ -29,7 +29,7 @@ if not settings.configured:
settings
.
configure
()
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locator
import
BlockUsageLocator
,
CourseLocator
from
opaque_keys.edx.locator
import
BlockUsageLocator
,
CourseLocator
,
LibraryLocator
from
xmodule.exceptions
import
InvalidVersionError
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.draft_and_published
import
UnsupportedRevisionError
...
...
@@ -38,7 +38,7 @@ from xmodule.modulestore.mixed import MixedModuleStore
from
xmodule.modulestore.search
import
path_to_location
from
xmodule.modulestore.tests.factories
import
check_mongo_calls
,
check_exact_number_of_calls
,
\
mongo_uses_error_check
from
xmodule.modulestore.tests.utils
import
create_modulestore_instance
from
xmodule.modulestore.tests.utils
import
create_modulestore_instance
,
LocationMixin
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
from
xmodule.tests
import
DATA_DIR
,
CourseComparisonTest
...
...
@@ -68,7 +68,7 @@ class TestMixedModuleStore(CourseComparisonTest):
'default_class'
:
DEFAULT_CLASS
,
'fs_root'
:
DATA_DIR
,
'render_template'
:
RENDER_TEMPLATE
,
'xblock_mixins'
:
(
EditInfoMixin
,
InheritanceMixin
),
'xblock_mixins'
:
(
EditInfoMixin
,
InheritanceMixin
,
LocationMixin
),
}
DOC_STORE_CONFIG
=
{
'host'
:
HOST
,
...
...
@@ -102,7 +102,7 @@ class TestMixedModuleStore(CourseComparisonTest):
'OPTIONS'
:
{
'data_dir'
:
DATA_DIR
,
'default_class'
:
'xmodule.hidden_module.HiddenDescriptor'
,
'xblock_mixins'
:
(
EditInfoMixin
,
InheritanceMixin
)
,
'xblock_mixins'
:
modulestore_options
[
'xblock_mixins'
]
,
}
},
]
...
...
@@ -309,9 +309,9 @@ class TestMixedModuleStore(CourseComparisonTest):
self
.
store
.
mappings
=
{}
course_key
=
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
course_key
with
check_exact_number_of_calls
(
self
.
store
.
default_modulestore
,
'has_course'
,
1
):
self
.
assertEqual
(
self
.
store
.
default_modulestore
,
self
.
store
.
_get_modulestore_for_course
id
(
course_key
))
self
.
assertEqual
(
self
.
store
.
default_modulestore
,
self
.
store
.
_get_modulestore_for_course
like
(
course_key
))
# pylint: disable=protected-access
self
.
assertIn
(
course_key
,
self
.
store
.
mappings
)
self
.
assertEqual
(
self
.
store
.
default_modulestore
,
self
.
store
.
_get_modulestore_for_course
id
(
course_key
))
self
.
assertEqual
(
self
.
store
.
default_modulestore
,
self
.
store
.
_get_modulestore_for_course
like
(
course_key
))
# pylint: disable=protected-access
@ddt.data
(
*
itertools
.
product
(
(
ModuleStoreEnum
.
Type
.
mongo
,
ModuleStoreEnum
.
Type
.
split
),
...
...
@@ -881,6 +881,27 @@ class TestMixedModuleStore(CourseComparisonTest):
course
=
self
.
store
.
get_item
(
self
.
course_locations
[
self
.
XML_COURSEID1
])
self
.
assertEqual
(
course
.
id
,
self
.
course_locations
[
self
.
XML_COURSEID1
]
.
course_key
)
@ddt.data
(
'draft'
,
'split'
)
def
test_get_library
(
self
,
default_ms
):
"""
Test that create_library and get_library work regardless of the default modulestore.
Other tests of MixedModulestore support are in test_libraries.py but this one must
be done here so we can test the configuration where Draft/old is the first modulestore.
"""
self
.
initdb
(
default_ms
)
with
self
.
store
.
default_store
(
ModuleStoreEnum
.
Type
.
split
):
# The CMS also wraps create_library like this
library
=
self
.
store
.
create_library
(
"org"
,
"lib"
,
self
.
user_id
,
{
"display_name"
:
"Test Library"
})
library_key
=
library
.
location
.
library_key
self
.
assertIsInstance
(
library_key
,
LibraryLocator
)
# Now load with get_library and make sure it works:
library
=
self
.
store
.
get_library
(
library_key
)
self
.
assertEqual
(
library
.
location
.
library_key
,
library_key
)
# Clear the mappings so we can test get_library code path without mapping set:
self
.
store
.
mappings
.
clear
()
library
=
self
.
store
.
get_library
(
library_key
)
self
.
assertEqual
(
library
.
location
.
library_key
,
library_key
)
# notice this doesn't test getting a public item via draft_preferred which draft would have 2 hits (split
# still only 2)
# Draft: get_parent
...
...
@@ -1007,7 +1028,7 @@ class TestMixedModuleStore(CourseComparisonTest):
self
.
_create_block_hierarchy
()
self
.
store
.
publish
(
self
.
course
.
location
,
self
.
user_id
)
mongo_store
=
self
.
store
.
_get_modulestore_for_course
id
(
course_id
)
# pylint: disable=protected-access
mongo_store
=
self
.
store
.
_get_modulestore_for_course
like
(
course_id
)
# pylint: disable=protected-access
# add another parent (unit) "vertical_x1b" for problem "problem_x1a_1"
mongo_store
.
collection
.
update
(
self
.
vertical_x1b
.
to_deprecated_son
(
'_id.'
),
...
...
@@ -1249,7 +1270,7 @@ class TestMixedModuleStore(CourseComparisonTest):
self
.
store
.
publish
(
self
.
course
.
location
,
self
.
user_id
)
# test that problem "problem_x1a_1" has only one published parent
mongo_store
=
self
.
store
.
_get_modulestore_for_course
id
(
course_id
)
# pylint: disable=protected-access
mongo_store
=
self
.
store
.
_get_modulestore_for_course
like
(
course_id
)
# pylint: disable=protected-access
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
published_only
,
course_id
):
parent
=
mongo_store
.
get_parent_location
(
self
.
problem_x1a_1
)
self
.
assertEqual
(
parent
,
self
.
vertical_x1a
)
...
...
@@ -1809,7 +1830,7 @@ class TestMixedModuleStore(CourseComparisonTest):
self
.
assertEquals
(
self
.
store
.
default_modulestore
.
get_modulestore_type
(),
store_type
)
# verify internal helper method
store
=
self
.
store
.
_get_modulestore_for_course
id
()
# pylint: disable=protected-access
store
=
self
.
store
.
_get_modulestore_for_course
like
()
# pylint: disable=protected-access
self
.
assertEquals
(
store
.
get_modulestore_type
(),
store_type
)
# verify store used for creating a course
...
...
lms/djangoapps/courseware/tests/test_module_render.py
View file @
025f046b
...
...
@@ -413,7 +413,7 @@ class TestTOC(ModuleStoreTestCase):
factory
=
RequestFactory
()
self
.
request
=
factory
.
get
(
chapter_url
)
self
.
request
.
user
=
UserFactory
()
self
.
modulestore
=
self
.
store
.
_get_modulestore_for_course
id
(
self
.
course_key
)
self
.
modulestore
=
self
.
store
.
_get_modulestore_for_course
like
(
self
.
course_key
)
# pylint: disable=protected-access, attribute-defined-outside-init
with
self
.
modulestore
.
bulk_operations
(
self
.
course_key
):
with
check_mongo_calls
(
num_finds
,
num_sends
):
self
.
toy_course
=
self
.
store
.
get_course
(
self
.
toy_loc
,
depth
=
2
)
...
...
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