Skip to content

Commit 164c047

Browse files
committed
fix: tests
Error was: TypeError: LibraryUsageLocatorV2.__init__() got an unexpected keyword argument 'deprecated' while generating 'serialized' from valid_key_string()
1 parent 917c04b commit 164c047

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

opaque_keys/edx/locator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1568,12 +1568,17 @@ class LibraryUsageLocatorV2(CheckFieldMixin, UsageKeyV2):
15681568
# Allow usage IDs to contian unicode characters
15691569
USAGE_ID_REGEXP = re.compile(r'^[\w\-.]+$', flags=re.UNICODE)
15701570

1571-
def __init__(self, lib_key: LibraryLocatorV2, block_type: str, usage_id: str):
1571+
def __init__(self, lib_key: LibraryLocatorV2, block_type: str, usage_id: str, **kwargs):
15721572
"""
15731573
Construct a LibraryUsageLocatorV2
15741574
"""
15751575
if not isinstance(lib_key, LibraryLocatorV2):
15761576
raise TypeError("lib_key must be a LibraryLocatorV2")
1577+
1578+
# LibraryUsageLocatorV2 is a new type of locator so should never be deprecated.
1579+
if lib_key.deprecated or kwargs.get('deprecated', False):
1580+
raise InvalidKeyError(self.__class__, "LibraryUsageLocatorV2s are never deprecated.")
1581+
15771582
self._check_key_string_field("block_type", block_type)
15781583
self._check_key_string_field("usage_id", usage_id, regexp=self.USAGE_ID_REGEXP)
15791584
super().__init__(

0 commit comments

Comments
 (0)