Stateful in-memory/SQLite mock of the Mastodon REST API for testing Mastodon clients
Project description
Mastodon Mock
mastodon_mock is a stateful, local Mastodon REST API for tests and development. It runs a
real FastAPI server backed by in-memory or file-backed SQLite, so client code can post
statuses, follow accounts, build timelines, manage lists and filters, file reports, and
exercise OAuth/admin flows without touching a live instance.
Use it when you want the confidence of real HTTP and persisted state, without flaky network tests, rate limits, public test posts, or hand-written response mocks.
Highlights:
- Real Mastodon-shaped HTTP API, tested against Mastodon.py.
- Fast disposable SQLite state, with deterministic seed data and reset support.
- Pytest fixtures, a context manager, and decorator sugar for zero-boilerplate tests.
- Bulk sample-data generation for demos, UI work, and performance checks.
- Bundled web client and admin UI at
/_ui/when the package includes the built frontend. - Admin/moderation endpoints for account actions, reports, domain blocks, email blocks, and IP blocks.
Installation
pipx install mastodon_mock
Or with pip:
pip install mastodon_mock
Usage
Run the mock server:
mastodon_mock serve --in-memory
Point a client at it:
from mastodon import Mastodon
client = Mastodon(access_token="mock_token", api_base_url="http://127.0.0.1:3000")
client.status_post("hello from a mock!")
Open http://127.0.0.1:3000/_ui/ for the bundled browser UI when it is available.
For a populated local instance, generate a throwaway cohort into a SQLite file and point
your config's [database].path at it:
mastodon_mock gen-data --preset small --database ./mastodon_mock.sqlite --yes
Documentation
See the documentation for configuration, fixtures, endpoint coverage, data generation, and admin UI/API details.
Contributing
See CONTRIBUTING.md.
License
MIT. See LICENSE.
Changelog
See CHANGELOG.md.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mastodon_mock-0.1.0.tar.gz.
File metadata
- Download URL: mastodon_mock-0.1.0.tar.gz
- Upload date:
- Size: 203.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43d7aca8c85100c233d5acd1dd4da92533b5f3f9ac62b60a226a99f36e638eff
|
|
| MD5 |
29f10da85824f5730f8c41bfa8c58e15
|
|
| BLAKE2b-256 |
7833e0853a5c001c3383a1e66d48043ffc19bde0dfc263021fafd128df173f02
|
Provenance
The following attestation bundles were made for mastodon_mock-0.1.0.tar.gz:
Publisher:
release.yml on matthewdeanmartin/mastodon_mock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mastodon_mock-0.1.0.tar.gz -
Subject digest:
43d7aca8c85100c233d5acd1dd4da92533b5f3f9ac62b60a226a99f36e638eff - Sigstore transparency entry: 1841515363
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/mastodon_mock@20fdbc3388b664509fed84a40df1a8f44d242c36 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@20fdbc3388b664509fed84a40df1a8f44d242c36 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mastodon_mock-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mastodon_mock-0.1.0-py3-none-any.whl
- Upload date:
- Size: 242.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cfde2fa88a8433adde7303b6b6317cc9cc5c62a1dc6e29af2560399fb8eec77
|
|
| MD5 |
69d469a0bcfa9a254109a5603f3440f1
|
|
| BLAKE2b-256 |
4a1afaab5ef2605dbe0ae8281803ef77251d6ef3ecc309fe044f88b4f38cd9b7
|
Provenance
The following attestation bundles were made for mastodon_mock-0.1.0-py3-none-any.whl:
Publisher:
release.yml on matthewdeanmartin/mastodon_mock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mastodon_mock-0.1.0-py3-none-any.whl -
Subject digest:
8cfde2fa88a8433adde7303b6b6317cc9cc5c62a1dc6e29af2560399fb8eec77 - Sigstore transparency entry: 1841515535
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/mastodon_mock@20fdbc3388b664509fed84a40df1a8f44d242c36 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@20fdbc3388b664509fed84a40df1a8f44d242c36 -
Trigger Event:
release
-
Statement type: