sg-mockgun
Mockgun, the in-memory Flow Production Tracking mock that ships inside shotgun_api3, taken out on its own and extended with behaviour recorded by sg-groundtruth.
Status: 0.1.0. Mockgun as vendored from shotgun_api3 3.10.5, upstream tests passing, plus a clean
current schema, schema field writes, an event log, and an HTTP server a real client connects to.
Why
Upstream mockgun covers find, create, update, delete, revive and batch against a pickled schema. It
raises NotImplementedError on schema_field_create, schema_field_update and
schema_field_delete, and has no event log. A live site refuses a data type change, keeps a
deleted field's name taken and records every write in the event log. Code tested on mockgun never
meets those answers.
Event log
Every create, update, delete, revive and schema field write adds EventLogEntry rows shaped as the
site writes them (docs/api3-probe-2026-11-12.md, findings 025 and 049), queryable with find:
- A create logs
Shotgun_<Type>_New, then one_Changeper field it set, within_create: true. - An update logs one
_Changeper field whose value changed,meta.old_valueandmeta.new_value. - A delete logs a
retirement_datechange and_Retirement, and drops theentitylink from every earlier row for that entity;meta.entity_idkeeps the trail. A revive logs the reverse and_Revival. - Field create, rename and delete log
Shotgun_DisplayColumn_*rows.
sg.generate_event_log_entries = False turns logging off, as the ApiUser flag does on a site (default
on here, off on a site). sg.set_clock(fn) makes timestamps deterministic.
Not modelled: server-set defaults logged on create, the internal properties row a rename also
writes, and event ids that a site reserves ahead and commits late (finding 025).
Schema field writes
schema_field_create, schema_field_update and schema_field_delete answer as a Flow PT 8.91 site
answered over api3 (docs/api3-probe-2026-11-12.md), with shotgun_api3.Fault and the site's words:
- The code is
sg_+ the lowercased display name, non-alphanumerics to_.sg_foobecomessg_sg_foo. - A display name already taken by a live field is silently suffixed:
_1,_2. - A deleted field's code stays taken. Creating it again, at any type, is refused, and api3 has no revive.
data_typecannot be updated. Onlyname,visible,description,summary_default,custom_metadataanduniquecan.query,summary,colorandimagecannot be created.calculatedfails as it does with no formula.entityandmulti_entityneed onevalid_types;checkboxneeds a boolean default.- Schema writes are per instance.
Two answers are not recorded over api3 and say so in the code: a valid_types with several types
uses the REST wording, and a calculated create carrying a formula is unmeasured.
Bundled schema
sg_mockgun.schemas.paths() returns a schema pulled from a Flow PT 8.91 site on 2026-11-12: 95
entity types, 1471 fields. Upstream's test schema predates visible, calculated, summary and
jsonb fields; this one has them.
It holds only what any site ships. sg_mockgun.clean.clean_schema keeps a field when the site cannot
hide it (visible.editable false, sg-groundtruth finding 056), when upstream's test schema has it, or
when its name carries no sg_ prefix, since every custom field gets one (finding 019). Custom
entities the site enabled are dropped with their connection entities and every link to them.
tools/pull_schema.py pulls and cleans a schema from any site, read-only.
schemas.paths("upstream_3_10_5") is Autodesk's own test schema from shotgun_api3 3.10.5, as
published in its repository under BSD-3. Older (77 entity types, 1035 fields, no visible key), but
it ships with the client's own licence and covers the common production entities.
Use
pip install sg-mockgun
from sg_mockgun import Shotgun, schemas
Shotgun.set_schema_paths(*schemas.paths())
sg = Shotgun("https://mock.example.com", script_name="x", api_key="y")
Serve
sg-mockgun serve --host 0.0.0.0 --port 8080
import shotgun_api3
sg = shotgun_api3.Shotgun("http://localhost:8080", script_name="any", api_key="any")
One mockgun instance behind the api3 JSON protocol: info, read with paging, create, update,
delete, revive, batch and the schema_* calls. Any script name and key are accepted, and the
script name is the event log's user. Faults come back in the site's exception envelope; any other
method answers Error: API method "<name>" is not permitted., as a site does. Calls are serialised
under one lock.
Next to api3 it serves the two REST routes a site needs to revive a trashed field, which api3
cannot do: POST /api/v1/auth/access_token (client_credentials with the script name and key,
session_token from sg.get_session_token(), refresh_token; form-encoded only) and
POST /api/v1/schema/<Type>/fields/<field> with revive true, in the body or the query. The field
comes back at its original type. Answers from sg-groundtruth finding 040 and its endpoint cards;
any other REST path is a 404. In-process, sg.revive_field(entity_type, code) does the same.
State lives in memory; sg_mockgun.server.make_server(mock) serves an instance you
have seeded yourself.
Develop
uv sync
uv run pytest
License
BSD-3-Clause, as upstream. src/sg_mockgun/ started as shotgun_api3/lib/mockgun from
shotgun_api3 3.10.5, Copyright (c) 2009-2011 Shotgun Software Inc. tests/test_upstream_mockgun.py
and tests/fixtures/upstream/ are upstream's tests and test schema, with import paths changed.
Metadata
Release files for sg-mockgun 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sg_mockgun-0.1.0.tar.gz | 534.2 kB | With provenance | Details for sg_mockgun-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sg_mockgun-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sg_mockgun-0.1.0-py3-none-any.whl |
Total release size: 884.2 kB
Release files / sg_mockgun-0.1.0.tar.gz
| Download URL | sg_mockgun-0.1.0.tar.gz |
|---|---|
| Size | 534.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8aa4f9d5e80a9b6cfb9f8c8f52ff0dcdd75474eed1a672015b046f8c5c17d453
|
|
BLAKE2b-256 checksum How to use checksums |
7c578363096d30991ed85741ada812ab5c9c123c575f09aebe478b866a2c9519
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logRelease files / sg_mockgun-0.1.0-py3-none-any.whl
| Download URL | sg_mockgun-0.1.0-py3-none-any.whl |
|---|---|
| Size | 350.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f6c13fd68ea2dd5cd4d0620cac7278d73c3c70daf5418f66346058f2f10df2d
|
|
BLAKE2b-256 checksum How to use checksums |
dffe8e49745fc1390d1a91b31dd1bf0845e03acf35cfd2e9a3c57b9b92e6de19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logSecurity for sg-mockgun 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sg_mockgun-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.