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
dd788c8f
Commit
dd788c8f
authored
Sep 25, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1107 from edx/dhm/bug_attrs
Ensure location is valid before trying to fetch
parents
fd06640d
3b61d572
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
common/lib/xmodule/xmodule/contentstore/mongo.py
+2
-0
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+8
-2
No files found.
common/lib/xmodule/xmodule/contentstore/mongo.py
View file @
dd788c8f
...
@@ -194,6 +194,8 @@ class MongoContentStore(ContentStore):
...
@@ -194,6 +194,8 @@ class MongoContentStore(ContentStore):
:param location: a c4x asset location
:param location: a c4x asset location
"""
"""
# raises exception if location is not fully specified
Location
.
ensure_fully_specified
(
location
)
for
attr
in
attr_dict
.
iterkeys
():
for
attr
in
attr_dict
.
iterkeys
():
if
attr
in
[
'_id'
,
'md5'
,
'uploadDate'
,
'length'
]:
if
attr
in
[
'_id'
,
'md5'
,
'uploadDate'
,
'length'
]:
raise
AttributeError
(
"{} is a protected attribute."
.
format
(
attr
))
raise
AttributeError
(
"{} is a protected attribute."
.
format
(
attr
))
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
View file @
dd788c8f
...
@@ -22,6 +22,7 @@ from xmodule.contentstore.mongo import MongoContentStore
...
@@ -22,6 +22,7 @@ from xmodule.contentstore.mongo import MongoContentStore
from
xmodule.modulestore.tests.test_modulestore
import
check_path_to_location
from
xmodule.modulestore.tests.test_modulestore
import
check_path_to_location
from
IPython.testing.nose_assert_methods
import
assert_in
,
assert_not_in
from
IPython.testing.nose_assert_methods
import
assert_in
,
assert_not_in
from
xmodule.exceptions
import
NotFoundError
from
xmodule.exceptions
import
NotFoundError
from
xmodule.modulestore.exceptions
import
InsufficientSpecificationError
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -227,11 +228,11 @@ class TestMongoModuleStore(object):
...
@@ -227,11 +228,11 @@ class TestMongoModuleStore(object):
TestMongoModuleStore
.
content_store
.
set_attrs
(
content
[
'_id'
],
{
'miscel'
:
99
})
TestMongoModuleStore
.
content_store
.
set_attrs
(
content
[
'_id'
],
{
'miscel'
:
99
})
assert_equals
(
TestMongoModuleStore
.
content_store
.
get_attr
(
content
[
'_id'
],
'miscel'
),
99
)
assert_equals
(
TestMongoModuleStore
.
content_store
.
get_attr
(
content
[
'_id'
],
'miscel'
),
99
)
assert_raises
(
assert_raises
(
AttributeError
,
TestMongoModuleStore
.
content_store
.
set_attr
,
course_content
[
0
],
AttributeError
,
TestMongoModuleStore
.
content_store
.
set_attr
,
course_content
[
0
]
[
'_id'
]
,
'md5'
,
'ff1532598830e3feac91c2449eaa60d6'
'md5'
,
'ff1532598830e3feac91c2449eaa60d6'
)
)
assert_raises
(
assert_raises
(
AttributeError
,
TestMongoModuleStore
.
content_store
.
set_attrs
,
course_content
[
0
],
AttributeError
,
TestMongoModuleStore
.
content_store
.
set_attrs
,
course_content
[
0
]
[
'_id'
]
,
{
'foo'
:
9
,
'md5'
:
'ff1532598830e3feac91c2449eaa60d6'
}
{
'foo'
:
9
,
'md5'
:
'ff1532598830e3feac91c2449eaa60d6'
}
)
)
assert_raises
(
assert_raises
(
...
@@ -253,6 +254,11 @@ class TestMongoModuleStore(object):
...
@@ -253,6 +254,11 @@ class TestMongoModuleStore(object):
Location
(
'bogus'
,
'bogus'
,
'bogus'
,
'asset'
,
'bogus'
),
Location
(
'bogus'
,
'bogus'
,
'bogus'
,
'asset'
,
'bogus'
),
{
'displayname'
:
'hello'
}
{
'displayname'
:
'hello'
}
)
)
assert_raises
(
InsufficientSpecificationError
,
TestMongoModuleStore
.
content_store
.
set_attrs
,
Location
(
'bogus'
,
'bogus'
,
'bogus'
,
'asset'
,
None
),
{
'displayname'
:
'hello'
}
)
class
TestMongoKeyValueStore
(
object
):
class
TestMongoKeyValueStore
(
object
):
...
...
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