Revert "remove location of item from loc_mapper and cache"

This reverts commit d2b8b4f0dd.
This commit is contained in:
zubair-arbi
2014-04-29 18:31:27 +05:00
parent b95966e959
commit 643e82ace3
3 changed files with 32 additions and 109 deletions

View File

@@ -125,9 +125,6 @@ def xblock_handler(request, tag=None, package_id=None, branch=None, version_guid
delete_children = str_to_bool(request.REQUEST.get('recurse', 'False'))
delete_all_versions = str_to_bool(request.REQUEST.get('all_versions', 'False'))
# delete item from loc_mapper and cache
loc_mapper().delete_item_mapping(locator, old_location)
return _delete_item_at_location(old_location, delete_children, delete_all_versions, request.user)
else: # Since we have a package_id, we are updating an existing xblock.
if block == 'handouts' and old_location is None:

View File

@@ -3,7 +3,6 @@
import json
from datetime import datetime
import ddt
from uuid import uuid4
from mock import patch
from pytz import UTC
@@ -57,10 +56,7 @@ class ItemTest(CourseTestCase):
parsed = json.loads(response.content)
return parsed['locator']
def create_xblock(self, parent_locator=None, display_name=None, category=None, boilerplate=None, type=None):
"""
Create xblock
"""
def create_xblock(self, parent_locator=None, display_name=None, category=None, boilerplate=None):
data = {
'parent_locator': self.unicode_locator if parent_locator is None else parent_locator,
'category': category
@@ -69,8 +65,6 @@ class ItemTest(CourseTestCase):
data['display_name'] = display_name
if boilerplate is not None:
data['boilerplate'] = boilerplate
if type is not None:
data['type'] = type
return self.client.ajax_post('/xblock', json.dumps(data))
@@ -679,43 +673,6 @@ class TestEditItem(ItemTest):
draft = self.get_item_from_modulestore(self.problem_locator, True)
self.assertNotEqual(draft.data, published.data)
def test_create_delete_discussion_components(self):
"""
Create discussion components and test that they are deleted from loc_mapper on delete
"""
# Test that creating two discussion components with first 3 digit same of uuid will have
# different block_ids (locators)
with patch("uuid.UUID.hex", '987' + uuid4().hex[3:]):
resp = self.create_xblock(parent_locator=self.seq_locator, category='discussion', type='discussion')
self.assertEqual(resp.status_code, 200)
discussion_1_locator = self.response_locator(resp)
discussion_1_draft = self.get_item_from_modulestore(discussion_1_locator, True)
self.assertIsNotNone(discussion_1_draft)
with patch("uuid.UUID.hex", '987' + uuid4().hex[3:]):
resp = self.create_xblock(parent_locator=self.seq_locator, category='discussion', type='discussion')
self.assertEqual(resp.status_code, 200)
discussion_2_locator = self.response_locator(resp)
discussion_2_draft = self.get_item_from_modulestore(discussion_2_locator, True)
self.assertIsNotNone(discussion_2_draft)
self.assertNotEqual(discussion_1_locator, discussion_2_locator)
# now delete first discussion component
resp = self.client.delete('/xblock/' + discussion_1_locator)
self.assertEqual(resp.status_code, 204)
# create a new discussion component and check that it has same locator as first discussion component
# but different id's
with patch("uuid.UUID.hex", '987' + uuid4().hex[3:]):
resp = self.create_xblock(parent_locator=self.seq_locator, category='discussion', type='discussion')
self.assertEqual(resp.status_code, 200)
discussion_3_locator = self.response_locator(resp)
discussion_3_draft = self.get_item_from_modulestore(discussion_3_locator, True)
self.assertIsNotNone(discussion_3_draft)
self.assertEqual(discussion_1_locator, discussion_3_locator)
self.assertNotEqual(discussion_1_draft.id, discussion_3_draft.id)
def test_publish_states_of_nested_xblocks(self):
""" Test publishing of a unit page containing a nested xblock """