Skip to main content

Mockgun

Mockgun is a testing utility that simulates a ShotGrid instance in memory. ShotGrid MCP Server includes an enhanced version of Mockgun that provides additional functionality and better compatibility with the ShotGrid API.

Why Use Mockgun?

Mockgun provides several benefits for development and testing:
  1. No ShotGrid Instance Required: Develop and test without connecting to a real ShotGrid instance.
  2. Faster Testing: In-memory operations are much faster than API calls.
  3. Controlled Environment: Create a consistent, predictable testing environment.
  4. No Side Effects: Test operations that would modify data without affecting real data.
  5. Offline Development: Develop and test without an internet connection.

Using Mockgun

Basic Setup

To use Mockgun, set use_mockgun=True when creating your server:

With Schema Files

For more realistic testing, provide schema files:

Creating Test Data

You can create test data in Mockgun just like you would with the real ShotGrid API:

Using Startup Handlers

A convenient way to create test data is with startup handlers:

Enhanced Mockgun Features

ShotGrid MCP Server’s Mockgun implementation includes several enhancements over the standard Mockgun:

Field Hopping Support

Mockgun supports “field hopping” (dot notation) in filters:

Advanced Filters

Mockgun supports a wide range of filter operators:

Batch Operations

Mockgun supports batch operations for creating, updating, and deleting entities:

Schema Validation

Mockgun validates entity types and fields against the schema:

Testing with Mockgun

Unit Testing

Mockgun is particularly useful for unit testing:

Integration Testing

For integration testing with MCP clients:

Best Practices

  1. Use Real Schema: For the most accurate testing, use schema files exported from your production ShotGrid instance.
  2. Create Realistic Test Data: Set up test data that closely resembles your production data.
  3. Test Edge Cases: Use Mockgun to test error conditions and edge cases that would be difficult to test with a real ShotGrid instance.
  4. Reset Between Tests: Create a fresh Mockgun instance for each test to ensure a clean state.
  5. Validate Against Real ShotGrid: Periodically validate your tests against a real ShotGrid instance to ensure Mockgun’s behavior matches.

Next Steps

Now that you understand Mockgun, you can: