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
c0ee1940
Commit
c0ee1940
authored
Sep 05, 2014
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pylint issues in test_mixed_modulestore.py.
parent
9c942d7e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
16 deletions
+30
-16
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+30
-16
No files found.
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
c0ee1940
# pylint: disable=no-member
"""
Unit tests for the Mixed Modulestore, with DDT for the various stores (Split, Draft, XML)
"""
import
datetime
import
ddt
import
itertools
...
...
@@ -92,7 +96,7 @@ class TestMixedModuleStore(unittest.TestCase):
]
}
def
_compare
IgnoreV
ersion
(
self
,
loc1
,
loc2
,
msg
=
None
):
def
_compare
_ignore_v
ersion
(
self
,
loc1
,
loc2
,
msg
=
None
):
"""
AssertEqual replacement for CourseLocator
"""
...
...
@@ -114,8 +118,8 @@ class TestMixedModuleStore(unittest.TestCase):
self
.
addCleanup
(
self
.
connection
.
close
)
super
(
TestMixedModuleStore
,
self
)
.
setUp
()
self
.
addTypeEqualityFunc
(
BlockUsageLocator
,
'_compare
IgnoreV
ersion'
)
self
.
addTypeEqualityFunc
(
CourseLocator
,
'_compare
IgnoreV
ersion'
)
self
.
addTypeEqualityFunc
(
BlockUsageLocator
,
'_compare
_ignore_v
ersion'
)
self
.
addTypeEqualityFunc
(
CourseLocator
,
'_compare
_ignore_v
ersion'
)
# define attrs which get set in initdb to quell pylint
self
.
writable_chapter_location
=
self
.
store
=
self
.
fake_location
=
self
.
xml_chapter_location
=
None
self
.
course_locations
=
[]
...
...
@@ -123,7 +127,7 @@ class TestMixedModuleStore(unittest.TestCase):
self
.
user_id
=
ModuleStoreEnum
.
UserID
.
test
# pylint: disable=invalid-name
def
_create_course
(
self
,
default
,
course_key
):
def
_create_course
(
self
,
course_key
):
"""
Create a course w/ one item in the persistence store using the given course & item location.
"""
...
...
@@ -187,6 +191,9 @@ class TestMixedModuleStore(unittest.TestCase):
]
def
create_sub_tree
(
parent
,
block_info
):
"""
recursive function that creates the given block and its descendants
"""
block
=
self
.
store
.
create_child
(
self
.
user_id
,
parent
.
location
,
block_info
.
category
,
block_id
=
block_info
.
display_name
,
...
...
@@ -207,6 +214,9 @@ class TestMixedModuleStore(unittest.TestCase):
return
self
.
course_locations
[
string
]
.
course_key
def
_initialize_mixed
(
self
):
"""
initializes the mixed modulestore
"""
self
.
store
=
MixedModuleStore
(
None
,
create_modulestore_instance
=
create_modulestore_instance
,
**
self
.
options
)
self
.
addCleanup
(
self
.
store
.
close_all_connections
)
...
...
@@ -239,7 +249,7 @@ class TestMixedModuleStore(unittest.TestCase):
self
.
xml_chapter_location
=
self
.
course_locations
[
self
.
XML_COURSEID1
]
.
replace
(
category
=
'chapter'
,
name
=
'Overview'
)
self
.
_create_course
(
default
,
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
course_key
)
self
.
_create_course
(
self
.
course_locations
[
self
.
MONGO_COURSEID
]
.
course_key
)
@ddt.data
(
'draft'
,
'split'
)
def
test_get_modulestore_type
(
self
,
default_ms
):
...
...
@@ -448,6 +458,9 @@ class TestMixedModuleStore(unittest.TestCase):
self
.
assertFalse
(
self
.
store
.
has_changes
(
component
))
def
_has_changes
(
self
,
location
):
"""
Helper function that loads the item before calling has_changes
"""
return
self
.
store
.
has_changes
(
self
.
store
.
get_item
(
location
))
def
setup_has_changes
(
self
,
default_ms
):
...
...
@@ -706,7 +719,7 @@ class TestMixedModuleStore(unittest.TestCase):
# create and delete a private vertical with private children
private_vert
=
self
.
store
.
create_child
(
# don't use course_location as it may not be the repr
self
.
user_id
,
self
.
course_locations
[
self
.
MONGO_COURSEID
],
'vertical'
,
block_id
=
'publish'
self
.
user_id
,
self
.
course_locations
[
self
.
MONGO_COURSEID
],
'vertical'
,
block_id
=
'publish'
)
private_leaf
=
self
.
store
.
create_child
(
self
.
user_id
,
private_vert
.
location
,
'html'
,
block_id
=
'bug_leaf'
...
...
@@ -748,13 +761,12 @@ class TestMixedModuleStore(unittest.TestCase):
published_courses
=
self
.
store
.
get_courses
(
remove_branch
=
True
)
self
.
assertEquals
([
c
.
id
for
c
in
draft_courses
],
[
c
.
id
for
c
in
published_courses
])
def
test_xml_get_courses
(
self
):
"""
Test that the xml modulestore only loaded the courses from the maps.
"""
self
.
initdb
(
'draft'
)
xml_store
=
self
.
store
.
_get_modulestore_by_type
(
ModuleStoreEnum
.
Type
.
xml
)
xml_store
=
self
.
store
.
_get_modulestore_by_type
(
ModuleStoreEnum
.
Type
.
xml
)
# pylint: disable=protected-access
courses
=
xml_store
.
get_courses
()
self
.
assertEqual
(
len
(
courses
),
2
)
course_ids
=
[
course
.
id
for
course
in
courses
]
...
...
@@ -768,7 +780,7 @@ class TestMixedModuleStore(unittest.TestCase):
Test that the xml modulestore doesn't allow write ops.
"""
self
.
initdb
(
'draft'
)
xml_store
=
self
.
store
.
_get_modulestore_by_type
(
ModuleStoreEnum
.
Type
.
xml
)
xml_store
=
self
.
store
.
_get_modulestore_by_type
(
ModuleStoreEnum
.
Type
.
xml
)
# pylint: disable=protected-access
# the important thing is not which exception it raises but that it raises an exception
with
self
.
assertRaises
(
AttributeError
):
xml_store
.
create_course
(
"org"
,
"course"
,
"run"
,
self
.
user_id
)
...
...
@@ -811,6 +823,9 @@ class TestMixedModuleStore(unittest.TestCase):
self
.
assertEqual
(
parent
,
self
.
course_locations
[
self
.
XML_COURSEID1
])
def
verify_get_parent_locations_results
(
self
,
expected_results
):
"""
Verifies the results of calling get_parent_locations matches expected_results.
"""
for
child_location
,
parent_location
,
revision
in
expected_results
:
self
.
assertEqual
(
parent_location
,
...
...
@@ -1107,7 +1122,7 @@ class TestMixedModuleStore(unittest.TestCase):
self
.
store
.
publish
(
self
.
course
.
location
,
self
.
user_id
)
# test that problem "problem_x1a_1" has only one published parent
mongo_store
=
self
.
store
.
_get_modulestore_for_courseid
(
course_id
)
mongo_store
=
self
.
store
.
_get_modulestore_for_courseid
(
course_id
)
# pylint: disable=protected-access
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
published_only
,
course_id
):
parent
=
mongo_store
.
get_parent_location
(
self
.
problem_x1a_1
)
self
.
assertEqual
(
parent
,
self
.
vertical_x1a
)
...
...
@@ -1353,10 +1368,8 @@ class TestMixedModuleStore(unittest.TestCase):
after_create
=
datetime
.
datetime
.
now
(
UTC
)
# Verify that all nodes were last edited in the past by create_user
[
for
block
in
[
component
,
child
,
sibling
]:
check_node
(
block
.
location
,
None
,
after_create
,
self
.
user_id
,
None
,
after_create
,
self
.
user_id
)
for
block
in
[
component
,
child
,
sibling
]
]
# Change the component, then check that there now are changes
component
.
display_name
=
'Changed Display Name'
...
...
@@ -1368,7 +1381,6 @@ class TestMixedModuleStore(unittest.TestCase):
# but child didn't change
check_node
(
child
.
location
,
None
,
after_create
,
self
.
user_id
,
None
,
after_create
,
self
.
user_id
)
# Change the child
child
=
self
.
store
.
get_item
(
child
.
location
)
child
.
display_name
=
'Changed Display Name'
...
...
@@ -1642,11 +1654,13 @@ class TestMixedModuleStore(unittest.TestCase):
assertNumProblems
(
problem_original_name
,
0
)
def
verify_default_store
(
self
,
store_type
):
# verify default_store property
"""
Verifies the default_store property
"""
self
.
assertEquals
(
self
.
store
.
default_modulestore
.
get_modulestore_type
(),
store_type
)
# verify internal helper method
store
=
self
.
store
.
_get_modulestore_for_courseid
()
store
=
self
.
store
.
_get_modulestore_for_courseid
()
# pylint: disable=protected-access
self
.
assertEquals
(
store
.
get_modulestore_type
(),
store_type
)
# verify store used for creating a 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