Commit c41f607a by Braden MacDonald Committed by E. Kolpakov

Remove unused method, apply fixes needed after latest rebase

parent 5f5b41d0
...@@ -11,7 +11,6 @@ from xmodule.modulestore import ModuleStoreEnum ...@@ -11,7 +11,6 @@ from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
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.tests.factories import CourseFactory, ItemFactory
from xmodule.tests import get_test_system
from mock import Mock from mock import Mock
from opaque_keys.edx.locator import CourseKey, LibraryLocator from opaque_keys.edx.locator import CourseKey, LibraryLocator
...@@ -30,6 +29,8 @@ class TestLibraries(ModuleStoreTestCase): ...@@ -30,6 +29,8 @@ class TestLibraries(ModuleStoreTestCase):
self.lib_key = self._create_library() self.lib_key = self._create_library()
self.library = modulestore().get_library(self.lib_key) 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"): def _create_library(self, org="org", library="lib", display_name="Test Library"):
""" """
Helper method used to create a library. Uses the REST API. Helper method used to create a library. Uses the REST API.
...@@ -73,6 +74,17 @@ class TestLibraries(ModuleStoreTestCase): ...@@ -73,6 +74,17 @@ class TestLibraries(ModuleStoreTestCase):
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
return modulestore().get_item(lib_content_block.location) 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): def _update_item(self, usage_key, metadata):
""" """
Helper method: Uses the REST API to update the fields of an XBlock. Helper method: Uses the REST API to update the fields of an XBlock.
...@@ -111,7 +123,7 @@ class TestLibraries(ModuleStoreTestCase): ...@@ -111,7 +123,7 @@ class TestLibraries(ModuleStoreTestCase):
# chosen for a given student. # chosen for a given student.
# In order to be able to call get_child_descriptors(), we must first # In order to be able to call get_child_descriptors(), we must first
# call bind_for_student: # 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.children), num_to_create)
self.assertEqual(len(lc_block.get_child_descriptors()), num_expected) self.assertEqual(len(lc_block.get_child_descriptors()), num_expected)
...@@ -119,15 +131,6 @@ class TestLibraries(ModuleStoreTestCase): ...@@ -119,15 +131,6 @@ class TestLibraries(ModuleStoreTestCase):
""" """
Test that the same student will always see the same selected child block 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: # Create many blocks in the library and add them to a course:
for num in range(0, 8): for num in range(0, 8):
ItemFactory.create( ItemFactory.create(
...@@ -151,7 +154,7 @@ class TestLibraries(ModuleStoreTestCase): ...@@ -151,7 +154,7 @@ class TestLibraries(ModuleStoreTestCase):
return children[0] return children[0]
# Check which child a student will see: # 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 = get_child_of_lc_block(lc_block)
chosen_child_defn_id = chosen_child.definition_locator.definition_id chosen_child_defn_id = chosen_child.definition_locator.definition_id
lc_block.save() lc_block.save()
...@@ -165,7 +168,7 @@ class TestLibraries(ModuleStoreTestCase): ...@@ -165,7 +168,7 @@ class TestLibraries(ModuleStoreTestCase):
""" """
for _ in range(0, 6): # Repeat many times b/c blocks are randomized 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 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) current_child = get_child_of_lc_block(lc_block)
self.assertEqual(current_child.location, chosen_child.location) self.assertEqual(current_child.location, chosen_child.location)
self.assertEqual(current_child.data, chosen_child.data) self.assertEqual(current_child.data, chosen_child.data)
......
...@@ -28,7 +28,7 @@ class LibraryToolsService(object): ...@@ -28,7 +28,7 @@ class LibraryToolsService(object):
assert library_key.version_guid is None assert library_key.version_guid is None
try: 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: except ItemNotFoundError:
return None return None
...@@ -44,16 +44,6 @@ class LibraryToolsService(object): ...@@ -44,16 +44,6 @@ class LibraryToolsService(object):
return library.location.library_key.version_guid return library.location.library_key.version_guid
return None 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): 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 This method is to be used when any of the libraries that a LibraryContentModule
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment