Stateful in-memory/SQLite mock of the Mastodon REST API for testing Mastodon clients
Project description
Mastodon Mock
mastodon_mock is a stateful, in-process mock of the Mastodon REST API. It runs a real
FastAPI server backed by a minimal in-memory (or on-disk) SQLite database, so client code
— including Mastodon.py — can post statuses, follow
accounts, build timelines, manage lists and filters, and exercise OAuth flows against a
fast, deterministic, side-effect-free target. It is intended for testing and local
development where talking to a live Mastodon instance is slow, flaky, or undesirable.
Installation
pipx install mastodon_mock
Or with pip:
pip install mastodon_mock
Usage
Run the mock server:
mastodon_mock serve --in-memory
Useful flags:
serve --config PATH— load configuration from a.mastodon_mock.tomlfile.serve --host HOST --port PORT— override the bind address.serve --in-memory— force an ephemeral in-memory SQLite database.db upgrade— run Alembic migrations to bring an on-disk database to head.
Point a client at it (for example, with Mastodon.py):
from mastodon import Mastodon
client = Mastodon(access_token="alice_token", api_base_url="http://127.0.0.1:8000")
client.status_post("hello from a mock!")
See mastodon_mock --help for the full command reference.
Configuration
Configuration is resolved in this order: an explicit --config path (or
./.mastodon_mock.toml), then a [tool.mastodon_mock] table in ./pyproject.toml,
then built-in defaults. See https://github.com/matthewdeanmartin/mastodon_mock/blob/main/docs/overview/README.md for details.
Contributing
See CONTRIBUTING.md.
License
MIT — see LICENSE.
Changelog
docs/overview/README.md 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.0.1.tar.gz.
File metadata
- Download URL: mastodon_mock-0.0.1.tar.gz
- Upload date:
- Size: 100.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8e47effb536654e28445de45d1fbb6339ad379842fd36a96a072908cce7ccf4
|
|
| MD5 |
0859fdc83a0b9e8638716665b469a098
|
|
| BLAKE2b-256 |
2088b29458039b6da10e4a04015a7055071d3f0ff517811705ba1c8f88a37d19
|
Provenance
The following attestation bundles were made for mastodon_mock-0.0.1.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.0.1.tar.gz -
Subject digest:
a8e47effb536654e28445de45d1fbb6339ad379842fd36a96a072908cce7ccf4 - Sigstore transparency entry: 1827613501
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/mastodon_mock@c268ba912e34287eb6eb522214e5e3cd6f80c6b6 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c268ba912e34287eb6eb522214e5e3cd6f80c6b6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mastodon_mock-0.0.1-py3-none-any.whl.
File metadata
- Download URL: mastodon_mock-0.0.1-py3-none-any.whl
- Upload date:
- Size: 98.3 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 |
94e58a25d6346bf56c9308b700f532aa1ed3bcc7b6fa28c5e76dc07a278065a9
|
|
| MD5 |
bbf0eb6fba8644cbc0bce33a581c5800
|
|
| BLAKE2b-256 |
9dea7267e4f8472c72d532b486b2329d4bdd17411f1e8f81ee0ca2867e7a39c4
|
Provenance
The following attestation bundles were made for mastodon_mock-0.0.1-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.0.1-py3-none-any.whl -
Subject digest:
94e58a25d6346bf56c9308b700f532aa1ed3bcc7b6fa28c5e76dc07a278065a9 - Sigstore transparency entry: 1827613651
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/mastodon_mock@c268ba912e34287eb6eb522214e5e3cd6f80c6b6 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c268ba912e34287eb6eb522214e5e3cd6f80c6b6 -
Trigger Event:
release
-
Statement type: