Skip to content

Commit

Permalink
refactor: Rename CollectionKey to LibCollectionKey and CollectionLoca…
Browse files Browse the repository at this point in the history
…tor to LibCollectionLocator
  • Loading branch information
ChrisChV committed Aug 27, 2024
1 parent 6e23233 commit 98ceab5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion opaque_keys/edx/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down
4 changes: 2 additions & 2 deletions opaque_keys/edx/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions opaque_keys/edx/tests/test_collection_locators.py
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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)
Expand All @@ -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-!@#{$%^&*}')
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
Expand Down

0 comments on commit 98ceab5

Please sign in to comment.