From 98ceab53d8c0cd0e98c6c0181807919c42621e20 Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Tue, 27 Aug 2024 14:14:26 -0500 Subject: [PATCH] refactor: Rename CollectionKey to LibCollectionKey and CollectionLocator to LibCollectionLocator --- opaque_keys/edx/keys.py | 2 +- opaque_keys/edx/locator.py | 4 ++-- .../edx/tests/test_collection_locators.py | 18 +++++++++--------- setup.py | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/opaque_keys/edx/keys.py b/opaque_keys/edx/keys.py index 33ee561..73138c2 100644 --- a/opaque_keys/edx/keys.py +++ b/opaque_keys/edx/keys.py @@ -89,7 +89,7 @@ def make_asset_key(self, asset_type: str, path: str) -> AssetKey: # pragma: no raise NotImplementedError() -class CollectionKey(LearningContextKey): +class LibCollectionKey(LearningContextKey): """ An :class:`opaque_keys.OpaqueKey` identifying a particular Library Collection object. """ diff --git a/opaque_keys/edx/locator.py b/opaque_keys/edx/locator.py index fbbde0a..02bc396 100644 --- a/opaque_keys/edx/locator.py +++ b/opaque_keys/edx/locator.py @@ -16,7 +16,7 @@ from opaque_keys import OpaqueKey, InvalidKeyError from opaque_keys.edx.keys import AssetKey, CourseKey, DefinitionKey, \ - LearningContextKey, UsageKey, UsageKeyV2, CollectionKey + LearningContextKey, UsageKey, UsageKeyV2, LibCollectionKey log = logging.getLogger(__name__) @@ -1623,7 +1623,7 @@ def html_id(self) -> str: return str(self) -class CollectionLocator(CheckFieldMixin, CollectionKey): +class LibCollectionLocator(CheckFieldMixin, LibCollectionKey): """ When serialized, these keys look like: lib-collection:org:lib:collection-id diff --git a/opaque_keys/edx/tests/test_collection_locators.py b/opaque_keys/edx/tests/test_collection_locators.py index 5fcf921..741ba0f 100644 --- a/opaque_keys/edx/tests/test_collection_locators.py +++ b/opaque_keys/edx/tests/test_collection_locators.py @@ -1,16 +1,16 @@ """ -Tests of CollectionLocator +Tests of LibCollectionLocator """ import ddt from opaque_keys import InvalidKeyError from opaque_keys.edx.tests import LocatorBaseTest -from opaque_keys.edx.locator import CollectionLocator +from opaque_keys.edx.locator import LibCollectionLocator @ddt.ddt -class TestCollectionLocator(LocatorBaseTest): +class TestLibCollectionLocator(LocatorBaseTest): """ - Tests of :class:`.CollectionLocator` + Tests of :class:`.LibCollectionLocator` """ @ddt.data( "org/lib/id/foo", @@ -23,13 +23,13 @@ class TestCollectionLocator(LocatorBaseTest): ) def test_coll_key_from_invalid_string(self, coll_id_str): with self.assertRaises(InvalidKeyError): - CollectionLocator.from_string(coll_id_str) + LibCollectionLocator.from_string(coll_id_str) def test_coll_key_constructor(self): org = 'TestX' lib = 'LibraryX' code = 'test-problem-bank' - coll_key = CollectionLocator(org=org, lib=lib, usage_id=code) + coll_key = LibCollectionLocator(org=org, lib=lib, usage_id=code) lib_key = coll_key.context_key self.assertEqual(coll_key.org, org) self.assertEqual(coll_key.lib, lib) @@ -39,8 +39,8 @@ def test_coll_key_constructor(self): def test_coll_key_constructor_bad_ids(self): with self.assertRaises(ValueError): - CollectionLocator(org="!@#{$%^&*}", lib="lib1", usage_id='usage-id') + LibCollectionLocator(org="!@#{$%^&*}", lib="lib1", usage_id='usage-id') with self.assertRaises(ValueError): - CollectionLocator(org="TestX", lib="lib+1", usage_id='usage-id') + LibCollectionLocator(org="TestX", lib="lib+1", usage_id='usage-id') with self.assertRaises(ValueError): - CollectionLocator(org="TestX", lib="lib1", usage_id='usage-!@#{$%^&*}') + LibCollectionLocator(org="TestX", lib="lib1", usage_id='usage-!@#{$%^&*}') diff --git a/setup.py b/setup.py index 7eebb5a..7b4ad8a 100644 --- a/setup.py +++ b/setup.py @@ -131,7 +131,7 @@ def get_version(*file_paths): 'course-v1 = opaque_keys.edx.locator:CourseLocator', 'library-v1 = opaque_keys.edx.locator:LibraryLocator', 'lib = opaque_keys.edx.locator:LibraryLocatorV2', - 'lib-collection = opaque_keys.edx.locator:CollectionLocator', + 'lib-collection = opaque_keys.edx.locator:LibCollectionLocator', # don't use slashes in any new code 'slashes = opaque_keys.edx.locator:CourseLocator', ],