sgmock.shotgun

Mock replacement for shotgun_api3 module.

class sgmock.shotgun.Shotgun(base_url=None, *args, **kwargs)

A mock Shotgun server, replicating the shotgun_api3 interface.

The constructor is a dummy and eats all arguments.

batch(requests)

Perform a series of requests in one request.

This mock does not have transactions, so a failed request will leave the data store in a partially mutated state.

Parameters:requests (list) – A series of dicts representing requests.
Returns:list of results from calling methods individually.
create(entity_type, data, return_fields=None, _log=True, _generate_events=True)

Store an entity of the given type and data; return the new entity.

Parameters:
  • entity_type (str) – The type of the entity.
  • data (dict) – The fields for the new entity.
  • return_fields (list) – Which fields to return from the server in addition to those explicitly stored; only good for updated_at in this mock version.
delete(entity_type, entity_id, _generate_events=True)

Delete a single entity.

This mock does not have retired entities, so once it is deleted an entity is gone.

Parameters:
  • entity_type (str) – The type of the entity to delete.
  • entity_id (int) – The id of the entity to delete.
Return bool:

True if the entity did exist.

find(entity_type, filters, fields=None, order=None, filter_operator=None, limit=500, retired_only=False, page=1)

Find and return entities satifying a list of filters.

We currently support deep-linked fields in the return fields, but not in filters.

Parameters:
  • entity_type (str) – The type of entities to find.
  • filters (list) – A list of filters
  • fields (list) – Which fields to return.
  • order – Ignored.
  • filter_operator – Ignored.
  • limite – Ignored.
  • retired_only – Ignored.
  • page – Ignored.
Returns:

list of ``dict``s.

find_one(entity_type, filters, fields=None, order=None, filter_operator=None, retired_only=False)

Find and return a single entity.

This is the same as calling find() and only returning the first result.

Returns:dict or None.
exception sgmock.shotgun.ShotgunError

Exception for all server logic.

exception sgmock.shotgun.Fault

Exception for all remote API logic; unused in this mock.