本文整理汇总了Python中xmodule.modulestore.locator.BlockUsageLocator.url方法的典型用法代码示例。如果您正苦于以下问题:Python BlockUsageLocator.url方法的具体用法?Python BlockUsageLocator.url怎么用?Python BlockUsageLocator.url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmodule.modulestore.locator.BlockUsageLocator
的用法示例。
在下文中一共展示了BlockUsageLocator.url方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_old_location_helpers
# 需要导入模块: from xmodule.modulestore.locator import BlockUsageLocator [as 别名]
# 或者: from xmodule.modulestore.locator.BlockUsageLocator import url [as 别名]
def test_old_location_helpers(self):
"""
Test the functions intended to help with the conversion from old locations to locators
"""
location_tuple = ('i4x', 'mit', 'eecs.6002x', 'course', 't3_2013')
location = Location(location_tuple)
self.assertEqual(location, Locator.to_locator_or_location(location))
self.assertEqual(location, Locator.to_locator_or_location(location_tuple))
self.assertEqual(location, Locator.to_locator_or_location(list(location_tuple)))
self.assertEqual(location, Locator.to_locator_or_location(location.dict()))
locator = BlockUsageLocator(package_id='foo.bar', branch='alpha', block_id='deep')
self.assertEqual(locator, Locator.to_locator_or_location(locator))
self.assertEqual(locator.as_course_locator(), Locator.to_locator_or_location(locator.as_course_locator()))
self.assertEqual(location, Locator.to_locator_or_location(location.url()))
self.assertEqual(locator, Locator.to_locator_or_location(locator.url()))
self.assertEqual(locator, Locator.to_locator_or_location(locator.__dict__))
asset_location = Location(['c4x', 'mit', 'eecs.6002x', 'asset', 'selfie.jpeg'])
self.assertEqual(asset_location, Locator.to_locator_or_location(asset_location))
self.assertEqual(asset_location, Locator.to_locator_or_location(asset_location.url()))
def_location_url = "defx://version/" + '{:024x}'.format(random.randrange(16 ** 24))
self.assertEqual(DefinitionLocator(def_location_url), Locator.to_locator_or_location(def_location_url))
with self.assertRaises(ValueError):
Locator.to_locator_or_location(22)
with self.assertRaises(ValueError):
Locator.to_locator_or_location("hello.world.not.a.url")
self.assertIsNone(Locator.parse_url("unknown://foo.bar/baz"))
示例2: test_block_constructor
# 需要导入模块: from xmodule.modulestore.locator import BlockUsageLocator [as 别名]
# 或者: from xmodule.modulestore.locator.BlockUsageLocator import url [as 别名]
def test_block_constructor(self):
testurn = 'mit.eecs.6002x;published#HW3'
expected_id = 'mit.eecs.6002x'
expected_branch = 'published'
expected_block_ref = 'HW3'
testobj = BlockUsageLocator(course_id=testurn)
self.check_block_locn_fields(testobj, 'test_block constructor',
course_id=expected_id,
branch=expected_branch,
block=expected_block_ref)
self.assertEqual(str(testobj), testurn)
self.assertEqual(testobj.url(), 'edx://' + testurn)
示例3: test_block_constructor
# 需要导入模块: from xmodule.modulestore.locator import BlockUsageLocator [as 别名]
# 或者: from xmodule.modulestore.locator.BlockUsageLocator import url [as 别名]
def test_block_constructor(self):
testurn = "mit.eecs.6002x" + BRANCH_PREFIX + "published" + BLOCK_PREFIX + "HW3"
expected_id = "mit.eecs.6002x"
expected_branch = "published"
expected_block_ref = "HW3"
testobj = BlockUsageLocator(course_id=testurn)
self.check_block_locn_fields(
testobj, "test_block constructor", course_id=expected_id, branch=expected_branch, 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
)
示例4: test_block_constructor
# 需要导入模块: from xmodule.modulestore.locator import BlockUsageLocator [as 别名]
# 或者: from xmodule.modulestore.locator.BlockUsageLocator import url [as 别名]
def test_block_constructor(self):
testurn = 'mit.eecs.6002x/' + BRANCH_PREFIX + 'published/' + BLOCK_PREFIX + 'HW3'
expected_id = 'mit.eecs.6002x'
expected_branch = 'published'
expected_block_ref = 'HW3'
testobj = BlockUsageLocator(package_id=testurn)
self.check_block_locn_fields(testobj, 'test_block constructor',
package_id=expected_id,
branch=expected_branch,
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',
package_id=expected_id,
branch=expected_branch,
block=expected_block_ref)