Repository navigation
test(model): pin from_resource schema-type coercion (issue #37) - #47
Merged
Merged
Conversation
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Issue #37 reported that
Model.from_resource()returned plain builtins for fields declared as schema types (created_atas plainstrinstead ofschema.DateTime), which is what let campus-cli call.isoformat()on a string and crash on every liveclient new/client get.The coercion fix itself has already landed upstream in campus and is active in this repo's dependency pin — no production code change is needed here:
dfb7d0c(fix(model): deserialize init=False and nested fields in from_resource) added str→str-subclass coercion and nested-model deserialization toModel.from_resource(), with its own unit testsac9dfdcmirrored the coercion infrom_storage()9e37b85, which this repo'spoetry.lockand venv already pin (PR chore(deps): bump campus-suite to weekly head 9e37b85 (campus #658 alignment check) #46)Verified against the pinned campus-suite:
Client.from_resource(...).created_atisschema.DateTimewith workingto_datetime(),id/emailcoerce toCampusID/Email, plain-primitive fields (str/bool/int) are untouched, andto_resource()round-trips JSON-serialisably.What this PR does
Adds
tests/unit/test_model_field_types.pypinning the field-type contract at this repo's boundary, following the same pattern astest_oauth_token_contract.py:DateTime,CampusID,Email) are coerced on parsed resources, including the nested OAuthToken inUserCredentialsand models returned byauth.clients.new()/.get()— the exact paths campus-cli consumesto_datetime(),Email.domain) are available on coerced fieldsIf a future campus-suite bump regresses the coercion, CI fails here instead of in campus-cli.
Fixes #37
Test plan
.venv/Scripts/python.exe -m pytest: 89 passed (80 existing + 9 new)