Repository navigation
Mockgun: return default values in the types the server returns - #467
Open
patrickwolf wants to merge 1 commit into
Open
patrickwolf wants to merge 1 commit into
patrickwolf wants to merge 1 commit into
Conversation
New records took their defaults from the schema as stored: an unset checkbox could be None, empty text "", and a number the string "0". The server returns False, None and 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
patrickwolf
force-pushed
the
mockgun-default-value-types
branch
from
November 16, 2026 17:45
ca9f564 to
3d389ba
Compare
This branch has not been deployed
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.
Problem
A new record takes each field's default straight from the schema's
default_value, in whatever form the schema stores it. In the schema shipped intests/mockgun, 9 checkbox fields haveNoneas their default (for exampleProject.current_user_favorite) and 4 text fields have""(for exampleHumanUser.email). Schemas read from newer sites can also store a number's default as a string such as"0". The server returnsFalse,Noneand0for these, so code that checksis Falseor does arithmetic behaves differently under Mockgun.Change
_get_default_valueconverts the default the way the server returns it: a checkbox to a bool, empty text toNone, and a number, percent, duration or timecode stored as a string to an int (a float or currency to a float)._get_new_rownow uses_get_default_valueinstead of repeating its logic.Tests
TestDefaultValues: an unset checkbox isFalse, empty text isNone, and a number default stored as"0"is0(the test changes the shared schema and restores it afterwards).Merge order
Independent of the other Mockgun PRs (field types, limit and page, upload), but each of them also adds its test class at the end of
tests/test_mockgun.py. Whichever is merged later needs a rebase that keeps both test classes.