Skip to main content

zenodo-mock

A local, credential-free stand-in for the Zenodo API, so a full publish round-trip can run on a dev VM or in CI without a Zenodo token.

Stdlib only — no runtime dependencies.

Install

pip install zenodo-mock

Run

zenodo-mock --port 8766
# Deposit API:  http://127.0.0.1:8766/api/deposit/depositions

(Or python -m zenodo_mock --port 8766.)

The deposit API always runs. Pass --source-outputs <dir> to also serve a fixed pre-staged read record (the fetch/consume demo); omit it to run deposit-only, which is all a bare VM needs. Uploaded deposit files land under --storage-dir.

Publish round-trip (no token)

Point any Zenodo publisher at the mock. For example, marinerg-data:

marinerg-data publish <bundle> --zenodo-url http://127.0.0.1:8766/api --skip-ckan
# → mints a DOI (10.5072/zenodo.<id>), uploads files, and the record becomes
#   resolvable at /api/records/<id>. --new-version works too.

The DOI is pre-reserved on the draft and returned in metadata.prereserve_doi, as Zenodo's deposit API does — so a publisher can record the identifier before it takes the step it cannot undo.

Use it from a test

from zenodo_mock.testing import spawn

def test_publish_round_trip(tmp_path):
    with spawn(tmp_path / "deposits") as base_url:
        publish_against(f"{base_url}/api")

spawn runs the mock in a subprocess on a kernel-chosen port, waits for it to be serving, and tears it down — so concurrent suites cannot collide, and no caller has to reimplement the readiness wait. Add zenodo-mock to your dev dependency group.

What it implements

The subset of the Zenodo deposit API a publisher drives: create deposition, bucket upload, delete file, set metadata, publish (mints a DOI and registers a resolvable record), and new-version. State is in-memory. Not a faithful Zenodo — just enough for the round-trip.

Provenance

Extracted from marinerg-i/data-access-service (infra/zenodo_mock/) when that repo was archived, so the mock could be reused independently of the catalogue.

tests/test_server.py covers the deposit store, tests/test_http.py the HTTP layer over it, and tests/test_spawn.py the subprocess helper. The mock is also driven by the suites of marinerg-data and ckanext-marinerg, which is what proves their encodings of the Zenodo API and this one agree.

Licence

AGPL-3.0-or-later. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zenodo_mock-0.1.0.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

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

zenodo_mock-0.1.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file zenodo_mock-0.1.0.tar.gz.

File metadata

  • Download URL: zenodo_mock-0.1.0.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for zenodo_mock-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c31da41989ad291ae65396a2aff6815d407e0a9f9c09ed6f844a362e3730e824
MD5 4f39247633df1f9fae3a1a73198630a0
BLAKE2b-256 f2f1d34e83e153338291a2bb3872b48a8b5b0b6518b52cab2237f339d8af8557

See more details on using hashes here.

File details

Details for the file zenodo_mock-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: zenodo_mock-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for zenodo_mock-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ef49ff81fd77d778fc8e2ea753f91e248f19d8cddd947aba389a86f565156f0
MD5 fc822adcb9299811f2bbf68f3c1cbd97
BLAKE2b-256 ae09205b0c583c07976b8b64b83f4c0083ad44addd8696058f4160eaf0adde27

See more details on using hashes here.

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