Repository navigation
Mockgun: implement download_attachment - #470
Open
patrickwolf wants to merge 2 commits into
Open
patrickwolf wants to merge 2 commits into
patrickwolf wants to merge 2 commits into
Conversation
upload raised NotImplementedError. It now validates the path and the field as the server does and creates the records an upload leaves: an Attachment linked to the entity, holding the file's name, size and tags, and the File/Link field pointing at it. A thumbnail field sets the entity's image field. The file itself is not stored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
upload now keeps a copy of the file in a temporary folder, removed with the Mockgun instance. download_attachment returns it, as bytes or written to file_path, for an Attachment entity, a File/Link field value or an id, and also returns the file of a local file link. It raises ShotgunFileDownloadError for an attachment it has no file for, as the server does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
patrickwolf
force-pushed
the
mockgun-download-attachment
branch
from
November 16, 2026 17:45
97950b5 to
2563f0b
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.
Builds on the upload PR #469 (
mockgun-upload); this diff shows only the download part.Problem
Mockgun has no
download_attachment, so code that downloads a movie or a file it uploaded cannot be tested on Mockgun.Change
uploadkeeps a copy of the file in a temporary folder, made on the first upload and removed when the Mockgun instance is garbage-collected. The copy outlives the source file, as an upload does.download_attachment(attachment, file_path=None, attachment_id=None)has the same signature asShotgun.download_attachmentand accepts the same arguments: an Attachment entity, a File/Link field value, or an Attachment id (also through the deprecatedattachment_id).file_pathand returns that path. It returnsNoneforNone.link_type: "local") returns the file at itslocal_path.ShotgunFileDownloadError, and a call without an attachment raisesTypeError, as on the server.Tests
TestDownloadAttachment: download by entity, field value, id andattachment_id, to bytes and to a path; the copy outlives the source; a local file link; missing attachments; the folder is removed with the instance.Merge order
Merge after the upload PR #469 , then point this one at
master. If the field types, default value types or limit and page PRs are merged first, this one needs a rebase that keeps their test classes next to its own at the end oftests/test_mockgun.py.