Skip to main content

Stateful in-memory/SQLite mock of the Mastodon REST API for testing Mastodon clients

Project description

Mastodon Mock

PyPI version CI Python versions License: MIT

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.toml file.
  • 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

mastodon_mock-0.0.1.tar.gz (100.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mastodon_mock-0.0.1-py3-none-any.whl (98.3 kB view details)

Uploaded Python 3

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

Hashes for mastodon_mock-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a8e47effb536654e28445de45d1fbb6339ad379842fd36a96a072908cce7ccf4
MD5 0859fdc83a0b9e8638716665b469a098
BLAKE2b-256 2088b29458039b6da10e4a04015a7055071d3f0ff517811705ba1c8f88a37d19

See more details on using hashes here.

Provenance

The following attestation bundles were made for mastodon_mock-0.0.1.tar.gz:

Publisher: release.yml on matthewdeanmartin/mastodon_mock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for mastodon_mock-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94e58a25d6346bf56c9308b700f532aa1ed3bcc7b6fa28c5e76dc07a278065a9
MD5 bbf0eb6fba8644cbc0bce33a581c5800
BLAKE2b-256 9dea7267e4f8472c72d532b486b2329d4bdd17411f1e8f81ee0ca2867e7a39c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mastodon_mock-0.0.1-py3-none-any.whl:

Publisher: release.yml on matthewdeanmartin/mastodon_mock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page