當前位置: 首頁>>代碼示例>>Python>>正文


Python locator.LibraryLocator類代碼示例

本文整理匯總了Python中opaque_keys.edx.locator.LibraryLocator的典型用法代碼示例。如果您正苦於以下問題:Python LibraryLocator類的具體用法?Python LibraryLocator怎麽用?Python LibraryLocator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LibraryLocator類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_for_branch

    def test_for_branch(self):
        lib_key = LibraryLocator(org='TestX', library='test', branch='initial')

        branch2 = "br2"
        branch2_key = lib_key.for_branch(branch2)
        self.assertEqual(branch2_key.branch, branch2)  # pylint: disable=no-member

        normal_branch = lib_key.for_branch(None)
        self.assertEqual(normal_branch.branch, None)  # pylint: disable=no-member
開發者ID:edx,項目名稱:opaque-keys,代碼行數:9,代碼來源:test_library_locators.py

示例2: test_lib_key_no_deprecated_support

 def test_lib_key_no_deprecated_support(self):
     lib_key = CourseKey.from_string('library-v1:TestX+lib1')
     with self.assertRaises(AttributeError):
         lib_key.to_deprecated_string()
     with self.assertRaises(NotImplementedError):
         lib_key._to_deprecated_string()  # pylint: disable=protected-access
     with self.assertRaises(NotImplementedError):
         LibraryLocator._from_deprecated_string('test/test/test')  # pylint: disable=protected-access
     with self.assertRaises(InvalidKeyError):
         LibraryLocator(org='org', library='code', deprecated=True)
開發者ID:edx,項目名稱:opaque-keys,代碼行數:10,代碼來源:test_library_locators.py

示例3: test_from_json_studio_editor_style

 def test_from_json_studio_editor_style(self):
     """
     Test that LibraryList can parse raw libraries list as passed by studio editor
     """
     lib_list = LibraryList()
     lib1_key, lib1_version = u'library-v1:Org1+Lib1', '5436ffec56c02c13806a4c1b'
     lib2_key, lib2_version = u'library-v1:Org2+Lib2', '112dbaf312c0daa019ce9992'
     raw = [lib1_key + ',' + lib1_version, lib2_key + ',' + lib2_version]
     parsed = lib_list.from_json(raw)
     self.assertEqual(len(parsed), 2)
     self.assertEquals(parsed[0].library_id, LibraryLocator.from_string(lib1_key))
     self.assertEquals(parsed[0].version, ObjectId(lib1_version))
     self.assertEquals(parsed[1].library_id, LibraryLocator.from_string(lib2_key))
     self.assertEquals(parsed[1].version, ObjectId(lib2_version))
開發者ID:feedbackfruits,項目名稱:edx-platform,代碼行數:14,代碼來源:test_library_content.py

示例4: test_lib_key_constructor_version_guid

    def test_lib_key_constructor_version_guid(self, version_id):
        version_id_str = str(version_id)
        version_id_obj = ObjectId(version_id)

        lib_key = LibraryLocator(version_guid=version_id)
        self.assertEqual(lib_key.version_guid, version_id_obj)  # pylint: disable=no-member
        self.assertEqual(lib_key.org, None)
        self.assertEqual(lib_key.library, None)  # pylint: disable=no-member
        self.assertEqual(str(lib_key.version_guid), version_id_str)  # pylint: disable=no-member
        # Allow access to _to_string
        # pylint: disable=protected-access
        expected_str = u'@'.join((lib_key.VERSION_PREFIX, version_id_str))
        self.assertEqual(lib_key._to_string(), expected_str)
        self.assertEqual(str(lib_key), u'library-v1:' + expected_str)
        self.assertEqual(lib_key.html_id(), u'library-v1:' + expected_str)
開發者ID:edx,項目名稱:opaque-keys,代碼行數:15,代碼來源:test_library_locators.py

示例5: _get_library

    def _get_library(self, library_key):
        """
        Given a library key like "library-v1:ProblemX+PR0B", return the
        'library' XBlock with meta-information about the library.

        Returns None on error.
        """
        if not isinstance(library_key, LibraryLocator):
            library_key = LibraryLocator.from_string(library_key)
        assert library_key.version_guid is None

        try:
            return self.store.get_library(library_key, remove_version=False, remove_branch=False)
        except ItemNotFoundError:
            return None
開發者ID:akbargumbira,項目名稱:Labster.EdX,代碼行數:15,代碼來源:library_tools.py

示例6: __new__

 def __new__(cls, library_id, version=None):
     # pylint: disable=super-on-old-class
     if not isinstance(library_id, LibraryLocator):
         library_id = LibraryLocator.from_string(library_id)
     if library_id.version_guid:
         assert (version is None) or (version == library_id.version_guid)
         if not version:
             version = library_id.version_guid
         library_id = library_id.for_version(None)
     if version and not isinstance(version, ObjectId):
         try:
             version = ObjectId(version)
         except InvalidId:
             raise ValueError(version)
     return super(LibraryVersionReference, cls).__new__(cls, library_id, version)
開發者ID:akbargumbira,項目名稱:Labster.EdX,代碼行數:15,代碼來源:library_content_module.py

示例7: source_library_key

 def source_library_key(self):
     """
     Convenience method to get the library ID as a LibraryLocator and not just a string
     """
     return LibraryLocator.from_string(self.source_library_id)
開發者ID:Colin-Fredericks,項目名稱:edx-platform,代碼行數:5,代碼來源:library_content_module.py

示例8: test_lib_key_with_trailing_whitespace

 def test_lib_key_with_trailing_whitespace(self, lib_id_fmt, whitespace):
     with self.assertRaises(InvalidKeyError):
         LibraryLocator.from_string(lib_id_fmt.format(whitespace))
開發者ID:edx,項目名稱:opaque-keys,代碼行數:3,代碼來源:test_library_locators.py

示例9: test_lib_key_from_invalid_string

 def test_lib_key_from_invalid_string(self, lib_id_str):
     with self.assertRaises(InvalidKeyError):
         LibraryLocator.from_string(lib_id_str)
開發者ID:edx,項目名稱:opaque-keys,代碼行數:3,代碼來源:test_library_locators.py

示例10: test_changing_course

 def test_changing_course(self):
     lib_key = LibraryLocator(org="TestX", library="test")
     with self.assertRaises(AttributeError):
         lib_key.course = "PHYS"
     with self.assertRaises(KeyError):
         lib_key.replace(course="PHYS")
開發者ID:edx,項目名稱:opaque-keys,代碼行數:6,代碼來源:test_library_locators.py

示例11: test_version_only_lib_key

 def test_version_only_lib_key(self):
     version_only_lib_key = LibraryLocator(version_guid=ObjectId('519665f6223ebd6980884f2b'))
     self.assertEqual(version_only_lib_key.org, None)
     self.assertEqual(version_only_lib_key.library, None)  # pylint: disable=no-member
     with self.assertRaises(InvalidKeyError):
         version_only_lib_key.for_branch("test")
開發者ID:edx,項目名稱:opaque-keys,代碼行數:6,代碼來源:test_library_locators.py


注:本文中的opaque_keys.edx.locator.LibraryLocator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。