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
9ee8c8fd
Commit
9ee8c8fd
authored
Jan 27, 2016
by
David Ormsbee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce publish signals during tests.
parent
44e4569d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
10 deletions
+50
-10
cms/djangoapps/contentstore/management/commands/tests/test_create_course.py
+34
-0
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+2
-2
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+5
-4
common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py
+3
-2
common/lib/xmodule/xmodule/modulestore/tests/factories.py
+6
-2
No files found.
cms/djangoapps/contentstore/management/commands/tests/test_create_course.py
View file @
9ee8c8fd
...
...
@@ -68,3 +68,37 @@ class TestCreateCourse(ModuleStoreTestCase):
)
# pylint: disable=protected-access
self
.
assertEqual
(
store
,
modulestore
()
.
_get_modulestore_for_courselike
(
new_key
)
.
get_modulestore_type
())
# import cProfile, pstats, StringIO
# from xmodule.modulestore import ModuleStoreEnum
# from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
#
# class TestCreateSingleCourse(ModuleStoreTestCase):
# """
# Unit tests for creating a course in either old mongo or split mongo via command line
#
# These are just here for profiling tests and will be removed later.
# """
#
# @classmethod
# def setUpClass(cls):
# cls.pr = cProfile.Profile()
# cls.pr.enable()
#
# @classmethod
# def tearDownClass(cls):
# cls.pr.disable()
# cls.pr.dump_stats("steelix/ms_tc2.stats")
#
# def setUp(self):
# super(TestCreateSingleCourse, self).setUp()
#
# def test_old_mongo(self):
# course = CourseFactory.create(
# default_store=ModuleStoreEnum.Type.mongo, emit_signals=False
# )
#
# def test_split(self):
# course = CourseFactory.create(
# default_store=ModuleStoreEnum.Type.split, emit_signals=False
# )
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
9ee8c8fd
...
...
@@ -1234,7 +1234,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
)
return
modules
def
create_course
(
self
,
org
,
course
,
run
,
user_id
,
fields
=
None
,
**
kwargs
):
def
create_course
(
self
,
org
,
course
,
run
,
user_id
,
fields
=
None
,
emit_signals
=
True
,
**
kwargs
):
"""
Creates and returns the course.
...
...
@@ -1264,7 +1264,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
if
courses
.
count
()
>
0
:
raise
DuplicateCourseError
(
course_id
,
courses
[
0
][
'_id'
])
with
self
.
bulk_operations
(
course_id
):
with
self
.
bulk_operations
(
course_id
,
emit_signals
=
emit_signals
):
xblock
=
self
.
create_item
(
user_id
,
course_id
,
'course'
,
course_id
.
run
,
fields
=
fields
,
**
kwargs
)
# create any other necessary things as a side effect
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
9ee8c8fd
...
...
@@ -1808,7 +1808,7 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
def
create_course
(
self
,
org
,
course
,
run
,
user_id
,
master_branch
=
None
,
fields
=
None
,
versions_dict
=
None
,
search_targets
=
None
,
root_category
=
'course'
,
root_block_id
=
None
,
**
kwargs
root_block_id
=
None
,
emit_signals
=
True
,
**
kwargs
):
"""
Create a new entry in the active courses index which points to an existing or new structure. Returns
...
...
@@ -1858,13 +1858,14 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
locator
=
CourseLocator
(
org
=
org
,
course
=
course
,
run
=
run
,
branch
=
master_branch
)
return
self
.
_create_courselike
(
locator
,
user_id
,
master_branch
,
fields
,
versions_dict
,
search_targets
,
root_category
,
root_block_id
,
**
kwargs
search_targets
,
root_category
,
root_block_id
,
emit_signals
=
emit_signals
,
**
kwargs
)
def
_create_courselike
(
self
,
locator
,
user_id
,
master_branch
,
fields
=
None
,
versions_dict
=
None
,
search_targets
=
None
,
root_category
=
'course'
,
root_block_id
=
None
,
**
kwargs
root_block_id
=
None
,
emit_signals
=
True
,
**
kwargs
):
"""
Internal code for creating a course or library
...
...
@@ -1928,7 +1929,7 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
draft_structure
=
self
.
_lookup_course
(
draft_version
)
.
structure
locator
=
locator
.
replace
(
version_guid
=
new_id
)
with
self
.
bulk_operations
(
locator
):
with
self
.
bulk_operations
(
locator
,
emit_signals
=
emit_signals
):
self
.
update_structure
(
locator
,
draft_structure
)
index_entry
=
{
'_id'
:
ObjectId
(),
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py
View file @
9ee8c8fd
...
...
@@ -19,7 +19,7 @@ class DraftVersioningModuleStore(SplitMongoModuleStore, ModuleStoreDraftAndPubli
A subclass of Split that supports a dual-branch fall-back versioning framework
with a Draft branch that falls back to a Published branch.
"""
def
create_course
(
self
,
org
,
course
,
run
,
user_id
,
skip_auto_publish
=
False
,
**
kwargs
):
def
create_course
(
self
,
org
,
course
,
run
,
user_id
,
skip_auto_publish
=
False
,
emit_signals
=
True
,
**
kwargs
):
"""
Creates and returns the course.
...
...
@@ -33,7 +33,8 @@ class DraftVersioningModuleStore(SplitMongoModuleStore, ModuleStoreDraftAndPubli
Returns: a CourseDescriptor
"""
master_branch
=
kwargs
.
pop
(
'master_branch'
,
ModuleStoreEnum
.
BranchName
.
draft
)
with
self
.
bulk_operations
(
CourseLocator
(
org
,
course
,
run
)):
with
self
.
bulk_operations
(
CourseLocator
(
org
,
course
,
run
),
emit_signals
=
emit_signals
):
item
=
super
(
DraftVersioningModuleStore
,
self
)
.
create_course
(
org
,
course
,
run
,
user_id
,
master_branch
=
master_branch
,
**
kwargs
)
...
...
common/lib/xmodule/xmodule/modulestore/tests/factories.py
View file @
9ee8c8fd
...
...
@@ -129,9 +129,13 @@ class CourseFactory(XModuleFactory):
with
store
.
bulk_operations
(
course_key
,
emit_signals
=
emit_signals
):
if
default_store_override
is
not
None
:
with
store
.
default_store
(
default_store_override
):
new_course
=
store
.
create_course
(
org
,
number
,
run
,
user_id
,
fields
=
kwargs
)
new_course
=
store
.
create_course
(
org
,
number
,
run
,
user_id
,
emit_signals
=
emit_signals
,
fields
=
kwargs
)
else
:
new_course
=
store
.
create_course
(
org
,
number
,
run
,
user_id
,
fields
=
kwargs
)
new_course
=
store
.
create_course
(
org
,
number
,
run
,
user_id
,
emit_signals
=
emit_signals
,
fields
=
kwargs
)
last_course
.
loc
=
new_course
.
location
return
new_course
...
...
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