Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions scripts/deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,19 @@ def run(slug, provider, live, publish, new_version, delete_draft,
set_field(slug, "archived_version", meta.get("version") or "0.0.0")
steps.append("stamped archived_at %s (version %s)"
% (stamp, meta.get("version")))
# The DOI has to reach the ARTICLE's front matter too, not only
# metadata.yml: that is where the PDF's title page takes it from,
# and `pixi run test` asserts the two agree. Run here, the request
# carries both files and the publish needs nothing further. Run at
# publish instead, it would land on the runner and have to be
# written back -- the step this flow exists to remove.
import subprocess
if subprocess.call([sys.executable, "scripts/sync_archival.py"],
cwd=ROOT) != 0:
raise DepositError(
"could not write the reserved DOI into the article's "
"front matter; nothing else was changed")
steps.append("wrote the DOI into the article front matter")
print("\n".join(" " + s for s in steps))
print("\nReserved and stopped. The identifiers are in "
"metadata.yml; commit them, and the deposit runs when they "
Expand Down
18 changes: 18 additions & 0 deletions tests/test_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2374,6 +2374,24 @@ def test_an_open_request_is_not_asked_for_twice():
"and it must subtract them from what it asks about"


def test_the_reserve_writes_the_doi_into_the_article_too():
"""A deposit request has to carry BOTH files.

`metadata.yml` holds the record for the guard; the article's own front
matter is where the PDF's title page takes the DOI from, and
`test_the_pdf_carries_the_archival_doi_once_a_note_is_deposited` asserts
the two agree. The first live reserve wrote only the metadata and that
test failed on the request it opened -- correctly, because a publish from
that state would have produced a PDF with no DOI on it.
"""
src = (ROOT / "scripts" / "deposit.py").read_text(encoding="utf-8")
reserve = src.split("if not rebuild:")[1].split("return")[0]
assert "sync_archival.py" in reserve, \
"the reserve must write the DOI into the article front matter"
for field in ("archived_at", "archived_version"):
assert field in reserve, "%s must be stamped by the reserve" % field


def test_the_deposit_reminder_asks_on_a_schedule_as_well_as_on_a_push():
"""The push trigger fires on a metadata CHANGE; the condition it cares
about is a STATE — archival, published, and holding no record.
Expand Down
Loading