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
42af561a
Commit
42af561a
authored
Aug 21, 2013
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pep8 and pylint for tests of nostatic import
parent
9b26e5bc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
29 deletions
+22
-29
cms/djangoapps/contentstore/management/commands/import.py
+1
-1
cms/djangoapps/contentstore/tests/test_import_nostatic.py
+18
-19
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+0
-1
lms/djangoapps/courseware/tests/test_module_render.py
+3
-8
No files found.
cms/djangoapps/contentstore/management/commands/import.py
View file @
42af561a
...
@@ -18,7 +18,7 @@ class Command(BaseCommand):
...
@@ -18,7 +18,7 @@ class Command(BaseCommand):
make_option
(
'--nostatic'
,
make_option
(
'--nostatic'
,
action
=
'store_true'
,
action
=
'store_true'
,
help
=
'Skip import of static content'
),
help
=
'Skip import of static content'
),
)
)
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
"Execute the command"
"Execute the command"
...
...
cms/djangoapps/contentstore/tests/test_import_nostatic.py
View file @
42af561a
#pylint: disable=E1101
#pylint: disable=E1101
'''
Tests for importing with no static
'''
import
json
import
shutil
import
sys
import
mock
from
django.test.client
import
Client
from
django.test.client
import
Client
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
path
import
path
from
path
import
path
import
copy
import
copy
from
json
import
loads
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
auth.authz
import
add_user_to_creator_group
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore
import
Location
,
mongo
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.contentstore.django
import
contentstore
,
_CONTENTSTORE
from
xmodule.contentstore.django
import
contentstore
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.contentstore.content
import
StaticContent
...
@@ -36,11 +30,20 @@ TEST_DATA_CONTENTSTORE['OPTIONS']['db'] = 'test_xcontent_%s' % uuid4().hex
...
@@ -36,11 +30,20 @@ TEST_DATA_CONTENTSTORE['OPTIONS']['db'] = 'test_xcontent_%s' % uuid4().hex
class
MongoCollectionFindWrapper
(
object
):
class
MongoCollectionFindWrapper
(
object
):
'''
MongoCollectionFindWrapper for testing.
'''
def
__init__
(
self
,
original
):
def
__init__
(
self
,
original
):
"""
intit func
"""
self
.
original
=
original
self
.
original
=
original
self
.
counter
=
0
self
.
counter
=
0
def
find
(
self
,
query
,
*
args
,
**
kwargs
):
def
find
(
self
,
query
,
*
args
,
**
kwargs
):
"""
find func
"""
self
.
counter
=
self
.
counter
+
1
self
.
counter
=
self
.
counter
+
1
return
self
.
original
(
query
,
*
args
,
**
kwargs
)
return
self
.
original
(
query
,
*
args
,
**
kwargs
)
...
@@ -76,7 +79,7 @@ class ContentStoreImportNoStaticTest(ModuleStoreTestCase):
...
@@ -76,7 +79,7 @@ class ContentStoreImportNoStaticTest(ModuleStoreTestCase):
def
load_test_import_course
(
self
):
def
load_test_import_course
(
self
):
'''
'''
Load the standard course used to test imports (for do_import_static=False behavior).
Load the standard course used to test imports (for do_import_static=False behavior).
'''
'''
content_store
=
contentstore
()
content_store
=
contentstore
()
module_store
=
modulestore
(
'direct'
)
module_store
=
modulestore
(
'direct'
)
...
@@ -87,12 +90,11 @@ class ContentStoreImportNoStaticTest(ModuleStoreTestCase):
...
@@ -87,12 +90,11 @@ class ContentStoreImportNoStaticTest(ModuleStoreTestCase):
return
module_store
,
content_store
,
course
,
course_location
return
module_store
,
content_store
,
course
,
course_location
def
test_static_import
(
self
):
def
test_static_import
(
self
):
'''
'''
Stuff in static_import should always be imported into contentstore
Stuff in static_import should always be imported into contentstore
'''
'''
module_store
,
content_store
,
course
,
course_location
=
self
.
load_test_import_course
()
_
,
content_store
,
course
,
course_location
=
self
.
load_test_import_course
()
# make sure we have ONE asset in our contentstore ("should_be_imported.html")
# make sure we have ONE asset in our contentstore ("should_be_imported.html")
all_assets
=
content_store
.
get_all_content_for_course
(
course_location
)
all_assets
=
content_store
.
get_all_content_for_course
(
course_location
)
...
@@ -107,12 +109,11 @@ class ContentStoreImportNoStaticTest(ModuleStoreTestCase):
...
@@ -107,12 +109,11 @@ class ContentStoreImportNoStaticTest(ModuleStoreTestCase):
pass
pass
self
.
assertIsNotNone
(
content
)
self
.
assertIsNotNone
(
content
)
# make sure course.lms.static_asset_path is correct
# make sure course.lms.static_asset_path is correct
print
"static_asset_path = {0}"
.
format
(
course
.
lms
.
static_asset_path
)
print
"static_asset_path = {0}"
.
format
(
course
.
lms
.
static_asset_path
)
self
.
assertEqual
(
course
.
lms
.
static_asset_path
,
'test_import_course'
)
self
.
assertEqual
(
course
.
lms
.
static_asset_path
,
'test_import_course'
)
def
test_asset_import_nostatic
(
self
):
def
test_asset_import_nostatic
(
self
):
'''
'''
This test validates that an image asset is NOT imported when do_import_static=False
This test validates that an image asset is NOT imported when do_import_static=False
...
@@ -123,14 +124,13 @@ class ContentStoreImportNoStaticTest(ModuleStoreTestCase):
...
@@ -123,14 +124,13 @@ class ContentStoreImportNoStaticTest(ModuleStoreTestCase):
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'toy'
],
static_content_store
=
content_store
,
do_import_static
=
False
,
verbose
=
True
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'toy'
],
static_content_store
=
content_store
,
do_import_static
=
False
,
verbose
=
True
)
course_location
=
CourseDescriptor
.
id_to_location
(
'edX/toy/2012_Fall'
)
course_location
=
CourseDescriptor
.
id_to_location
(
'edX/toy/2012_Fall'
)
course
=
module_store
.
get_item
(
course_location
)
module_store
.
get_item
(
course_location
)
# make sure we have NO assets in our contentstore
# make sure we have NO assets in our contentstore
all_assets
=
content_store
.
get_all_content_for_course
(
course_location
)
all_assets
=
content_store
.
get_all_content_for_course
(
course_location
)
print
"len(all_assets)=
%
d"
%
len
(
all_assets
)
print
"len(all_assets)=
%
d"
%
len
(
all_assets
)
self
.
assertEqual
(
len
(
all_assets
),
0
)
self
.
assertEqual
(
len
(
all_assets
),
0
)
def
test_no_static_link_rewrites_on_import
(
self
):
def
test_no_static_link_rewrites_on_import
(
self
):
module_store
=
modulestore
(
'direct'
)
module_store
=
modulestore
(
'direct'
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'toy'
],
do_import_static
=
False
,
verbose
=
True
)
import_from_xml
(
module_store
,
'common/test/data/'
,
[
'toy'
],
do_import_static
=
False
,
verbose
=
True
)
...
@@ -140,4 +140,3 @@ class ContentStoreImportNoStaticTest(ModuleStoreTestCase):
...
@@ -140,4 +140,3 @@ class ContentStoreImportNoStaticTest(ModuleStoreTestCase):
handouts
=
module_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'toy'
,
'html'
,
'toyhtml'
,
None
]))
handouts
=
module_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'toy'
,
'html'
,
'toyhtml'
,
None
]))
self
.
assertIn
(
'/static/'
,
handouts
.
data
)
self
.
assertIn
(
'/static/'
,
handouts
.
data
)
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
42af561a
...
@@ -174,7 +174,6 @@ def import_from_xml(store, data_dir, course_dirs=None,
...
@@ -174,7 +174,6 @@ def import_from_xml(store, data_dir, course_dirs=None,
import_static_content
(
xml_module_store
.
modules
[
course_id
],
course_location
,
course_data_path
,
static_content_store
,
import_static_content
(
xml_module_store
.
modules
[
course_id
],
course_location
,
course_data_path
,
static_content_store
,
_namespace_rename
,
subpath
=
simport
,
verbose
=
verbose
)
_namespace_rename
,
subpath
=
simport
,
verbose
=
verbose
)
# finally loop through all the modules
# finally loop through all the modules
for
module
in
xml_module_store
.
modules
[
course_id
]
.
itervalues
():
for
module
in
xml_module_store
.
modules
[
course_id
]
.
itervalues
():
...
...
lms/djangoapps/courseware/tests/test_module_render.py
View file @
42af561a
...
@@ -83,7 +83,7 @@ class ModuleRenderTestCase(LoginEnrollmentTestCase):
...
@@ -83,7 +83,7 @@ class ModuleRenderTestCase(LoginEnrollmentTestCase):
# See if the url got rewritten to the target link
# See if the url got rewritten to the target link
# note if the URL mapping changes then this assertion will break
# note if the URL mapping changes then this assertion will break
self
.
assertIn
(
'/courses/'
+
self
.
course_id
+
'/jump_to_id/vertical_test'
,
html
)
self
.
assertIn
(
'/courses/'
+
self
.
course_id
+
'/jump_to_id/vertical_test'
,
html
)
def
test_modx_dispatch
(
self
):
def
test_modx_dispatch
(
self
):
self
.
assertRaises
(
Http404
,
render
.
modx_dispatch
,
'dummy'
,
'dummy'
,
self
.
assertRaises
(
Http404
,
render
.
modx_dispatch
,
'dummy'
,
'dummy'
,
...
@@ -139,7 +139,6 @@ class ModuleRenderTestCase(LoginEnrollmentTestCase):
...
@@ -139,7 +139,6 @@ class ModuleRenderTestCase(LoginEnrollmentTestCase):
self
.
course_id
self
.
course_id
)
)
def
test_xqueue_callback_success
(
self
):
def
test_xqueue_callback_success
(
self
):
"""
"""
Test for happy-path xqueue_callback
Test for happy-path xqueue_callback
...
@@ -356,10 +355,9 @@ class TestHtmlModifiers(ModuleStoreTestCase):
...
@@ -356,10 +355,9 @@ class TestHtmlModifiers(ModuleStoreTestCase):
result_fragment
.
content
result_fragment
.
content
)
)
def
test_static_asset_path_use
(
self
):
def
test_static_asset_path_use
(
self
):
'''
'''
when a course is loaded with do_import_static=False (see xml_importer.py), then
when a course is loaded with do_import_static=False (see xml_importer.py), then
static_asset_path is set as an lms kv in course. That should make static paths
static_asset_path is set as an lms kv in course. That should make static paths
not be mangled (ie not changed to c4x://).
not be mangled (ie not changed to c4x://).
'''
'''
...
@@ -374,7 +372,6 @@ class TestHtmlModifiers(ModuleStoreTestCase):
...
@@ -374,7 +372,6 @@ class TestHtmlModifiers(ModuleStoreTestCase):
result_fragment
=
module
.
runtime
.
render
(
module
,
None
,
'student_view'
)
result_fragment
=
module
.
runtime
.
render
(
module
,
None
,
'student_view'
)
self
.
assertIn
(
'href="/static/toy_course_dir'
,
result_fragment
.
content
)
self
.
assertIn
(
'href="/static/toy_course_dir'
,
result_fragment
.
content
)
def
test_course_image
(
self
):
def
test_course_image
(
self
):
url
=
course_image_url
(
self
.
course
)
url
=
course_image_url
(
self
.
course
)
self
.
assertTrue
(
url
.
startswith
(
'/c4x/'
))
self
.
assertTrue
(
url
.
startswith
(
'/c4x/'
))
...
@@ -384,14 +381,12 @@ class TestHtmlModifiers(ModuleStoreTestCase):
...
@@ -384,14 +381,12 @@ class TestHtmlModifiers(ModuleStoreTestCase):
self
.
assertTrue
(
url
.
startswith
(
'/static/toy_course_dir/'
))
self
.
assertTrue
(
url
.
startswith
(
'/static/toy_course_dir/'
))
self
.
course
.
lms
.
static_asset_path
=
""
self
.
course
.
lms
.
static_asset_path
=
""
def
test_get_course_info_section
(
self
):
def
test_get_course_info_section
(
self
):
self
.
course
.
lms
.
static_asset_path
=
"toy_course_dir"
self
.
course
.
lms
.
static_asset_path
=
"toy_course_dir"
handouts
=
get_course_info_section
(
self
.
request
,
self
.
course
,
"handouts"
)
get_course_info_section
(
self
.
request
,
self
.
course
,
"handouts"
)
# TODO: check handouts output...right now test course seems to have no such content
# TODO: check handouts output...right now test course seems to have no such content
# at least this makes sure get_course_info_section returns without exception
# at least this makes sure get_course_info_section returns without exception
def
test_course_link_rewrite
(
self
):
def
test_course_link_rewrite
(
self
):
module
=
render
.
get_module
(
module
=
render
.
get_module
(
self
.
user
,
self
.
user
,
...
...
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