feat!: Collection.key -> Collection.collection_code#504
feat!: Collection.key -> Collection.collection_code#504kdmccormick wants to merge 1 commit intomainfrom
Conversation
12e7dc6 to
89d04ed
Compare
| "has#hash", | ||
| ] | ||
| for code in invalid_codes: | ||
| with self.subTest(code=code): |
There was a problem hiding this comment.
I've never seen subTest before--I'd have used ddt myself--but Claude generated it and I think I like it. Reviewers, let me know if you disagree.
There was a problem hiding this comment.
I am trying to use @pytest.mark.parametrize instead of ddt, because ddt has no types and is not really maintained. But @pytest.mark.parametrize doesn't work on UnitTest class methods, so this seems like a nice alternative :)
|
@ormsbee , @bradenmacdonald , could one of you review when you have a chance? I won't merge until Braden's Containers change is released, as to not complicate that. |
Also, standardize internal usage of collection_key to collection_code. This helps clarify that Collection.key is *not* an OpaqueKey, but is rather a local slug, which can be combined with other identifiers to form a fully- qualified LibraryCollectionKey instance. BREAKING CHANGE: Collection.key has been renamed to Collection.collection_code. BREAKING CHANGE: Collection.collection_code now validates that its contents matches '[A-Za-z0-9\-\_\.]+'. This was already effectively true, because LibraryCollectionKey can only be built with slug-like parts, but we now we explicitly raise ValiationError from create_collection. Backup now writes both 'key' and 'collection_code' to collection TOML files, so older software (which only knows 'key') can still read new archives. Restore accepts either field, preferring 'collection_code' and falling back to the legacy 'key'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Part of: #322
5c635f8 to
55c3071
Compare
|
@ormsbee @bradenmacdonald , this is ready. Curious if you'd prefer |
|
@ormsbee @bradenmacdonald I think I should let the OEP land before merging this or any opaque-key changes. I'll return this to draft, feel free to unsubscribe and not review for the time being. I'll probably queue more of the changes up into this PR so we can review and merge shortly after the OEP is merged (4/13). |
Description
Also, standardize internal usage of collection_key to collection_code.
This helps clarify that Collection.key is not an OpaqueKey, but is rather
a local slug, which can be combined with other identifiers to form a fully-
qualified LibraryCollectionKey instance.
Backup now writes both 'key' and 'collection_code' to collection TOML files,
so older software (which only knows 'key') can still read new archives.
Restore accepts either field, preferring 'collection_code' and falling back
to the legacy 'key'.
BREAKING CHANGE: Collection.key has been renamed to Collection.collection_code,
and Collection.objects.get_by_key is now Collection.objects.get_by_code.
BREAKING CHANGE: Collection.collection_code now validates that its contents
matches '[A-Za-z0-9-_.]+'. This was already effectively true, because
LibraryCollectionKey can only be built with slug-like parts, but we now
we explicitly raise ValiationError from create_collection.
Supporting info
This follows the naming convention proposed in: openedx/openedx-proposals#773
Part of: #322
Related openedx-platform PR: openedx/openedx-platform#38214
Testing
Things that work without any openedx-platform changes:
The Collections tab renders in a library
Django admin looks good:
Running Backup yields both key and collection_code
Things I'll test once I have the openedx-platform PR ready:
AI disclosure
I used Claude Code to write:
I reviewed all of that code carefully.