From c1789adfd97046d24a486804782696c19d914597 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Tue, 17 Sep 2013 13:58:05 -0400 Subject: [PATCH] Always return a Locator: cases weren't exhaustive. --- common/lib/xmodule/xmodule/modulestore/locator.py | 2 +- .../xmodule/modulestore/tests/test_locators.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/modulestore/locator.py b/common/lib/xmodule/xmodule/modulestore/locator.py index 916a970ad0..dfeafa5e1d 100644 --- a/common/lib/xmodule/xmodule/modulestore/locator.py +++ b/common/lib/xmodule/xmodule/modulestore/locator.py @@ -377,7 +377,7 @@ class BlockUsageLocator(CourseLocator): :param block_locator: """ - if self.course_id and self.version_guid: + if self.version_guid: return BlockUsageLocator(version_guid=self.version_guid, branch=self.branch, usage_id=self.usage_id) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py b/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py index 862b05cd53..05f4d25283 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py @@ -208,6 +208,12 @@ class LocatorTest(TestCase): block=expected_block_ref) self.assertEqual(str(testobj), testurn) self.assertEqual(testobj.url(), 'edx://' + testurn) + agnostic = testobj.version_agnostic() + self.assertIsNone(agnostic.version_guid) + self.check_block_locn_fields(agnostic, 'test_block constructor', + course_id=expected_id, + branch=expected_branch, + block=expected_block_ref) def test_block_constructor_url_version_prefix(self): test_id_loc = '519665f6223ebd6980884f2b' @@ -220,6 +226,14 @@ class LocatorTest(TestCase): block='lab2', version_guid=ObjectId(test_id_loc) ) + agnostic = testobj.version_agnostic() + self.check_block_locn_fields( + agnostic, 'error parsing URL with version and block', + block='lab2', + course_id=None, + version_guid=ObjectId(test_id_loc) + ) + self.assertIsNone(agnostic.course_id) def test_block_constructor_url_kitchen_sink(self): test_id_loc = '519665f6223ebd6980884f2b'