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.1.tar.gz (25.7 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.1-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zenodo_mock-0.1.1.tar.gz
  • Upload date:
  • Size: 25.7 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.1.tar.gz
Algorithm Hash digest
SHA256 34942382f6f1a9dd941645c275e6399f73c8154aefb38acd4dd5dc7fb71491e6
MD5 aeb1a8dcad2de4f51673c313ec6c9bae
BLAKE2b-256 2e7fccbfb8c8e1935c71cf0d0ec0a567ac670ff6611d7b7271523e87e842dab5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zenodo_mock-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e710a21c4217bebdbf4508758bf58dd93eb7bc9a1917ca71da93313bc920c4a0
MD5 d82b7b777d8366d6697287c35bafb863
BLAKE2b-256 9e8225ed87ad5e5c817da1d147ffc2530a3a805536b1a719295f90e6be73c076

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