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
c41f607a
Commit
c41f607a
authored
Jan 02, 2015
by
Braden MacDonald
Committed by
E. Kolpakov
Jan 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused method, apply fixes needed after latest rebase
parent
5f5b41d0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
24 deletions
+17
-24
cms/djangoapps/contentstore/tests/test_libraries.py
+16
-13
common/lib/xmodule/xmodule/library_tools.py
+1
-11
No files found.
cms/djangoapps/contentstore/tests/test_libraries.py
View file @
c41f607a
...
...
@@ -11,7 +11,6 @@ from xmodule.modulestore import ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.tests
import
get_test_system
from
mock
import
Mock
from
opaque_keys.edx.locator
import
CourseKey
,
LibraryLocator
...
...
@@ -30,6 +29,8 @@ class TestLibraries(ModuleStoreTestCase):
self
.
lib_key
=
self
.
_create_library
()
self
.
library
=
modulestore
()
.
get_library
(
self
.
lib_key
)
self
.
session_data
=
{}
# Used by _bind_module
def
_create_library
(
self
,
org
=
"org"
,
library
=
"lib"
,
display_name
=
"Test Library"
):
"""
Helper method used to create a library. Uses the REST API.
...
...
@@ -73,6 +74,17 @@ class TestLibraries(ModuleStoreTestCase):
self
.
assertEqual
(
response
.
status_code
,
200
)
return
modulestore
()
.
get_item
(
lib_content_block
.
location
)
def
_bind_module
(
self
,
descriptor
,
user
=
None
):
"""
Helper to use the CMS's module system so we can access student-specific fields.
"""
if
user
is
None
:
user
=
self
.
user
if
user
not
in
self
.
session_data
:
self
.
session_data
[
user
]
=
{}
request
=
Mock
(
user
=
user
,
session
=
self
.
session_data
[
user
])
_load_preview_module
(
request
,
descriptor
)
# pylint: disable=protected-access
def
_update_item
(
self
,
usage_key
,
metadata
):
"""
Helper method: Uses the REST API to update the fields of an XBlock.
...
...
@@ -111,7 +123,7 @@ class TestLibraries(ModuleStoreTestCase):
# chosen for a given student.
# In order to be able to call get_child_descriptors(), we must first
# call bind_for_student:
lc_block
.
bind_for_student
(
get_test_system
(),
lc_block
.
_field_data
)
# pylint: disable=protected-access
self
.
_bind_module
(
lc_block
)
self
.
assertEqual
(
len
(
lc_block
.
children
),
num_to_create
)
self
.
assertEqual
(
len
(
lc_block
.
get_child_descriptors
()),
num_expected
)
...
...
@@ -119,15 +131,6 @@ class TestLibraries(ModuleStoreTestCase):
"""
Test that the same student will always see the same selected child block
"""
session_data
=
{}
def
bind_module
(
descriptor
):
"""
Helper to use the CMS's module system so we can access student-specific fields.
"""
request
=
Mock
(
user
=
self
.
user
,
session
=
session_data
)
return
_load_preview_module
(
request
,
descriptor
)
# pylint: disable=protected-access
# Create many blocks in the library and add them to a course:
for
num
in
range
(
0
,
8
):
ItemFactory
.
create
(
...
...
@@ -151,7 +154,7 @@ class TestLibraries(ModuleStoreTestCase):
return
children
[
0
]
# Check which child a student will see:
bind_module
(
lc_block
)
self
.
_
bind_module
(
lc_block
)
chosen_child
=
get_child_of_lc_block
(
lc_block
)
chosen_child_defn_id
=
chosen_child
.
definition_locator
.
definition_id
lc_block
.
save
()
...
...
@@ -165,7 +168,7 @@ class TestLibraries(ModuleStoreTestCase):
"""
for
_
in
range
(
0
,
6
):
# Repeat many times b/c blocks are randomized
lc_block
=
modulestore
()
.
get_item
(
lc_block_key
)
# Reload block from the database
bind_module
(
lc_block
)
self
.
_
bind_module
(
lc_block
)
current_child
=
get_child_of_lc_block
(
lc_block
)
self
.
assertEqual
(
current_child
.
location
,
chosen_child
.
location
)
self
.
assertEqual
(
current_child
.
data
,
chosen_child
.
data
)
...
...
common/lib/xmodule/xmodule/library_tools.py
View file @
c41f607a
...
...
@@ -28,7 +28,7 @@ class LibraryToolsService(object):
assert
library_key
.
version_guid
is
None
try
:
return
self
.
store
.
get_library
(
library_key
,
remove_version
=
False
)
return
self
.
store
.
get_library
(
library_key
,
remove_version
=
False
,
remove_branch
=
False
)
except
ItemNotFoundError
:
return
None
...
...
@@ -44,16 +44,6 @@ class LibraryToolsService(object):
return
library
.
location
.
library_key
.
version_guid
return
None
def
get_library_display_name
(
self
,
lib_key
):
"""
Get the display_name of the given library.
Returns None if the library does not exist.
"""
library
=
self
.
_get_library
(
lib_key
)
if
library
:
return
library
.
display_name
return
None
def
update_children
(
self
,
dest_block
,
user_id
,
update_db
=
True
):
"""
This method is to be used when any of the libraries that a LibraryContentModule
...
...
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