Files
cc-ci/tests/ghost/functional/test_post_roundtrip.py
autonomic-bot b4d03ccafe feat(2): ghost P4 data-integrity overlay (MySQL ci_marker) + §4.3 create-post round-trip
- ops.py + test_{upgrade,backup,restore}.py: seed ci_marker into the MySQL `ghost` DB (db service)
  via the mysql CLI; rides the recipe's mysqldump --tab backup. recipe is MySQL not sqlite (stale
  comment fixed). Expect restore RED -> recipe-PR (no backupbot.restore hook; immich/mattermost class).
- functional/_ghost.py: cookie-aware Ghost Admin API client (stdlib http.cookiejar; Origin CSRF hdr).
- functional/test_post_roundtrip.py: §4.3 create published post + read back (unique marker, non-vacuous);
  closes the DEFERRED ghost create-post item.
- PARITY.md + recipe_meta.py updated. Authored node-free; full-lifecycle run next, NOT yet claimed.
2026-05-30 04:14:13 +01:00

60 lines
2.5 KiB
Python

"""ghost — Q4.4 recipe-specific functional test (plan §4.3: "create the app's primary object — a
post — and read it back").
Exercises Ghost's core publishing path end-to-end against the live per-run deploy, via the real
Admin API:
1. Wait for the Admin API to answer (the recipe's own healthcheck hits /ghost/api/admin/site/).
2. Bootstrap the owner on a fresh deploy + establish an admin session (_ghost.GhostAdmin).
3. POST /ghost/api/admin/posts/ to create a published post carrying a unique marker (title + body).
4. GET /ghost/api/admin/posts/<id>/ to read it back and assert the marker round-tripped intact.
NOT health-only: a Ghost whose DB/Admin-API/publishing path is broken fails here even though `/`
(themed front) and `/ghost/` (admin SPA shell) return 200. The marker is unique per run, so a stale
or echoed response cannot pass. This closes the DEFERRED.md ghost "create-a-post round-trip" item.
"""
from __future__ import annotations
import os
import sys
import uuid
sys.path.insert(0, os.path.dirname(__file__))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "runner"))
import _ghost # noqa: E402
from harness import http as harness_http # noqa: E402
def test_create_post_roundtrip(live_app):
# 1) The Admin API (and its DB migrations) may settle slightly after the themed front is up —
# poll the recipe's own admin healthcheck endpoint before authenticating.
harness_http.retry_http_get(
f"https://{live_app}/ghost/api/admin/site/",
expect_status=200,
max_wait=120,
interval=10,
)
admin = _ghost.GhostAdmin(live_app)
admin.ensure_authenticated()
# 2-3) Create a published post with a unique marker in both title and body.
uniq = uuid.uuid4().hex[:10]
title = f"ccci-marker-{uniq}"
marker = f"ccci-body-marker-{uniq}-roundtrip"
created = admin.create_post(title, f"<p>{marker}</p>")
assert created.get("title") == title, (
f"created post title mismatch: sent {title!r}, got {created.get('title')!r}"
)
# 4) Read it back by id and assert the post survived the round-trip (title always returned;
# html returned because we requested ?formats=html).
got = admin.get_post(created["id"])
assert got.get("title") == title, (
f"post title did not round-trip: sent {title!r}, got {got.get('title')!r}"
)
html = got.get("html") or ""
assert marker in html, (
f"post body did not round-trip: marker {marker!r} not in read-back html {html!r}"
)