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
OpenEdx
edx-platform
Commits
d1dc8c91
Commit
d1dc8c91
authored
Feb 07, 2014
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add README to tilde fixture, fix pylint/pep8 issues
parent
83b0eda4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
7 deletions
+27
-7
common/lib/xmodule/xmodule/modulestore/tests/test_xml.py
+9
-2
common/lib/xmodule/xmodule/modulestore/xml.py
+4
-3
common/lib/xmodule/xmodule/tests/test_import_static.py
+5
-2
common/test/data/tilde/README.md
+9
-0
No files found.
common/lib/xmodule/xmodule/modulestore/tests/test_xml.py
View file @
d1dc8c91
"""
Tests around our XML modulestore, including importing
well-formed and not-well-formed XML.
"""
import
os.path
import
os.path
import
unittest
import
unittest
from
glob
import
glob
from
glob
import
glob
...
@@ -12,6 +16,7 @@ from xmodule.modulestore import Location, XML_MODULESTORE_TYPE
...
@@ -12,6 +16,7 @@ from xmodule.modulestore import Location, XML_MODULESTORE_TYPE
from
.test_modulestore
import
check_path_to_location
from
.test_modulestore
import
check_path_to_location
from
xmodule.tests
import
DATA_DIR
from
xmodule.tests
import
DATA_DIR
def
glob_tildes_at_end
(
path
):
def
glob_tildes_at_end
(
path
):
"""
"""
A wrapper for the `glob.glob` function, but it always returns
A wrapper for the `glob.glob` function, but it always returns
...
@@ -24,6 +29,9 @@ def glob_tildes_at_end(path):
...
@@ -24,6 +29,9 @@ def glob_tildes_at_end(path):
class
TestXMLModuleStore
(
unittest
.
TestCase
):
class
TestXMLModuleStore
(
unittest
.
TestCase
):
"""
Test around the XML modulestore
"""
def
test_path_to_location
(
self
):
def
test_path_to_location
(
self
):
"""Make sure that path_to_location works properly"""
"""Make sure that path_to_location works properly"""
...
@@ -57,7 +65,7 @@ class TestXMLModuleStore(unittest.TestCase):
...
@@ -57,7 +65,7 @@ class TestXMLModuleStore(unittest.TestCase):
assert
errors
==
[]
assert
errors
==
[]
@patch
(
"xmodule.modulestore.xml.glob.glob"
,
side_effect
=
glob_tildes_at_end
)
@patch
(
"xmodule.modulestore.xml.glob.glob"
,
side_effect
=
glob_tildes_at_end
)
def
test_tilde_files_ignored
(
self
,
fake_glob
):
def
test_tilde_files_ignored
(
self
,
_
fake_glob
):
modulestore
=
XMLModuleStore
(
DATA_DIR
,
course_dirs
=
[
'tilde'
],
load_error_modules
=
False
)
modulestore
=
XMLModuleStore
(
DATA_DIR
,
course_dirs
=
[
'tilde'
],
load_error_modules
=
False
)
course_module
=
modulestore
.
modules
[
'edX/tilde/2012_Fall'
]
course_module
=
modulestore
.
modules
[
'edX/tilde/2012_Fall'
]
about_location
=
Location
({
about_location
=
Location
({
...
@@ -70,4 +78,3 @@ class TestXMLModuleStore(unittest.TestCase):
...
@@ -70,4 +78,3 @@ class TestXMLModuleStore(unittest.TestCase):
about_module
=
course_module
[
about_location
]
about_module
=
course_module
[
about_location
]
self
.
assertIn
(
"GREEN"
,
about_module
.
data
)
self
.
assertIn
(
"GREEN"
,
about_module
.
data
)
self
.
assertNotIn
(
"RED"
,
about_module
.
data
)
self
.
assertNotIn
(
"RED"
,
about_module
.
data
)
common/lib/xmodule/xmodule/modulestore/xml.py
View file @
d1dc8c91
...
@@ -405,8 +405,9 @@ class XMLModuleStore(ModuleStoreReadBase):
...
@@ -405,8 +405,9 @@ class XMLModuleStore(ModuleStoreReadBase):
try
:
try
:
course_descriptor
=
self
.
load_course
(
course_dir
,
errorlog
.
tracker
)
course_descriptor
=
self
.
load_course
(
course_dir
,
errorlog
.
tracker
)
except
Exception
as
e
:
except
Exception
as
e
:
msg
=
"ERROR: Failed to load course '{0}': {1}"
.
format
(
course_dir
.
encode
(
"utf-8"
),
msg
=
"ERROR: Failed to load course '{0}': {1}"
.
format
(
unicode
(
e
))
course_dir
.
encode
(
"utf-8"
),
unicode
(
e
)
)
log
.
exception
(
msg
)
log
.
exception
(
msg
)
errorlog
.
tracker
(
msg
)
errorlog
.
tracker
(
msg
)
...
@@ -568,7 +569,7 @@ class XMLModuleStore(ModuleStoreReadBase):
...
@@ -568,7 +569,7 @@ class XMLModuleStore(ModuleStoreReadBase):
if
not
os
.
path
.
isfile
(
filepath
):
if
not
os
.
path
.
isfile
(
filepath
):
continue
continue
if
filepath
.
endswith
(
'~'
):
# skip *~ files
if
filepath
.
endswith
(
'~'
):
# skip *~ files
continue
continue
with
open
(
filepath
)
as
f
:
with
open
(
filepath
)
as
f
:
...
...
common/lib/xmodule/xmodule/tests/test_import_static.py
View file @
d1dc8c91
"""
Tests that check that we ignore the appropriate files when importing courses.
"""
import
unittest
import
unittest
from
path
import
path
from
mock
import
Mock
from
mock
import
Mock
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.xml_importer
import
import_static_content
from
xmodule.modulestore.xml_importer
import
import_static_content
...
@@ -7,8 +9,9 @@ from xmodule.tests import DATA_DIR
...
@@ -7,8 +9,9 @@ from xmodule.tests import DATA_DIR
class
IgnoredFilesTestCase
(
unittest
.
TestCase
):
class
IgnoredFilesTestCase
(
unittest
.
TestCase
):
"Tests for ignored files"
def
test_ignore_tilde_static_files
(
self
):
def
test_ignore_tilde_static_files
(
self
):
course_dir
=
DATA_DIR
/
"tilde"
course_dir
=
DATA_DIR
/
"tilde"
loc
=
Location
(
"edX"
,
"tilde"
,
"Fall_2012"
)
loc
=
Location
(
"edX"
,
"tilde"
,
"Fall_2012"
)
content_store
=
Mock
()
content_store
=
Mock
()
content_store
.
generate_thumbnail
.
return_value
=
(
"content"
,
"location"
)
content_store
.
generate_thumbnail
.
return_value
=
(
"content"
,
"location"
)
...
...
common/test/data/tilde/README.md
0 → 100644
View file @
d1dc8c91
DO NOT DELETE TILDE FILES
This course simulates an export that has been edited by hand, where the editor's
text editor has left behind some backup files (about/index.html~ and
static/example.txt~). Normally, we do not commit files that end with tildes to
the repository, for precisely this reason -- they are backup files, and do
not belong with the content. However, in this case, we
*need*
these backup files
to be committed to the repository, so that we can exercise logic in the codebase
that checks for these sort of editor backup files and skips them on export.
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