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
944d2d61
Commit
944d2d61
authored
May 16, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure to get the correct modulestore on delete (static tabs do not exist in draft modulestore).
#324
parent
fca63f06
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
34 deletions
+62
-34
cms/djangoapps/contentstore/tests/test_contentstore.py
+28
-28
cms/djangoapps/contentstore/tests/test_course_settings.py
+1
-2
cms/djangoapps/contentstore/tests/test_item.py
+29
-0
cms/djangoapps/contentstore/views/item.py
+1
-1
cms/envs/test.py
+1
-1
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
+2
-2
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
944d2d61
...
...
@@ -74,7 +74,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
client
.
login
(
username
=
uname
,
password
=
password
)
def
check_edit_unit
(
self
,
test_course_name
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
test_course_name
])
import_from_xml
(
modulestore
(
'direct'
),
'common/test/data/'
,
[
test_course_name
])
for
descriptor
in
modulestore
()
.
get_items
(
Location
(
None
,
None
,
'vertical'
,
None
,
None
)):
print
"Checking "
,
descriptor
.
location
.
url
()
...
...
@@ -101,7 +101,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
Unfortunately, None = published for the revision field, so get_items() would return
both draft and non-draft copies.
'''
store
=
modulestore
()
store
=
modulestore
(
'direct'
)
draft_store
=
modulestore
(
'draft'
)
import_from_xml
(
store
,
'common/test/data/'
,
[
'simple'
])
...
...
@@ -128,7 +128,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
module as 'own-metadata' when publishing. Also verifies the metadata inheritance is
properly computed
'''
store
=
modulestore
()
store
=
modulestore
(
'direct'
)
draft_store
=
modulestore
(
'draft'
)
import_from_xml
(
store
,
'common/test/data/'
,
[
'simple'
])
...
...
@@ -186,7 +186,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
assertEqual
(
html_module
.
lms
.
graceperiod
,
new_graceperiod
)
def
test_get_depth_with_drafts
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'simple'
])
import_from_xml
(
modulestore
(
'direct'
),
'common/test/data/'
,
[
'simple'
])
course
=
modulestore
(
'draft'
)
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'simple'
,
'course'
,
'2012_Fall'
,
None
]),
...
...
@@ -221,17 +221,17 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
assertEqual
(
num_drafts
,
1
)
def
test_import_textbook_as_content_element
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'full'
])
course
=
module_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'full'
,
'course'
,
'6.002_Spring_2012'
,
None
]))
self
.
assertGreater
(
len
(
course
.
textbooks
),
0
)
def
test_static_tab_reordering
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'full'
])
course
=
module_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'full'
,
'course'
,
'6.002_Spring_2012'
,
None
]))
# reverse the ordering
...
...
@@ -253,10 +253,8 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
assertEqual
(
reverse_tabs
,
course_tabs
)
def
test_import_polls
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
found
=
False
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'full'
])
items
=
module_store
.
get_items
([
'i4x'
,
'edX'
,
'full'
,
'poll_question'
,
None
,
None
])
found
=
len
(
items
)
>
0
...
...
@@ -270,9 +268,8 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
assertGreater
(
err_cnt
,
0
)
def
test_delete
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
direct_store
=
modulestore
(
'direct'
)
import_from_xml
(
direct_store
,
'common/test/data/'
,
[
'full'
])
sequential
=
direct_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'full'
,
'sequential'
,
'Administrivia_and_Circuit_Elements'
,
None
]))
...
...
@@ -306,8 +303,9 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
This test case verifies that a course can use specialized override for about data, e.g. /about/Fall_2012/effort.html
while there is a base definition in /about/effort.html
'''
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'full'
])
effort
=
module_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'full'
,
'about'
,
'effort'
,
None
]))
self
.
assertEqual
(
effort
.
data
,
'6 hours'
)
...
...
@@ -316,9 +314,8 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
assertEqual
(
effort
.
data
,
'TBD'
)
def
test_remove_hide_progress_tab
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'full'
])
source_location
=
CourseDescriptor
.
id_to_location
(
'edX/full/6.002_Spring_2012'
)
course
=
module_store
.
get_item
(
source_location
)
...
...
@@ -333,14 +330,14 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
'display_name'
:
'Robot Super Course'
,
}
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'full'
])
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
course_data
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
data
=
parse_json
(
resp
)
self
.
assertEqual
(
data
[
'id'
],
'i4x://MITx/999/course/Robot_Super_Course'
)
module_store
=
modulestore
(
'direct'
)
content_store
=
contentstore
()
source_location
=
CourseDescriptor
.
id_to_location
(
'edX/full/6.002_Spring_2012'
)
...
...
@@ -365,9 +362,9 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
assertEqual
(
resp
.
status_code
,
400
)
def
test_delete_course
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'full'
])
content_store
=
contentstore
()
location
=
CourseDescriptor
.
id_to_location
(
'edX/full/6.002_Spring_2012'
)
...
...
@@ -523,8 +520,9 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
assertContains
(
resp
,
'/c4x/edX/full/asset/handouts_schematic_tutorial.pdf'
)
def
test_prefetch_children
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'full'
])
location
=
CourseDescriptor
.
id_to_location
(
'edX/full/6.002_Spring_2012'
)
wrapper
=
MongoCollectionFindWrapper
(
module_store
.
collection
.
find
)
...
...
@@ -736,7 +734,7 @@ class ContentStoreTest(ModuleStoreTestCase):
Import and walk through some common URL endpoints. This just verifies non-500 and no other
correct behavior, so it is not a deep test
"""
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'simple'
])
import_from_xml
(
modulestore
(
'direct'
),
'common/test/data/'
,
[
'simple'
])
loc
=
Location
([
'i4x'
,
'edX'
,
'simple'
,
'course'
,
'2012_Fall'
,
None
])
resp
=
self
.
client
.
get
(
reverse
(
'course_index'
,
kwargs
=
{
'org'
:
loc
.
org
,
...
...
@@ -838,9 +836,11 @@ class ContentStoreTest(ModuleStoreTestCase):
json
.
dumps
({
'id'
:
del_loc
.
url
()}),
"application/json"
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
def
test_import_metadata_with_attempts_empty_string
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'simple'
])
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'simple'
])
did_load_item
=
False
try
:
module_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'simple'
,
'problem'
,
'ps01-simple'
,
None
]))
...
...
@@ -852,8 +852,9 @@ class ContentStoreTest(ModuleStoreTestCase):
self
.
assertTrue
(
did_load_item
)
def
test_forum_id_generation
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'full'
])
new_component_location
=
Location
(
'i4x'
,
'edX'
,
'full'
,
'discussion'
,
'new_component'
)
source_template_location
=
Location
(
'i4x'
,
'edx'
,
'templates'
,
'discussion'
,
'Discussion_Tag'
)
...
...
@@ -865,9 +866,8 @@ class ContentStoreTest(ModuleStoreTestCase):
self
.
assertNotEquals
(
new_discussion_item
.
discussion_id
,
'$$GUID$$'
)
def
test_update_modulestore_signal_did_fire
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'full'
])
try
:
module_store
.
modulestore_update_signal
=
Signal
(
providing_args
=
[
'modulestore'
,
'course_id'
,
'location'
])
...
...
@@ -891,9 +891,9 @@ class ContentStoreTest(ModuleStoreTestCase):
self
.
assertTrue
(
self
.
got_signal
)
def
test_metadata_inheritance
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'full'
])
course
=
module_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'full'
,
'course'
,
'6.002_Spring_2012'
,
None
]))
verticals
=
module_store
.
get_items
([
'i4x'
,
'edX'
,
'full'
,
'vertical'
,
None
,
None
])
...
...
cms/djangoapps/contentstore/tests/test_course_settings.py
View file @
944d2d61
...
...
@@ -17,7 +17,6 @@ from xmodule.modulestore.tests.factories import CourseFactory
from
models.settings.course_metadata
import
CourseMetadata
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
xmodule.modulestore.django
import
modulestore
from
xmodule.fields
import
Date
...
...
@@ -256,7 +255,7 @@ class CourseMetadataEditingTest(CourseTestCase):
def
setUp
(
self
):
CourseTestCase
.
setUp
(
self
)
# add in the full class too
import_from_xml
(
modulestore
(
),
'common/test/data/'
,
[
'full'
])
import_from_xml
(
get_modulestore
(
self
.
course_location
),
'common/test/data/'
,
[
'full'
])
self
.
fullcourse_location
=
Location
([
'i4x'
,
'edX'
,
'full'
,
'course'
,
'6.002_Spring_2012'
,
None
])
def
test_fetch_initial_fields
(
self
):
...
...
cms/djangoapps/contentstore/tests/test_item.py
0 → 100644
View file @
944d2d61
from
contentstore.utils
import
get_modulestore
,
get_url_reverse
from
contentstore.tests.test_course_settings
import
CourseTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
django.core.urlresolvers
import
reverse
class
DeleteItem
(
CourseTestCase
):
def
setUp
(
self
):
""" Creates the test course with a static page in it. """
super
(
DeleteItem
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
(
org
=
'mitX'
,
number
=
'333'
,
display_name
=
'Dummy Course'
)
def
testDeleteStaticPage
(
self
):
# Add static tab
data
=
{
'parent_location'
:
'i4x://mitX/333/course/Dummy_Course'
,
'template'
:
'i4x://edx/templates/static_tab/Empty'
}
resp
=
self
.
client
.
post
(
reverse
(
'clone_item'
),
data
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# Now delete it. There was a bug that the delete was failing (static tabs do not exist in draft modulestore).
resp
=
self
.
client
.
post
(
reverse
(
'delete_item'
),
resp
.
content
,
"application/json"
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
cms/djangoapps/contentstore/views/item.py
View file @
944d2d61
...
...
@@ -113,7 +113,7 @@ def delete_item(request):
delete_children
=
request
.
POST
.
get
(
'delete_children'
,
False
)
delete_all_versions
=
request
.
POST
.
get
(
'delete_all_versions'
,
False
)
store
=
modulestore
(
)
store
=
get_modulestore
(
item_location
)
item
=
store
.
get_item
(
item_location
)
...
...
cms/envs/test.py
View file @
944d2d61
...
...
@@ -48,7 +48,7 @@ MODULESTORE_OPTIONS = {
MODULESTORE
=
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.mongo.MongoModuleStore'
,
'ENGINE'
:
'xmodule.modulestore.mongo.
Draft
MongoModuleStore'
,
'OPTIONS'
:
MODULESTORE_OPTIONS
},
'direct'
:
{
...
...
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
View file @
944d2d61
...
...
@@ -31,11 +31,11 @@ class ModuleStoreTestCase(TestCase):
@staticmethod
def
load_templates_if_necessary
():
'''
Load templates into the modulestore only if they do not already exist.
Load templates into the
direct
modulestore only if they do not already exist.
We need the templates, because they are copied to create
XModules such as sections and problems
'''
modulestore
=
xmodule
.
modulestore
.
django
.
modulestore
()
modulestore
=
xmodule
.
modulestore
.
django
.
modulestore
(
'direct'
)
# Count the number of templates
query
=
{
"_id.course"
:
"templates"
}
...
...
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